Siren AI scripting API reference

Classes

GenerativeAi

Generative AI class. Accessible via sirenapi.extensions.GenerativeAi

Methods

generateGraphReport()
static generateGraphReport(graphModel, options?): Promise<{
  content: string;
}>;

Generate a report from a graph model

Parameters
Parameter Type Description

graphModel

GraphModel

The graph model to generate a report from. Retrieved from the graphBrowserVis.getGraphModel()

options?

GraphReportOptions

Graph report options GraphReportOptions)

Returns

Promise<{ content: string; }>

  • The generated report content in Markdown format

Example
const graphVis = sirenapi.Visualization.getCurrentVisualizer()
const graphModel = await graphVis.getGraphModel()
await sirenapi.extensions.GenerativeAi.generateGraphReport(graphModel)

sendPrompt()
static sendPrompt(message, options?): Promise<PromptResponse>;

Send a prompt to the AI

Parameters
Parameter Type Description

message

string

The message to send to the AI

options?

{ contextId?: string; }

Additional options

options.contextId?

string

The ID of the conversation context; helps the LLM remember previous messages

Returns

Promise<PromptResponse>

  • The response from the LLM

Example
await sirenapi.extensions.GenerativeAi.sendPrompt('What is 2 * 4?')

Interfaces

GraphReportOptions

Properties

customPrompt?
optional customPrompt: string;

Custom prompt for the LLM to generate the report

focusNodes?
optional focusNodes: string[];

IDs of nodes to focus on in the report


K9Message

Extends

  • BaseMessage

Properties

content
content: string;

Formatted in Markdown

Inherited from
BaseMessage.content

errors?
optional errors: object;
attachment
attachment: string;

timestamp
timestamp: string;

ISO format

Inherited from
BaseMessage.timestamp

type
type: "message";
Inherited from
BaseMessage.type

user
user: K9;
Overrides
BaseMessage.user

PromptResponse

Properties

contextId
contextId: string;

data
data: (
  | ToolCall
  | ToolCallResponse
  | K9Message)[];

usage?
optional usage: TokenUsage;

TokenUsage

Properties

inputTokens
inputTokens: number;

outputTokens
outputTokens: number;

totalTokens
totalTokens: number;

ToolCall

Properties

callId
callId: string;

function
function: object;
arguments
arguments: string;

JSON string of arguments

name
name: string;

type
type: "function_call";

ToolCallResponse

Properties

callId
callId: string;

Uses the callId of the ToolCall that this is responding to

name
name: string;

Name of the function that was called

output
output: string;

If the function does not return anything, use 'success' as the output

success
success: boolean;

Indicates whether the tool call was successful

type
type: "function_call_output";