adds attachment support
This commit is contained in:
@@ -9,6 +9,7 @@ Transport:
|
||||
- HTTP response uses `Content-Type: text/event-stream; charset=utf-8`
|
||||
- Events are emitted in SSE format (`event: ...`, `data: ...`)
|
||||
- Request body is JSON
|
||||
- Request body supports the same inline attachment schema and limits documented in `docs/api/rest.md`.
|
||||
|
||||
Authentication:
|
||||
- Same as REST endpoints (`Authorization: Bearer <token>` when token mode is enabled)
|
||||
@@ -21,7 +22,30 @@ Authentication:
|
||||
"provider": "openai|anthropic|xai",
|
||||
"model": "string",
|
||||
"messages": [
|
||||
{ "role": "system|user|assistant|tool", "content": "string", "name": "optional" }
|
||||
{
|
||||
"role": "system|user|assistant|tool",
|
||||
"content": "string",
|
||||
"name": "optional",
|
||||
"attachments": [
|
||||
{
|
||||
"kind": "image",
|
||||
"id": "attachment-id",
|
||||
"filename": "photo.jpg",
|
||||
"mimeType": "image/jpeg",
|
||||
"sizeBytes": 12345,
|
||||
"dataUrl": "data:image/jpeg;base64,..."
|
||||
},
|
||||
{
|
||||
"kind": "text",
|
||||
"id": "attachment-id",
|
||||
"filename": "notes.md",
|
||||
"mimeType": "text/markdown",
|
||||
"sizeBytes": 4567,
|
||||
"text": "# Notes\\n...",
|
||||
"truncated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"temperature": 0.2,
|
||||
"maxTokens": 256
|
||||
@@ -32,6 +56,7 @@ Notes:
|
||||
- If `chatId` is omitted, backend creates a new chat.
|
||||
- If `chatId` is provided, backend validates it exists.
|
||||
- Backend stores only new non-assistant input history rows to avoid duplicates.
|
||||
- Attachments are optional and are persisted under `message.metadata.attachments` on stored user messages.
|
||||
|
||||
## Event Stream Contract
|
||||
|
||||
@@ -103,8 +128,9 @@ Event order:
|
||||
## Provider Streaming Behavior
|
||||
|
||||
- `openai`: backend may execute internal tool calls (`web_search`, `fetch_url`) before producing final text.
|
||||
- `openai`: image attachments are sent as chat-completions content parts; text attachments are inlined as text parts.
|
||||
- `xai`: same tool-enabled behavior as OpenAI.
|
||||
- `anthropic`: streamed via event stream; emits `delta` from `content_block_delta` with `text_delta`.
|
||||
- `anthropic`: streamed via event stream; emits `delta` from `content_block_delta` with `text_delta`. Image attachments are sent as base64 `image` blocks and text attachments are appended as `text` blocks.
|
||||
- `web_search` uses `CHAT_WEB_SEARCH_ENGINE` (`exa` default, or `searxng` with `SEARXNG_BASE_URL` set). SearXNG mode requires the instance to allow `format=json`. This only affects chat-mode tool calls, not search-mode endpoints.
|
||||
|
||||
Tool-enabled streaming notes (`openai`/`xai`):
|
||||
|
||||
Reference in New Issue
Block a user