From 7565b876e302c7d6527d1c691ddcb4db6139addd Mon Sep 17 00:00:00 2001 From: 0xSage Date: Tue, 21 Nov 2023 20:34:33 +0800 Subject: [PATCH 1/8] docs: threads --- docs/docs/specs/models.md | 6 +- docs/docs/specs/threads.md | 198 ++++++++++++++++++++++--------------- docs/sidebars.js | 4 +- 3 files changed, 121 insertions(+), 87 deletions(-) diff --git a/docs/docs/specs/models.md b/docs/docs/specs/models.md index 851626431..fa33a3755 100644 --- a/docs/docs/specs/models.md +++ b/docs/docs/specs/models.md @@ -4,7 +4,7 @@ title: Models :::caution -Draft Specification: functionality has not been implemented yet. +This is currently under development. ::: @@ -46,7 +46,7 @@ jan/ # Jan root folder - `model.json` contains metadata and default parameters used to run a model. - The only required field is `source_url`. -### GGUF Example +### Example Here's a standard example `model.json` for a GGUF model. @@ -95,7 +95,7 @@ See [Jan Models API](https://jan.ai/api-reference#tag/Models) :::caution -This is current under development. +This is currently under development. ::: diff --git a/docs/docs/specs/threads.md b/docs/docs/specs/threads.md index d5bc15c8f..c424e0a63 100644 --- a/docs/docs/specs/threads.md +++ b/docs/docs/specs/threads.md @@ -2,89 +2,101 @@ title: Threads --- -:::warning +:::caution -Draft Specification: functionality has not been implemented yet. - -Feedback: [HackMD: Threads Spec](https://hackmd.io/BM_8o_OCQ-iLCYhunn2Aug) +This is currently under development. ::: -## User Stories +## Overview -_Users can chat with an assistant in a thread_ +`Threads` are conversations between an `assistant` and the user: -- See [Messages Spec](./messages.md) +- Users can tweak `model` params and `assistant` behavior within each thread. +- Users can import and export threads. -_Users can change assistant and model parameters in a thread_ +## Folder Structure -- Wireframes of +- Threads are saved in the `/threads` folder. +- Threads are organized by folders, one for each thread, and can be easily zipped, exported, and cleared. +- Thread folders follow the naming: `assistant_id` + `thread_created_at`. -_Users can delete all thread history_ +```sh +jan/ + threads/ + assistant_name_unix_timestamp/ + thread.json + jan_2341243134/ + thread.json +``` -- Wireframes of settings page. +## `thread.json` -## Jan Thread Object +- Each `thread` folder contains a `thread.json` file, which is a representation of a thread. +- `thread.json` contains metadata, model parameter overrides, and [message](https://jan.ai/specs/messages) history. +- There are no required fields. -- A `Jan Thread Object` is a "representation of a conversation thread" between an `assistant` and the user -- Objects are defined by `thread-uuid.json` files in `json` format -- Objects are designed to be compatible with `OpenAI Thread Objects` with additional properties needed to run on our infrastructure. -- Objects contain a `models` field, to track when the user overrides the assistant's default model parameters. +### Example -| Property | Type | Description | Validation | -| ---------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | -| `object` | enum: `model`, `assistant`, `thread`, `message` | The Jan Object type | Defaults to `thread` | -| `assistants` | array | An array of Jan Assistant Objects. Threads can "override" an assistant's parameters. Thread-level model parameters are directly saved in the `thread.models` property! (see Models spec) | Defaults to `assistant.name` | -| `messages` | array | An array of Jan Message Objects. (see Messages spec) | Defaults to `[]` | -| `metadata` | map | Useful for storing additional information about the object in a structured format. | Defaults to `{}` | - -### Generic Example +Here's a standard example `thread.json` for a conversation between the user and the default Jan assistant. ```json -// janroot/threads/jan_1700123404.json -"assistants": ["assistant-123"], +"type": "thread", // Defaults to "thread" +"summary": "funny physics joke", // Defaults to "" +"assistants": ["jan"], // Defaults to "jan" +"created": 1231231 // Defaults to file creation time +"metadata": {}, // Defaults to {} "messages": [ - {...message0}, {...message1} + {...message_0}, {...message_1} ], -"metadata": { - "summary": "funny physics joke", +"model_id": "...", // Do we need this property? +// Overrides assistant.settings && model.settings +"settings": { + ... +}, +// Overrides assistant.settings && model.settings +"parameters": { + ... }, ``` -## Filesystem +## API Reference -- `Jan Thread Objects`'s `json` files always has the naming schema: `assistant_uuid` + `unix_time_thread_created_at. See below. -- Threads are all saved in the `janroot/threads` folder in a flat folder structure. -- The folder is standalone and can be easily zipped, exported, and cleared. +Jan's Threads API is compatible with [OpenAI's Threads API](https://platform.openai.com/docs/api-reference/threads), with additional methods for managing threads locally. -```sh -janroot/ - threads/ - jan_1700123404.json - homework_helper_700120003.json -``` +See [Jan Threads API](https://jan.ai/api-reference#tag/Threads) + + -## Jan API ### Get thread + > OpenAI Equivalent: https://platform.openai.com/docs/api-reference/threads/getThread + - Example request + ```shell curl {JAN_URL}/v1/threads/{thread_id} ``` + - Example response + ```json - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "assistants": ["assistant-001"], - "metadata": {}, - "messages": [] - } +{ + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "assistants": ["assistant-001"], + "metadata": {}, + "messages": [] +} ``` + ### Create Thread + > OpenAI Equivalent: https://platform.openai.com/docs/api-reference/threads/createThread + - Example request + ```shell curl -X POST {JAN_URL}/v1/threads \ -H "Content-Type: application/json" \ @@ -99,18 +111,24 @@ janroot/ }] }' ``` + - Example response + ```json - { - "id": 'thread_abc123', - "object": 'thread', - "created_at": 1699014083, - "metadata": {} - } +{ + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {} +} ``` + ### Modify Thread + > OpenAI Equivalent: https://platform.openai.com/docs/api-reference/threads/modifyThread + - Example request + ```shell curl -X POST {JAN_URL}/v1/threads/{thread_id} \ -H "Content-Type: application/json" \ @@ -125,69 +143,85 @@ janroot/ }] }' ``` + - Example response + ```json - { - "id": 'thread_abc123', - "object": 'thread', - "created_at": 1699014083, - "metadata": {} - } +{ + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {} +} ``` - https://platform.openai.com/docs/api-reference/threads/modifyThread ### Delete Thread + > OpenAI Equivalent: https://platform.openai.com/docs/api-reference/threads/deleteThread + - Example request + ```shell curl -X DELETE {JAN_URL}/v1/threads/{thread_id} ``` + - Example response + ```json - { - "id": "thread_abc123", - "object": "thread.deleted", - "deleted": true - } +{ + "id": "thread_abc123", + "object": "thread.deleted", + "deleted": true +} ``` ### List Threads + > This is a Jan-only endpoint, not supported by OAI yet. + - Example request + ```shell curl {JAN_URL}/v1/threads \ -H "Content-Type: application/json" \ ``` + - Example response + ```json - [ - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "assistants": ["assistant-001"], - "metadata": {}, - "messages": [] - }, - { - "id": "thread_abc456", - "object": "thread", - "created_at": 1699014083, - "assistants": ["assistant-002", "assistant-002"], - "metadata": {}, - } - ] +[ + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "assistants": ["assistant-001"], + "metadata": {}, + "messages": [] + }, + { + "id": "thread_abc456", + "object": "thread", + "created_at": 1699014083, + "assistants": ["assistant-002", "assistant-002"], + "metadata": {} + } +] ``` ### Get & Modify `Thread.Assistants` + -> Can achieve this goal by calling `Modify Thread` API #### `GET v1/threads/{thread_id}/assistants` + -> Can achieve this goal by calling `Get Thread` API #### `POST v1/threads/{thread_id}/assistants/{assistant_id}` + -> Can achieve this goal by calling `Modify Assistant` API with `thread.assistant[]` ### List `Thread.Messages` + -> Can achieve this goal by calling `Get Thread` API diff --git a/docs/sidebars.js b/docs/sidebars.js index aa05c4117..711c00a7a 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -61,8 +61,8 @@ const sidebars = { items: [ "specs/chats", "specs/models", - // "specs/threads", - // "specs/messages", + "specs/threads", + "specs/messages", // "specs/assistants", // "specs/files", // "specs/jan", From cab49b700d8b44150210d4fc180cbb2b4076f788 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Tue, 21 Nov 2023 21:05:39 +0800 Subject: [PATCH 2/8] docs: roughing in a messages spec --- docs/docs/specs/messages.md | 208 +++++++++++++++++++++--------------- docs/docs/specs/models.md | 6 +- docs/docs/specs/threads.md | 21 ++-- 3 files changed, 132 insertions(+), 103 deletions(-) diff --git a/docs/docs/specs/messages.md b/docs/docs/specs/messages.md index 66e4eeaa2..7133d23d3 100644 --- a/docs/docs/specs/messages.md +++ b/docs/docs/specs/messages.md @@ -2,57 +2,70 @@ title: Messages --- -:::warning +:::caution -Draft Specification: functionality has not been implemented yet. - -Feedback: [HackMD: Threads Spec](https://hackmd.io/BM_8o_OCQ-iLCYhunn2Aug) +This is currently under development. ::: -Messages are within `threads` and capture additional metadata. -> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/messages +## Overview + +`Messages` are in `threads` and capture additional metadata: + +- Users can ... + +## Folder Structure + +- `Message` objects are in `thread.json` files under `messages` property. See [threads](./threads.md) + +## `message` object + +### Example + +Here's a standard example `message` json. -## Message Object -> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/messages/object ```json -{ - // Jan specific properties - "updatedAt": "...", // that's it I think - - // OpenAI compatible properties: https://platform.openai.com/docs/api-reference/messages) - "id": "msg_dKYDWyQvtjDBi3tudL1yWKDa", - "object": "thread.message", - "created_at": 1698983503, - "thread_id": "thread_RGUhOuO9b2nrktrmsQ2uSR6I", - "role": "assistant", - "content": [ - { - "type": "text", - "text": { - "value": "Hi! How can I help you today?", - "annotations": [] - } +"id": "0", // Sequential or UUID? +"object": "thread.message", // Defaults to "thread.message" +"created_at": 1698983503, +"thread_id": "thread_asdf", // Defaults to parent thread +"role": "assistant", // Defaults to "user" or "assistant" +"content": [ + { + "type": "text", + "text": { + "value": "Hi! How can I help you today?", + "annotations": [] } - ], - "file_ids": [], - "assistant_id": "asst_ToSF7Gb04YMj8AMMm50ZLLtY", - "run_id": "run_BjylUJgDqYK9bOhy4yjAiMrn", - "metadata": {} -} + } +], +"assistant_id": "...", +"run_id": "...", // The `run` resulting in this message +"metadata": {}, // Defaults to {} +// "file_ids": [], ``` -## Messages API -> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/messages +## API Reference + +Jan's Threads API is compatible with [OpenAI's Messages API](https://platform.openai.com/docs/api-reference/messages), with additional methods for managing messages locally. + +See [Jan Messages API](https://jan.ai/api-reference#tag/Messages) + + ### Get list message + > OpenAI Equivalent: https://platform.openai.com/docs/api-reference/messages/getMessage + - Example request + ```shell curl {JAN_URL}/v1/threads/{thread_id}/messages/{message_id} \ -H "Content-Type: application/json" ``` + - Example response + ```json { "id": "msg_abc123", @@ -75,9 +88,13 @@ Messages are within `threads` and capture additional metadata. "metadata": {} } ``` + ### Create message + > OpenAI Equivalent: https://platform.openai.com/docs/api-reference/messages/createMessage + - Example request + ```shell curl -X POST {JAN_URL}/v1/threads/{thread_id}/messages \ -H "Content-Type: application/json" \ @@ -86,93 +103,112 @@ Messages are within `threads` and capture additional metadata. "content": "How does AI work? Explain it in simple terms." }' ``` + - Example response + ```json - { - "id": "msg_abc123", - "object": "thread.message", - "created_at": 1699017614, - "thread_id": "thread_abc123", - "role": "user", - "content": [ - { - "type": "text", - "text": { - "value": "How does AI work? Explain it in simple terms.", - "annotations": [] - } +{ + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "thread_id": "thread_abc123", + "role": "user", + "content": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] } - ], - "file_ids": [], - "assistant_id": null, - "run_id": null, - "metadata": {} - } + } + ], + "file_ids": [], + "assistant_id": null, + "run_id": null, + "metadata": {} +} ``` + ### Get message + > OpenAI Equivalent: https://platform.openai.com/docs/api-reference/assistants/listAssistants + - Example request + ```shell curl {JAN_URL}/v1/threads/{thread_id}/messages/{message_id} \ -H "Content-Type: application/json" ``` + - Example response + ```json - { - "id": "msg_abc123", - "object": "thread.message", - "created_at": 1699017614, - "thread_id": "thread_abc123", - "role": "user", - "content": [ - { - "type": "text", - "text": { - "value": "How does AI work? Explain it in simple terms.", - "annotations": [] - } +{ + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "thread_id": "thread_abc123", + "role": "user", + "content": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] } - ], - "file_ids": [], - "assistant_id": null, - "run_id": null, - "metadata": {} - } + } + ], + "file_ids": [], + "assistant_id": null, + "run_id": null, + "metadata": {} +} ``` ### Modify message + > Jan: TODO: Do we need to modify message? Or let user create new message? # Get message file + > OpenAI Equivalent: https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files/{file_id} + - Example request + ```shell curl {JAN_URL}/v1/threads/{thread_id}/messages/{message_id}/files/{file_id} \ -H "Content-Type: application/json" ``` + - Example response + ```json - { - "id": "file-abc123", - "object": "thread.message.file", - "created_at": 1699061776, - "message_id": "msg_abc123" - } +{ + "id": "file-abc123", + "object": "thread.message.file", + "created_at": 1699061776, + "message_id": "msg_abc123" +} ``` + # List message files + > OpenAI Equivalent: https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files -``` + +```` - Example request ```shell curl {JAN_URL}/v1/threads/{thread_id}/messages/{message_id}/files/{file_id} \ -H "Content-Type: application/json" -``` +```` + - Example response + ```json - { - "id": "file-abc123", - "object": "thread.message.file", - "created_at": 1699061776, - "message_id": "msg_abc123" - } -``` \ No newline at end of file +{ + "id": "file-abc123", + "object": "thread.message.file", + "created_at": 1699061776, + "message_id": "msg_abc123" +} +``` diff --git a/docs/docs/specs/models.md b/docs/docs/specs/models.md index fa33a3755..471904bc5 100644 --- a/docs/docs/specs/models.md +++ b/docs/docs/specs/models.md @@ -53,12 +53,12 @@ Here's a standard example `model.json` for a GGUF model. - `source_url`: https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/. ```json -"source_url": "https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/blob/main/zephyr-7b-beta.Q4_K_M.gguf", -"type": "model", // Defaults to "model" -"version": "1", // Defaults to 1 "id": "zephyr-7b" // Defaults to foldername +"object": "model", // Defaults to "model" +"source_url": "https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/blob/main/zephyr-7b-beta.Q4_K_M.gguf", "name": "Zephyr 7B" // Defaults to foldername "owned_by": "you" // Defaults to you +"version": "1", // Defaults to 1 "created": 1231231 // Defaults to file creation time "description": "" "state": enum[null, "downloading", "ready", "starting", "stopping", ...] diff --git a/docs/docs/specs/threads.md b/docs/docs/specs/threads.md index c424e0a63..98e3af5b1 100644 --- a/docs/docs/specs/threads.md +++ b/docs/docs/specs/threads.md @@ -41,23 +41,16 @@ jan/ Here's a standard example `thread.json` for a conversation between the user and the default Jan assistant. ```json -"type": "thread", // Defaults to "thread" +"id": "thread_....", // Defaults to foldername +"object": "thread", // Defaults to "thread" "summary": "funny physics joke", // Defaults to "" "assistants": ["jan"], // Defaults to "jan" "created": 1231231 // Defaults to file creation time "metadata": {}, // Defaults to {} -"messages": [ - {...message_0}, {...message_1} -], -"model_id": "...", // Do we need this property? -// Overrides assistant.settings && model.settings -"settings": { - ... -}, -// Overrides assistant.settings && model.settings -"parameters": { - ... -}, +"messages": [], +"model_id": "...", // Defaults to assistant.model ??? +"settings": {}, // Defaults to and overrides assistant.settings +"parameters": {}, // Defaults to and overrides assistant.settings ``` ## API Reference @@ -66,7 +59,7 @@ Jan's Threads API is compatible with [OpenAI's Threads API](https://platform.ope See [Jan Threads API](https://jan.ai/api-reference#tag/Threads) - + ### Get thread From 1a8977b4c761c7da60ef2350ad2a4ac4480d3ec8 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Tue, 21 Nov 2023 21:07:34 +0800 Subject: [PATCH 3/8] docs: nits --- docs/docs/specs/messages.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/docs/specs/messages.md b/docs/docs/specs/messages.md index 7133d23d3..c04179263 100644 --- a/docs/docs/specs/messages.md +++ b/docs/docs/specs/messages.md @@ -10,13 +10,11 @@ This is currently under development. ## Overview -`Messages` are in `threads` and capture additional metadata: - -- Users can ... +`Messages` are in `threads` and capture additional metadata. ## Folder Structure -- `Message` objects are in `thread.json` files under `messages` property. See [threads](./threads.md) +- `Message` objects are stored in `thread.json` files under the `messages` property. See [threads](./threads.md). ## `message` object From a43ce60dadc5b93aa08d8a9ee3704e124cda1512 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Tue, 21 Nov 2023 21:09:15 +0800 Subject: [PATCH 4/8] docs: nits --- docs/docs/specs/messages.md | 3 +++ docs/docs/specs/threads.md | 1 + 2 files changed, 4 insertions(+) diff --git a/docs/docs/specs/messages.md b/docs/docs/specs/messages.md index c04179263..2fafc15ca 100644 --- a/docs/docs/specs/messages.md +++ b/docs/docs/specs/messages.md @@ -12,6 +12,9 @@ This is currently under development. `Messages` are in `threads` and capture additional metadata. +- Users and assistants can send multimedia messages. +- An [OpenAI Message API](https://platform.openai.com/docs/api-reference/messages) compatible endpoint at `localhost:3000/v1/messages`. + ## Folder Structure - `Message` objects are stored in `thread.json` files under the `messages` property. See [threads](./threads.md). diff --git a/docs/docs/specs/threads.md b/docs/docs/specs/threads.md index 98e3af5b1..eaec86ee8 100644 --- a/docs/docs/specs/threads.md +++ b/docs/docs/specs/threads.md @@ -14,6 +14,7 @@ This is currently under development. - Users can tweak `model` params and `assistant` behavior within each thread. - Users can import and export threads. +- An [OpenAI Thread API](https://platform.openai.com/docs/api-reference/threads) compatible endpoint at `localhost:3000/v1/threads`. ## Folder Structure From b1fade0fe788725d1589d8191e5980bc3c2f6729 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Tue, 21 Nov 2023 21:13:17 +0800 Subject: [PATCH 5/8] docs: patch --- docs/docs/specs/messages.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/docs/specs/messages.md b/docs/docs/specs/messages.md index 2fafc15ca..d233916af 100644 --- a/docs/docs/specs/messages.md +++ b/docs/docs/specs/messages.md @@ -30,7 +30,8 @@ Here's a standard example `message` json. "object": "thread.message", // Defaults to "thread.message" "created_at": 1698983503, "thread_id": "thread_asdf", // Defaults to parent thread -"role": "assistant", // Defaults to "user" or "assistant" +"assistant_id": "jan", // Defaults to parent thread +"role": "assistant", // From either "user" or "assistant" "content": [ { "type": "text", @@ -40,9 +41,9 @@ Here's a standard example `message` json. } } ], -"assistant_id": "...", -"run_id": "...", // The `run` resulting in this message "metadata": {}, // Defaults to {} +"chat_completion_id": "", // For now, we use `chat` completion id +// "run_id": "...", // Rather than `run` id // "file_ids": [], ``` From 70a8ea26d2eb97d9e3c8c7195b6d8847810cc1b1 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Wed, 22 Nov 2023 18:36:03 +0800 Subject: [PATCH 6/8] docs: update threads and messages --- docs/docs/specs/messages.md | 61 +++++++++++++++++++++++++++++++------ docs/docs/specs/threads.md | 22 ++++++++----- 2 files changed, 65 insertions(+), 18 deletions(-) diff --git a/docs/docs/specs/messages.md b/docs/docs/specs/messages.md index d233916af..83a8fa063 100644 --- a/docs/docs/specs/messages.md +++ b/docs/docs/specs/messages.md @@ -10,23 +10,65 @@ This is currently under development. ## Overview -`Messages` are in `threads` and capture additional metadata. +`Messages` capture a conversation's content. This can include the content from LLM responses and other metadata from [chat completions](/specs/chats). - Users and assistants can send multimedia messages. - An [OpenAI Message API](https://platform.openai.com/docs/api-reference/messages) compatible endpoint at `localhost:3000/v1/messages`. ## Folder Structure -- `Message` objects are stored in `thread.json` files under the `messages` property. See [threads](./threads.md). +Messages are saved in the `/threads/{thread_id}` folder in `messages.jsonl` files -## `message` object +```sh +jan/ + threads/ + assistant_name_unix_timestamp/ + ... + messages.jsonl + jan_2341243134/ + ... + messages.jsonl +``` -### Example +## `message.jsonl` -Here's a standard example `message` json. +Individual messages are saved in `jsonl` format for indexing purposes. ```json -"id": "0", // Sequential or UUID? +{...message_2} +{...message_1} +{...message_0} +``` + +### Examples + +Here's a standard example `message` sent from a user. + +```json +"id": "0", // Sequential or UUID +"object": "thread.message", // Defaults to "thread.message" +"created_at": 1698983503, +"thread_id": "thread_asdf", // Defaults to parent thread +"assistant_id": "jan", // Defaults to parent thread +"role": "user", // From either "user" or "assistant" +"content": [ + { + "type": "text", + "text": { + "value": "Hi!?", + "annotations": [] + } + } +], +"metadata": {}, // Defaults to {} +// "run_id": "...", // Rather than `run` id abstraction +// "file_ids": [], +``` + +Here's an example `message` response from an assistant. + +```json +"id": "0", // Sequential or UUID "object": "thread.message", // Defaults to "thread.message" "created_at": 1698983503, "thread_id": "thread_asdf", // Defaults to parent thread @@ -42,14 +84,13 @@ Here's a standard example `message` json. } ], "metadata": {}, // Defaults to {} -"chat_completion_id": "", // For now, we use `chat` completion id -// "run_id": "...", // Rather than `run` id -// "file_ids": [], +// "run_id": "...", // KIV +// "file_ids": [], // KIV ``` ## API Reference -Jan's Threads API is compatible with [OpenAI's Messages API](https://platform.openai.com/docs/api-reference/messages), with additional methods for managing messages locally. +Jan's `messages` API is compatible with [OpenAI's Messages API](https://platform.openai.com/docs/api-reference/messages), with additional methods for managing messages locally. See [Jan Messages API](https://jan.ai/api-reference#tag/Messages) diff --git a/docs/docs/specs/threads.md b/docs/docs/specs/threads.md index eaec86ee8..3290b1574 100644 --- a/docs/docs/specs/threads.md +++ b/docs/docs/specs/threads.md @@ -21,12 +21,14 @@ This is currently under development. - Threads are saved in the `/threads` folder. - Threads are organized by folders, one for each thread, and can be easily zipped, exported, and cleared. - Thread folders follow the naming: `assistant_id` + `thread_created_at`. +- Thread folders also contain `messages.jsonl` files. See [messages](/specs/messages). ```sh jan/ threads/ assistant_name_unix_timestamp/ thread.json + messages.jsonl jan_2341243134/ thread.json ``` @@ -34,7 +36,7 @@ jan/ ## `thread.json` - Each `thread` folder contains a `thread.json` file, which is a representation of a thread. -- `thread.json` contains metadata, model parameter overrides, and [message](https://jan.ai/specs/messages) history. +- `thread.json` contains metadata and model parameter overrides. - There are no required fields. ### Example @@ -43,15 +45,19 @@ Here's a standard example `thread.json` for a conversation between the user and ```json "id": "thread_....", // Defaults to foldername -"object": "thread", // Defaults to "thread" -"summary": "funny physics joke", // Defaults to "" -"assistants": ["jan"], // Defaults to "jan" +"object": "thread", // Defaults to "thread" +"title": "funny physics joke", // Defaults to "" +"assistants": [ + { + "assistant_id": "jan", // Defaults to "jan" + "model": { // Defaults to 1 currently active model (can be changed before thread is begun) + "settings": {}, // Defaults to and overrides assistant.json's "settings" (and if none, then model.json "settings") + "parameters": {}, // Defaults to and overrides assistant.json's "parameters" (and if none, then model.json "parameters") + } + }, +], "created": 1231231 // Defaults to file creation time "metadata": {}, // Defaults to {} -"messages": [], -"model_id": "...", // Defaults to assistant.model ??? -"settings": {}, // Defaults to and overrides assistant.settings -"parameters": {}, // Defaults to and overrides assistant.settings ``` ## API Reference From 17f46d640b67ac11bad611f8e8e4a0b314aed2c8 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Wed, 22 Nov 2023 18:38:25 +0800 Subject: [PATCH 7/8] docs: commented out api parts --- docs/docs/specs/messages.md | 4 ++-- docs/docs/specs/threads.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/specs/messages.md b/docs/docs/specs/messages.md index 83a8fa063..011579e22 100644 --- a/docs/docs/specs/messages.md +++ b/docs/docs/specs/messages.md @@ -95,7 +95,7 @@ Jan's `messages` API is compatible with [OpenAI's Messages API](https://platform See [Jan Messages API](https://jan.ai/api-reference#tag/Messages) - + diff --git a/docs/docs/specs/threads.md b/docs/docs/specs/threads.md index 3290b1574..c9d9c9d4c 100644 --- a/docs/docs/specs/threads.md +++ b/docs/docs/specs/threads.md @@ -67,7 +67,7 @@ Jan's Threads API is compatible with [OpenAI's Threads API](https://platform.ope See [Jan Threads API](https://jan.ai/api-reference#tag/Threads) - + Can achieve this goal by calling `Get Thread` API +-> Can achieve this goal by calling `Get Thread` API --> From ac1075fcd7f3343bf915365ab1f60fc677151c84 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Wed, 22 Nov 2023 18:40:24 +0800 Subject: [PATCH 8/8] docs: comments --- docs/docs/specs/messages.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/docs/specs/messages.md b/docs/docs/specs/messages.md index 011579e22..dbee33fe4 100644 --- a/docs/docs/specs/messages.md +++ b/docs/docs/specs/messages.md @@ -74,7 +74,7 @@ Here's an example `message` response from an assistant. "thread_id": "thread_asdf", // Defaults to parent thread "assistant_id": "jan", // Defaults to parent thread "role": "assistant", // From either "user" or "assistant" -"content": [ +"content": [ // Usually from Chat Completion obj { "type": "text", "text": { @@ -86,6 +86,7 @@ Here's an example `message` response from an assistant. "metadata": {}, // Defaults to {} // "run_id": "...", // KIV // "file_ids": [], // KIV +// "usage": {} // KIV: saving chat completion properties https://platform.openai.com/docs/api-reference/chat/object ``` ## API Reference