docs: api-reference for models message threads (#679)

API Reference for Models, Messages, Threads
This commit is contained in:
Hieu 2023-11-24 14:48:03 +09:00 committed by GitHub
commit 67c34cfe09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1201 additions and 9490 deletions

View File

@ -13,7 +13,7 @@ This is currently under development.
`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`.
- An [OpenAI Message API](https://platform.openai.com/docs/api-reference/messages) compatible endpoint at `localhost:1337/v1/messages`.
## Folder Structure

View File

@ -103,4 +103,4 @@ You can import a model by dragging the model binary or gguf file into the `/mode
- Jan automatically generates a corresponding `model.json` file based on the binary filename.
- Jan automatically organizes it into its own `/models/model-id` folder.
- Jan automatically populates the `model.json` properties, which you can subsequently modify.
- Jan automatically populates the `model.json` properties, which you can subsequently modify.

View File

@ -14,7 +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`.
- An [OpenAI Thread API](https://platform.openai.com/docs/api-reference/threads) compatible endpoint at `localhost:1337/v1/threads`.
## Folder Structure
@ -224,4 +224,4 @@ See [Jan Threads API](https://jan.ai/api-reference#tag/Threads)
### List `Thread.Messages`
-> Can achieve this goal by calling `Get Thread` API -->
-> Can achieve this goal by calling `Get Thread` API -->

View File

@ -25,7 +25,7 @@ const config = {
onBrokenLinks: "warn",
onBrokenMarkdownLinks: "warn",
trailingSlash: true,
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
@ -112,6 +112,11 @@ const config = {
theme: {
primaryColor: "#1a73e8",
primaryColorDark: "#1a73e8",
options: {
disableSearch: true,
requiredPropsFirst: true,
noAutoAuth: true
},
// redocOptions: { hideDownloadButton: false },
},
},

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,304 @@
components:
schemas:
MessageObject:
type: object
properties:
id:
type: string
description: "Sequential or UUID identifier of the message."
example: 0
object:
type: string
description: "Type of the object, defaults to 'thread.message'."
example: thread.message
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the message."
thread_id:
type: string
description: "Identifier of the thread to which this message belongs. Defaults to parent thread."
example: "thread_asdf"
assistant_id:
type: string
description: "Identifier of the assistant involved in the message. Defaults to parent thread."
example: jan
role:
type: string
enum: ["user", "assistant"]
description: "Role of the sender, either 'user' or 'assistant'."
content:
type: array
items:
type: object
properties:
type:
type: string
description: "Type of content, e.g., 'text'."
text:
type: object
properties:
value:
type: string
description: "Text content of the message."
example: "Hi!?"
annotations:
type: array
items:
type: string
description: "Annotations for the text content, if any."
example: []
metadata:
type: object
description: "Metadata associated with the message, defaults to an empty object."
example: {}
GetMessageResponse:
type: object
properties:
id:
type: string
description: "The identifier of the message."
example: msg_abc123
object:
type: string
description: "Type of the object, indicating it's a thread message."
default: thread.message
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the message."
example: 1699017614
thread_id:
type: string
description: "Identifier of the thread to which this message belongs."
example: thread_abc123
role:
type: string
description: "Role of the sender, either 'user' or 'assistant'."
example: user
content:
type: array
items:
type: object
properties:
type:
type: string
description: "Type of content, e.g., 'text'."
example: text
text:
type: object
properties:
value:
type: string
description: "Text content of the message."
example: "How does AI work? Explain it in simple terms."
annotations:
type: array
items:
type: string
description: "Annotations for the text content, if any."
example: []
file_ids:
type: array
items:
type: string
description: "Array of file IDs associated with the message, if any."
example: []
assistant_id:
type: string
description: "Identifier of the assistant involved in the message, if applicable."
example: null
run_id:
type: string
description: "Run ID associated with the message, if applicable."
example: null
metadata:
type: object
description: "Metadata associated with the message."
example: {}
CreateMessageResponse:
type: object
properties:
id:
type: string
description: "The identifier of the created message."
example: msg_abc123
object:
type: string
description: "Type of the object, indicating it's a thread message."
example: thread.message
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the message."
example: 1699017614
thread_id:
type: string
description: "Identifier of the thread to which this message belongs."
example: thread_abc123
role:
type: string
description: "Role of the sender, either 'user' or 'assistant'."
example: user
content:
type: array
items:
type: object
properties:
type:
type: string
description: "Type of content, e.g., 'text'."
example: text
text:
type: object
properties:
value:
type: string
description: "Text content of the message."
example: "How does AI work? Explain it in simple terms."
annotations:
type: array
items:
type: string
description: "Annotations for the text content, if any."
example: []
file_ids:
type: array
items:
type: string
description: "Array of file IDs associated with the message, if any."
example: []
assistant_id:
type: string
description: "Identifier of the assistant involved in the message, if applicable."
example: null
run_id:
type: string
description: "Run ID associated with the message, if applicable."
example: null
metadata:
type: object
description: "Metadata associated with the message."
example: {}
ListMessagesResponse:
type: object
properties:
object:
type: string
description: "Type of the object, indicating it's a list."
default: "list"
data:
type: array
items:
$ref: '#/components/schemas/ListMessageObject'
first_id:
type: string
description: "Identifier of the first message in the list."
example: "msg_abc123"
last_id:
type: string
description: "Identifier of the last message in the list."
example: "msg_abc456"
has_more:
type: boolean
description: "Indicates whether there are more messages to retrieve."
example: false
ListMessageObject:
type: object
properties:
id:
type: string
description: "The identifier of the message."
example: msg_abc123
object:
type: string
description: "Type of the object, indicating it's a thread message."
example: thread.message
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the message."
example: 1699017614
thread_id:
type: string
description: "Identifier of the thread to which this message belongs."
example: thread_abc123
role:
type: string
description: "Role of the sender, either 'user' or 'assistant'."
example: user
content:
type: array
items:
type: object
properties:
type:
type: string
description: "Type of content, e.g., 'text'."
text:
type: object
properties:
value:
type: string
description: "Text content of the message."
example: "How does AI work? Explain it in simple terms."
annotations:
type: array
items:
type: string
description: "Annotations for the text content, if any."
file_ids:
type: array
items:
type: string
description: "Array of file IDs associated with the message, if any."
example: []
assistant_id:
type: string
description: "Identifier of the assistant involved in the message, if applicable."
example: null
run_id:
type: string
description: "Run ID associated with the message, if applicable."
example: null
metadata:
type: object
description: "Metadata associated with the message."
example: {}
MessageFileObject:
type: object
properties:
id:
type: string
description: "The identifier of the file."
example: file-abc123
object:
type: string
description: "Type of the object, indicating it's a thread message file."
example: thread.message.file
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the file."
example: 1699061776
message_id:
type: string
description: "Identifier of the message to which this file is associated."
example: msg_abc123
ListMessageFilesResponse:
type: object
properties:
object:
type: string
description: "Type of the object, indicating it's a list."
default: "list"
data:
type: array
items:
$ref: '#/components/schemas/MessageFileObject'

View File

@ -0,0 +1,320 @@
components:
schemas:
ListModelsResponse:
type: object
properties:
object:
type: string
enum: [list]
data:
type: array
items:
$ref: "#/components/schemas/Model"
required:
- object
- data
Model:
type: object
properties:
type:
type: string
default: "model"
description: "The type of the object."
version:
type: string
default: "1"
description: "The version number of the model."
id:
type: string
description: "Unique identifier used in chat-completions model_name, matches folder name."
example: "zephyr-7b"
name:
type: string
description: "Name of the model."
example: "Zephyr 7B"
owned_by:
type: string
description: "Compatibility field for OpenAI."
default: ""
created:
type: integer
format: int64
description: "Unix timestamp representing the creation time."
description:
type: string
description: "Description of the model."
state:
type: string
enum: [null, "downloading", "ready", "starting", "stopping"]
description: "Current state of the model."
format:
type: string
description: "State format of the model, distinct from the engine."
example: "ggufv3"
source_url:
type: string
format: uri
description: "URL to the source of the model."
example: "https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/blob/main/zephyr-7b-beta.Q4_K_M.gguf"
settings:
type: object
properties:
ctx_len:
type: string
description: "Context length."
example: "2048"
ngl:
type: string
description: "Number of layers."
example: "100"
embedding:
type: string
description: "Indicates if embedding is enabled."
example: "true"
n_parallel:
type: string
description: "Number of parallel processes."
example: "4"
additionalProperties: false
parameters:
type: object
properties:
temperature:
type: string
description: "Temperature setting for the model."
example: "0.7"
token_limit:
type: string
description: "Token limit for the model."
example: "2048"
top_k:
type: string
description: "Top-k setting for the model."
example: "0"
top_p:
type: string
description: "Top-p setting for the model."
example: "1"
stream:
type: string
description: "Indicates if streaming is enabled."
example: "true"
additionalProperties: false
metadata:
type: object
description: "Additional metadata."
assets:
type: array
items:
type: string
description: "List of assets related to the model."
required:
- source_url
ModelObject:
type: object
properties:
id:
type: string
description: "The identifier of the model."
example: "zephyr-7b"
object:
type: string
description: "The type of the object, indicating it's a model."
default: "model"
created:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the model."
example: "1253935178"
owned_by:
type: string
description: "The entity that owns the model."
example: "_"
required:
- id
- object
- created
- owned_by
GetModelResponse:
type: object
properties:
id:
type: string
description: "The identifier of the model."
example: "zephyr-7b"
object:
type: string
description: "Type of the object, indicating it's a model."
default: "model"
created:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the model."
owned_by:
type: string
description: "The entity that owns the model."
example: "_"
state:
type: string
enum: [not_downloaded, downloaded, running, stopped]
description: "The current state of the model."
source_url:
type: string
format: uri
description: "URL to the source of the model."
example: "https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/blob/main/zephyr-7b-beta.Q4_K_M.gguf"
parameters:
type: object
properties:
ctx_len:
type: integer
description: "Context length."
example: 2048
ngl:
type: integer
description: "Number of layers."
example: 100
embedding:
type: boolean
description: "Indicates if embedding is enabled."
example: true
n_parallel:
type: integer
description: "Number of parallel processes."
example: 4
# pre_prompt:
# type: string
# description: "Predefined prompt for initiating the chat."
# example: "A chat between a curious user and an artificial intelligence"
# user_prompt:
# type: string
# description: "Format of user's prompt."
# example: "USER: "
# ai_prompt:
# type: string
# description: "Format of AI's response."
# example: "ASSISTANT: "
temperature:
type: string
description: "Temperature setting for the model."
example: "0.7"
token_limit:
type: string
description: "Token limit for the model."
example: "2048"
top_k:
type: string
description: "Top-k setting for the model."
example: "0"
top_p:
type: string
description: "Top-p setting for the model."
example: "1"
metadata:
type: object
properties:
engine:
type: string
description: "The engine used by the model."
example: "llamacpp"
quantization:
type: string
description: "Quantization parameter of the model."
example: "Q3_K_L"
size:
type: string
description: "Size of the model."
example: "7B"
required:
- id
- object
- created
- owned_by
- state
- source_url
- parameters
- metadata
DeleteModelResponse:
type: object
properties:
id:
type: string
description: "The identifier of the model that was deleted."
example: "model-zephyr-7B"
object:
type: string
description: "Type of the object, indicating it's a model."
default: "model"
deleted:
type: boolean
description: "Indicates whether the model was successfully deleted."
example: true
required:
- id
- object
- deleted
StartModelResponse:
type: object
properties:
id:
type: string
description: "The identifier of the model that was started."
example: "model-zephyr-7B"
object:
type: string
description: "Type of the object, indicating it's a model."
default: "model"
state:
type: string
description: "The current state of the model after the start operation."
example: "running"
required:
- id
- object
- state
StopModelResponse:
type: object
properties:
id:
type: string
description: "The identifier of the model that was started."
example: "model-zephyr-7B"
object:
type: string
description: "Type of the object, indicating it's a model."
default: "model"
state:
type: string
description: "The current state of the model after the start operation."
example: "stopped"
required:
- id
- object
- state
DownloadModelResponse:
type: object
properties:
id:
type: string
description: "The identifier of the model that was started."
example: "model-zephyr-7B"
object:
type: string
description: "Type of the object, indicating it's a model."
default: "model"
state:
type: string
description: "The current state of the model after the start operation."
example: "downloaded"
required:
- id
- object
- state

View File

@ -0,0 +1,155 @@
components:
schemas:
ThreadObject:
type: object
properties:
id:
type: string
description: "The identifier of the thread, defaults to foldername."
example: thread_....
object:
type: string
description: "Type of the object, defaults to thread."
example: thread
summary:
type: string
description: "A brief summary or description of the thread, defaults to an empty string."
example: "funny physics joke"
assistants:
type: array
items:
type: string
description: "List of assistants involved in the thread, defaults to [\"jan\"]."
example: ["jan"]
created:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the thread, defaults to file creation time."
example: 1231231
metadata:
type: object
description: "Metadata associated with the thread, defaults to an empty object."
example: {}
messages:
type: array
description: "List of messages within the thread."
items:
type: string
example: []
model_id:
type: string
description: "Model identifier associated with the thread, defaults to assistant.model."
example: "..."
settings:
type: object
description: "Settings for the thread, defaults to and overrides assistant.settings."
parameters:
type: object
description: "Parameters for the thread, defaults to and overrides assistant.settings."
GetThreadResponse:
type: object
properties:
id:
type: string
description: "The identifier of the thread."
example: thread_abc123
object:
type: string
description: "Type of the object"
example: thread
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the thread."
example: 1699014083
assistants:
type: array
items:
type: string
description: "List of assistants involved in the thread."
example: ["assistant-001"]
metadata:
type: object
description: "Metadata associated with the thread."
example: {}
messages:
type: array
items:
type: string
description: "List of messages within the thread."
example: []
CreateThreadResponse:
type: object
properties:
id:
type: string
description: "The identifier of the newly created thread."
example: thread_abc123
object:
type: string
description: "Type of the object, indicating it's a thread."
example: thread
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the thread."
example: 1699014083
metadata:
type: object
description: "Metadata associated with the newly created thread."
example: {}
ThreadMessageObject:
type: object
properties:
role:
type: string
description: "Role of the sender, either 'user' or 'assistant'."
enum: ["user", "assistant"]
content:
type: string
description: "Text content of the message."
file_ids:
type: array
items:
type: string
description: "Array of file IDs associated with the message, if any."
ModifyThreadResponse:
type: object
properties:
id:
type: string
description: "The identifier of the modified thread."
example: thread_abc123
object:
type: string
description: "Type of the object, indicating it's a thread."
example: thread
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the thread."
example: 1699014083
metadata:
type: object
description: "Metadata associated with the modified thread."
example: {}
DeleteThreadResponse:
type: object
properties:
id:
type: string
description: "The identifier of the deleted thread."
example: thread_abc123
object:
type: string
description: "Type of the object, indicating the thread has been deleted."
example: thread.deleted
deleted:
type: boolean
description: "Indicates whether the thread was successfully deleted."
example: true