docs: update threads

This commit is contained in:
hieu-jan 2023-11-23 10:12:38 +09:00
parent 00b583659a
commit 7a9cd83e80
2 changed files with 67 additions and 60 deletions

View File

@ -182,8 +182,8 @@ paths:
operationId: createThread operationId: createThread
tags: tags:
- Threads - Threads
summary: Create a new thread summary: Create thread
description: Creates a new thread with an initial set of messages. description: Create a thread
requestBody: requestBody:
required: true required: true
content: content:
@ -196,8 +196,6 @@ paths:
description: "Initial set of messages for the thread." description: "Initial set of messages for the thread."
items: items:
$ref: 'specs/threads.yaml#/components/schemas/ThreadMessageObject' $ref: 'specs/threads.yaml#/components/schemas/ThreadMessageObject'
required:
- messages
responses: responses:
"200": "200":
description: Thread created successfully description: Thread created successfully
@ -206,16 +204,25 @@ paths:
schema: schema:
$ref: 'specs/threads.yaml#/components/schemas/CreateThreadResponse' $ref: 'specs/threads.yaml#/components/schemas/CreateThreadResponse'
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "cURL"
source: | source: |
curl -X POST {JAN_URL}/v1/threads \ curl -X POST {JAN_URL}/v1/threads \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Hello, what is AI?", "file_ids": ["file-abc123"]}, {"role": "user", "content": "How does AI work? Explain it in simple terms."}]}' -d '{
"messages": [{
"role": "user",
"content": "Hello, what is AI?",
"file_ids": ["file-abc123"]
}, {
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}]
}'
get: get:
operationId: listThreads operationId: listThreads
tags: tags:
- Threads - Threads
summary: List all threads summary: List threads
description: Retrieves a list of all threads available in the system. description: Retrieves a list of all threads available in the system.
responses: responses:
"200": "200":
@ -241,15 +248,15 @@ paths:
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "curl"
source: | source: |
curl {JAN_URL}/v1/threads \ curl {JAN_URL}/v1/threads \
-H "Content-Type: application/json" -H "Content-Type: application/json" \
/threads/{thread_id}: /threads/{thread_id}:
get: get:
operationId: getThread operationId: getThread
tags: tags:
- Threads - Threads
summary: Get details of a specific thread summary: Get thread
description: Retrieves detailed information about a specific thread using its thread_id. description: Retrieves detailed information about a specific thread using its thread_id.
parameters: parameters:
- in: path - in: path
@ -274,8 +281,8 @@ paths:
operationId: modifyThread operationId: modifyThread
tags: tags:
- Threads - Threads
summary: Modify an existing thread summary: Modify thread
description: Updates a thread with new or modified messages. description: Modifies a thread
parameters: parameters:
- in: path - in: path
name: thread_id name: thread_id
@ -308,15 +315,24 @@ paths:
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "curl"
source: | source: |
curl -X POST {JAN_URL}/v1/threads/{thread_id} \ curl -X POST {JAN_URL}/v1/threads/{thread_id} \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Hello, what is AI?", "file_ids": ["file-abc123"]}, {"role": "user", "content": "How does AI work? Explain it in simple terms."}]}' -d '{
"messages": [{
"role": "user",
"content": "Hello, what is AI?",
"file_ids": ["file-abc123"]
}, {
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}]
}'
delete: delete:
operationId: deleteThread operationId: deleteThread
tags: tags:
- Threads - Threads
summary: Delete a specific thread summary: Delete thread
description: Deletes a thread identified by its thread_id. description: Delete a thread
parameters: parameters:
- in: path - in: path
name: thread_id name: thread_id
@ -336,6 +352,7 @@ paths:
- lang: "curl" - lang: "curl"
source: | source: |
curl -X DELETE {JAN_URL}/v1/threads/{thread_id} curl -X DELETE {JAN_URL}/v1/threads/{thread_id}
### MESSAGES ### MESSAGES
/threads/{thread_id}/messages: /threads/{thread_id}/messages:
get: get:
@ -553,7 +570,8 @@ x-webhooks:
ThreadObject: ThreadObject:
post: post:
summary: The thread object summary: The thread object
description: Information about a thread description:
- Each thread folder contains a `thread.json` file, which is a representation of a thread.
operationId: ThreadObject operationId: ThreadObject
tags: tags:
- Threads - Threads

View File

