Using the Siren API methods

The Siren AI plugin provides the ability to interact with the configured LLM from a scripted context, including scripted panels, template scripts, or even from your browser console. This section shows you how to use the available API methods. For a complete reference, see Siren API reference.

Sending messages

You can send a single message or perform a conversation programmatically using the following method:

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

Here is what the response looks like:

{
  contextId: '6ab4feda-1b69-4ee1-bbed',
  data: {
    content: '2 * 4 equals 8.',
    timestamp: '2025-02-11T11:46:23.963Z'
  }
}

Having a conversation

The contextId returned from sendPrompt() can be used to continue the conversation. This context ID allows the LLM to remember previous messages that were sent. Calling sendPrompt() without a context ID will always start a new conversation.

await sirenapi.extensions.GenerativeAi.sendPrompt('Now multiply that by 10', { contextId: '6ab4feda-1b69-4ee1-bbed' })
{
  contextId: '6ab4feda-1b69-4ee1-bbed',
  data: {
    content: '8 * 10 equals 80.',
    timestamp: '2025-02-11T11:50:57.461Z'
  }
}

Generating reports

You can generate reports based on graphs using the generateGraphReport() method. This requires you pass in a graph model object, which can be fetched from an existing graph.

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

The response is a Markdown-formatted string:

{
  content: '### Title and Introduction\n\n**Title:** Analyzing Investment and Networking Landscape in Mountain View\n\n**Introduction:** This r...'
}

You can direct the LLM to focus on specific nodes in the graph by passing the list of node IDs like this:

await sirenapi.extensions.GenerativeAi.generateGraphReport(graphModel, { focusNodes: ['investor/_doc/1', 'investor/_doc/2'] })

Downloading reports

The returned Markdown report can be downloaded as a .docx file using other Siren API methods:

const report = await sirenapi.extensions.GenerativeAi.generateGraphReport(graphModel)
const docxBlob = await sirenapi.Reporting.markdownToDocxBlob(report.content)
await sirenapi.Reporting.downloadBlob(docxBlob, 'my-report.docx')