Introduction
The Server-Sent Events endpoint is the interface through which a client opens a connection to the server's event stream and receives the messages and events the server sends. Those messages carry all sorts of things: what an agent or bot says, system events, end-user messages. Once the endpoint is called, the client holds the connection open and receives events from the server.
Request
There are four kinds of request event:
- Start or reset
- Send a message
- Upload a file
- Attach a file and send a message
The request flow
Response
The event types:
Event Types
| Name | What it is |
|---|---|
| asgard.run.init | The SSE service initialises |
| asgard.message.start | The conversation begins, possibly with some initial text |
| asgard.message.delta | The content updates, character by character, for a typewriter effect |
| asgard.message.complete | The conversation ends, with the full text and the template |
| asgard.run.done | The SSE service has finished |
| asgard.run.error | An error in the SSE service, which appears only when something goes wrong |
| asgard.process.start | A process begins |
| asgard.process.complete | A process finishes |
| asgard.tool_call.start | A tool call begins, which appears only when a toolset is in use |
| asgard.tool_call.complete | A tool call finishes, which appears only when a toolset is in use |
A run initialises before any message is sent. A message then begins, continues and finishes. During the continuing stage there can be many deltas until the message is complete, and idx tells you their order. Only once the message is complete does the run finish.
An ordinary conversation
A conversation that uses a toolset
Fact Fields
The fields inside an event:
| Name | What it is |
|---|---|
| runInit | What init returns |
| runDone | What done returns |
| runError | What error returns |
| messageStart | The start of the message. The message object supports: messageId, replyToCustomMessageId, text, payload, idx, template |
| messageDelta | An increment of the message. The message object supports: messageId, replyToCustomMessageId, text, payload, idx, template (omitted as null) idx identifies the position of this piece of the message; see the delta examples below. |
| messageComplete | The completion of the message. The message object supports: messageId, replyToCustomMessageId, text, payload, idx, template |
| processStart | A process begins |
| processComplete | A process finishes |
| toolCallStart | A tool call begins, which appears only when a toolset is in use |
| toolCallComplete | A tool call finishes, which appears only when a toolset is in use |