@ -5,12 +5,12 @@ components:
properties: properties:
id: id:
type: string type: string
description: "Identifier of the thread, defaults to folder name." description: "The identifier of the thread, defaults to foldername."
example: "thread_...." example: thread_....
object: object:
type: string type: string
description: "Type of the object, typically 'thread'." description: "Type of the object, defaults to thread."
default: "thread" example: thread
summary: summary:
type: string type: string
description: "A brief summary or description of the thread, defaults to an empty string." description: "A brief summary or description of the thread, defaults to an empty string."
@ -19,91 +19,87 @@ components:
type: array type: array
items: items:
type: string type: string
description: "List of assistants involved in the thread, defaults to ['jan']." description: "List of assistants involved in the thread, defaults to [\"jan\"]."
example: ["jan"] example: ["jan"]
created: created:
type: integer type: integer
format: int64 format: int64
description: "Unix timestamp representing the creation time of the thread, defaults to file creation time." description: "Unix timestamp representing the creation time of the thread, defaults to file creation time."
example: 1231231
metadata: metadata:
type: object type: object
description: "Metadata associated with the thread, defaults to an empty object." description: "Metadata associated with the thread, defaults to an empty object."
example: {}
messages: messages:
type: array type: array
description: "List of messages within the thread." description: "List of messages within the thread."
items: items:
type: string type: string
example: []
model_id: model_id:
type: string type: string
description: "Model identifier associated with the thread, defaults to assistant's model." description: "Model identifier associated with the thread, defaults to assistant.model."
example: "..." example: "..."
settings: settings:
type: object type: object
description: "Settings for the thread, defaults to and overrides assistant's settings." description: "Settings for the thread, defaults to and overrides assistant.settings."
parameters: parameters:
type: object type: object
description: "Parameters for the thread, defaults to and overrides assistant's settings." description: "Parameters for the thread, defaults to and overrides assistant.settings."
required:
- id
- object
GetThreadResponse: GetThreadResponse:
type: object type: object
properties: properties:
id: id:
type: string type: string
description: "The identifier of the thread." description: "The identifier of the thread."
example: "thread_abc123" example: thread_abc123
object: object:
type: string type: string
description: "Type of the object, indicating it's a thread." description: "Type of the object"
default: "thread" example: thread
created_at: created_at:
type: integer type: integer
format: int64 format: int64
description: "Unix timestamp representing the creation time of the thread." description: "Unix timestamp representing the creation time of the thread."
example: 1699014083
assistants: assistants:
type: array type: array
items: items:
type: string type: string
description: "List of assistants involved in the thread." description: "List of assistants involved in the thread."
example: ["assistant-001"]
metadata: metadata:
type: object type: object
description: "Metadata associated with the thread." description: "Metadata associated with the thread."
example: {}
messages: messages:
type: array type: array
items: items:
type: string type: string
description: "List of messages within the thread." description: "List of messages within the thread."
required: example: []
- id
- object
- created_at
- assistants
- metadata
- messages
CreateThreadResponse: CreateThreadResponse:
type: object type: object
properties: properties:
id: id:
type: string type: string
description: "The identifier of the newly created thread." description: "The identifier of the newly created thread."
example: "thread_abc123" example: thread_abc123
object: object:
type: string type: string
description: "Type of the object, indicating it's a thread." description: "Type of the object, indicating it's a thread."
default: "thread" example: thread
created_at: created_at:
type: integer type: integer
format: int64 format: int64
description: "Unix timestamp representing the creation time of the thread." description: "Unix timestamp representing the creation time of the thread."
example: 1699014083
metadata: metadata:
type: object type: object
description: "Metadata associated with the newly created thread." description: "Metadata associated with the newly created thread."
required: example: {}
- id
- object
- created_at
- metadata
ThreadMessageObject: ThreadMessageObject:
type: object type: object
@ -130,23 +126,20 @@ components:
id: id:
type: string type: string
description: "The identifier of the modified thread." description: "The identifier of the modified thread."
example: "thread_abc123" example: thread_abc123
object: object:
type: string type: string
description: "Type of the object, indicating it's a thread." description: "Type of the object, indicating it's a thread."
default: "thread" example: thread
created_at: created_at:
type: integer type: integer
format: int64 format: int64
description: "Unix timestamp representing the creation time of the thread." description: "Unix timestamp representing the creation time of the thread."
example: 1699014083
metadata: metadata:
type: object type: object
description: "Metadata associated with the modified thread." description: "Metadata associated with the modified thread."
required: example: {}
- id
- object
- created_at
- metadata
DeleteThreadResponse: DeleteThreadResponse:
type: object type: object
@ -154,16 +147,12 @@ components:
id: id:
type: string type: string
description: "The identifier of the deleted thread." description: "The identifier of the deleted thread."
example: "thread_abc123" example: thread_abc123
object: object:
type: string type: string
description: "Type of the object, indicating the thread has been deleted." description: "Type of the object, indicating the thread has been deleted."
default: "thread.deleted" example: thread.deleted
deleted: deleted:
type: boolean type: boolean
description: "Indicates whether the thread was successfully deleted." description: "Indicates whether the thread was successfully deleted."
example: true example: true
required:
- id
- object
- deleted