add assistants request and response

This commit is contained in:
hieu-jan 2023-12-08 03:59:02 +09:00
parent f1e37e2f9f
commit ba2341e4c3
6 changed files with 477 additions and 98 deletions

View File

@ -245,14 +245,14 @@ paths:
type: array type: array
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"
responses: responses:
"200": "200":
description: Thread created successfully description: Thread created successfully
content: content:
application/json: application/json:
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: |
@ -283,7 +283,7 @@ paths:
schema: schema:
type: array type: array
items: items:
$ref: 'specs/threads.yaml#/components/schemas/ThreadObject' $ref: "specs/threads.yaml#/components/schemas/ThreadObject"
example: example:
- id: "thread_abc123" - id: "thread_abc123"
object: "thread" object: "thread"
@ -299,8 +299,8 @@ paths:
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "curl"
source: | source: |
curl http://localhost:1337/v1/threads \ curl http://localhost:1337/v1/threads \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
/threads/{thread_id}: /threads/{thread_id}:
get: get:
@ -359,29 +359,29 @@ paths:
type: array type: array
description: "Set of messages to update in the thread." description: "Set of messages to update in the thread."
items: items:
$ref: 'specs/threads.yaml#/components/schemas/ThreadMessageObject' $ref: "specs/threads.yaml#/components/schemas/ThreadMessageObject"
responses: responses:
"200": "200":
description: Thread modified successfully description: Thread modified successfully
content: content:
application/json: application/json:
schema: schema:
$ref: 'specs/threads.yaml#/components/schemas/ModifyThreadResponse' $ref: "specs/threads.yaml#/components/schemas/ModifyThreadResponse"
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "curl"
source: | source: |
curl -X POST http://localhost:1337/v1/threads/{thread_id} \ curl -X POST http://localhost:1337/v1/threads/{thread_id} \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d '{
"messages": [{ "messages": [{
"role": "user", "role": "user",
"content": "Hello, what is AI?", "content": "Hello, what is AI?",
"file_ids": ["file-abc123"] "file_ids": ["file-abc123"]
}, { }, {
"role": "user", "role": "user",
"content": "How does AI work? Explain it in simple terms." "content": "How does AI work? Explain it in simple terms."
}] }]
}' }'
delete: delete:
operationId: deleteThread operationId: deleteThread
tags: tags:
@ -404,7 +404,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: 'specs/threads.yaml#/components/schemas/DeleteThreadResponse' $ref: "specs/threads.yaml#/components/schemas/DeleteThreadResponse"
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "curl"
source: | source: |
@ -486,12 +486,48 @@ paths:
description: | description: |
Return a list of assistants. <a href = "https://platform.openai.com/docs/api-reference/assistants/listAssistants"> Equivalent to OpenAI's list assistants. </a> Return a list of assistants. <a href = "https://platform.openai.com/docs/api-reference/assistants/listAssistants"> Equivalent to OpenAI's list assistants. </a>
responses: responses:
responses:
"200": "200":
description: description: List of threads retrieved successfully
content: content:
application/json: application/json:
schema: schema:
$ref: "specs/assistants.yaml#/components/schemas/ListAssistantsResponse" type: array
example:
- id: "asst_abc123"
object: "assistant"
version: 1
created_at: 1698984975
name: "Math Tutor"
description: null
avatar: "https://pic.png"
models:
- model_id: "model_0"
instructions: "Be concise"
events:
in: []
out: []
metadata: {}
- id: "asst_abc456"
object: "assistant"
version: 1
created_at: 1698984975
name: "Physics Tutor"
description: null
avatar: "https://pic.png"
models:
- model_id: "model_1"
instructions: "Be concise!"
events:
in: []
out: []
metadata: {}
x-codeSamples:
- lang: "curl"
source: |
curl http://localhost:1337/v1/assistants \
-H "Content-Type: application/json" \
post: post:
operationId: createAssistant operationId: createAssistant
tags: tags:
@ -499,6 +535,22 @@ paths:
summary: Create assistant summary: Create assistant
description: | description: |
Create an assistant with a model and instructions. <a href = "https://platform.openai.com/docs/api-reference/assistants/createAssistant"> Equivalent to OpenAI's create assistants. </a> Create an assistant with a model and instructions. <a href = "https://platform.openai.com/docs/api-reference/assistants/createAssistant"> Equivalent to OpenAI's create assistants. </a>
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
models:
type: array
description: "List of models associated with the assistant. Jan-specific property."
items:
type: object
properties:
model_id:
type: string
example: model_0
responses: responses:
"200": "200":
description: description:
@ -506,7 +558,18 @@ paths:
application/json: application/json:
schema: schema:
$ref: "specs/assistants.yaml#/components/schemas/CreateAssistantResponse" $ref: "specs/assistants.yaml#/components/schemas/CreateAssistantResponse"
x-codeSamples:
- lang: "curl"
source: |
curl http://localhost:1337/v1/assistants \
-H "Content-Type: application/json" \
-d '{
"models": [
{
"model_id": "model_0"
}
]
}'
/assistants/{assistant_id}: /assistants/{assistant_id}:
get: get:
operationId: getAssistant operationId: getAssistant
@ -515,6 +578,15 @@ paths:
summary: Retrieve assistant summary: Retrieve assistant
description: | description: |
Retrieves an assistant. <a href = "https://platform.openai.com/docs/api-reference/assistants/getAssistant"> Equivalent to OpenAI's retrieve assistants. </a> Retrieves an assistant. <a href = "https://platform.openai.com/docs/api-reference/assistants/getAssistant"> Equivalent to OpenAI's retrieve assistants. </a>
parameters:
- in: path
name: assistant_id
required: true
schema:
type: string
example: asst_abc123
description: |
The ID of the assistant to retrieve.
responses: responses:
"200": "200":
description: description:
@ -522,7 +594,11 @@ paths:
application/json: application/json:
schema: schema:
$ref: "specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse" $ref: "specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse"
x-codeSamples:
- lang: "curl"
source: |
curl http://localhost:1337/v1/assistants/{assistant_id} \
-H "Content-Type: application/json" \
post: post:
operationId: modifyAssistant operationId: modifyAssistant
tags: tags:
@ -530,13 +606,39 @@ paths:
summary: Modify assistant summary: Modify assistant
description: | description: |
Modifies an assistant. <a href = "https://platform.openai.com/docs/api-reference/assistants/modifyAssistant"> Equivalent to OpenAI's modify assistant. </a> Modifies an assistant. <a href = "https://platform.openai.com/docs/api-reference/assistants/modifyAssistant"> Equivalent to OpenAI's modify assistant. </a>
delete: parameters:
operationId: deleteAssistant - in: path
tags: name: assistant_id
- Assistants required: true
summary: Delete assistant schema:
description: | type: string
Delete an assistant. <a href = "https://platform.openai.com/docs/api-reference/assistants/deleteAssistant"> Equivalent to OpenAI's delete assistant. </a> example: asst_abc123
description: |
The ID of the assistant to modify.
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
models:
type: array
description: "List of models associated with the assistant. Jan-specific property."
items:
type: object
properties:
model_id:
type: string
example: model_0
name:
type: string
description: "Name of the assistant."
example: "Physics Tutor"
instructions:
type: string
description: "A system prompt for the assistant."
example: Be concise!
responses: responses:
"200": "200":
description: description:
@ -544,6 +646,48 @@ paths:
application/json: application/json:
schema: schema:
$ref: "specs/assistants.yaml#/components/schemas/ModifyAssistantResponse" $ref: "specs/assistants.yaml#/components/schemas/ModifyAssistantResponse"
x-codeSamples:
- lang: "curl"
source: |
curl http://localhost:1337/v1/assistants/{assistant_id} \
-H "Content-Type: application/json" \
-d '{
"models": [
{
"model_id": "model_0"
}
],
"name": "Physics Tutor",
"instructions": "Be concise!",
}'
delete:
operationId: deleteAssistant
tags:
- Assistants
summary: Delete assistant
description: |
Delete an assistant. <a href = "https://platform.openai.com/docs/api-reference/assistants/deleteAssistant"> Equivalent to OpenAI's delete assistant. </a>
parameters:
- in: path
name: assistant_id
required: true
schema:
type: string
example: asst_abc123
description: |
The ID of the assistant to delete.
responses:
"200":
description: Deletion status
content:
application/json:
schema:
$ref: "specs/assistants.yaml#/components/schemas/DeleteAssistantResponse"
x-codeSamples:
- lang: "curl"
source: |
curl -X DELETE http://localhost:1337/v1/assistants/{assistant_id}
### MESSAGES ### MESSAGES
/threads/{thread_id}/messages: /threads/{thread_id}/messages:
@ -601,18 +745,14 @@ paths:
role: role:
type: string type: string
description: | description: |
"Role of the sender, either 'user' or 'assistant'." Role of the sender, either 'user' or 'assistant'.
<span style="color:#228B22">OpenAI compatible</span>
example: "user" example: "user"
enum: ["user", "assistant"] enum: ["user", "assistant"]
content: content:
type: string type: string
description: | description: |
"Text content of the message." Text content of the message.
example: How does AI work? Explain it in simple terms.
<span style="color:#228B22">OpenAI compatible</span>
example: "How does AI work? Explain it in simple terms."
required: required:
- role - role
- content - content
@ -626,12 +766,12 @@ paths:
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "curl"
source: | source: |
curl -X POST http://localhost:1337/v1/threads/{thread_id}/messages \ curl -X POST http://localhost:1337/v1/threads/{thread_id}/messages \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d '{
"role": "user", "role": "user",
"content": "How does AI work? Explain it in simple terms." "content": "How does AI work? Explain it in simple terms."
}' }'
/threads/{thread_id}/messages/{message_id}: /threads/{thread_id}/messages/{message_id}:
get: get:
@ -650,7 +790,6 @@ paths:
example: thread_abc123 example: thread_abc123
description: | description: |
The ID of the thread containing the message. The ID of the thread containing the message.
- in: path - in: path
name: message_id name: message_id
required: true required: true
@ -670,8 +809,8 @@ paths:
x-codeSamples: x-codeSamples:
- lang: "curl" - lang: "curl"
source: | source: |
curl http://localhost:1337/v1/threads/{thread_id}/messages/{message_id} \ curl http://localhost:1337/v1/threads/{thread_id}/messages/{message_id} \
-H "Content-Type: application/json" -H "Content-Type: application/json"
/threads/{thread_id}/messages/{message_id}/files: /threads/{thread_id}/messages/{message_id}/files:
get: get:
@ -776,7 +915,7 @@ x-webhooks:
content: content:
application/json: application/json:
schema: schema:
$ref: 'specs/models.yaml#/components/schemas/ModelObject' $ref: "specs/models.yaml#/components/schemas/ModelObject"
AssistantObject: AssistantObject:
post: post:
summary: The assistant object summary: The assistant object
@ -789,7 +928,7 @@ x-webhooks:
content: content:
application/json: application/json:
schema: schema:
$ref: 'specs/assistants.yaml#/components/schemas/AssistantObject' $ref: "specs/assistants.yaml#/components/schemas/AssistantObject"
MessageObject: MessageObject:
post: post:
summary: The message object summary: The message object
@ -802,7 +941,7 @@ x-webhooks:
content: content:
application/json: application/json:
schema: schema:
$ref: 'specs/messages.yaml#/components/schemas/MessageObject' $ref: "specs/messages.yaml#/components/schemas/MessageObject"
ThreadObject: ThreadObject:
post: post:
summary: The thread object summary: The thread object
@ -814,4 +953,4 @@ x-webhooks:
content: content:
application/json: application/json:
schema: schema:
$ref: 'specs/threads.yaml#/components/schemas/ThreadObject' $ref: "specs/threads.yaml#/components/schemas/ThreadObject"

View File

@ -43,7 +43,7 @@ components:
example: model_0 example: model_0
instructions: instructions:
type: string type: string
description: "A system prompt for the assistant" description: "A system prompt for the assistant."
example: Be concise example: Be concise
events: events:
type: object type: object
@ -63,16 +63,267 @@ components:
description: "Metadata associated with the assistant." description: "Metadata associated with the assistant."
ListAssistantsResponse: ListAssistantsResponse:
type: object
CreateAssistantResponse: CreateAssistantResponse:
type: object type: object
properties:
id:
type: string
description: "The identifier of the assistant."
example: "asst_abc123"
object:
type: string
description: "Type of the object, indicating it's an assistant."
default: "assistant"
version:
type: integer
description: "Version number of the assistant."
example: 1
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the assistant."
example: 1698984975
name:
type: string
description: "Name of the assistant."
example: "Math Tutor"
description:
type: string
description: "Description of the assistant. Can be null."
example: null
avatar:
type: string
description: "URL of the assistant's avatar. Jan-specific property."
example: "https://pic.png"
models:
type: array
description: "List of models associated with the assistant. Jan-specific property."
items:
type: object
properties:
model_id:
type: string
example: model_0
instructions:
type: string
description: "A system prompt for the assistant."
example: Be concise
events:
type: object
description: "Event subscription settings for the assistant."
properties:
in:
type: array
items:
type: string
out:
type: array
items:
type: string
# If there are specific event types, they can be detailed here
metadata:
type: object
description: "Metadata associated with the assistant."
RetrieveAssistantResponse: RetrieveAssistantResponse:
type: object type: object
properties:
id:
type: string
description: "The identifier of the assistant."
example: "asst_abc123"
object:
type: string
description: "Type of the object, indicating it's an assistant."
default: "assistant"
version:
type: integer
description: "Version number of the assistant."
example: 1
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the assistant."
example: 1698984975
name:
type: string
description: "Name of the assistant."
example: "Math Tutor"
description:
type: string
description: "Description of the assistant. Can be null."
example: null
avatar:
type: string
description: "URL of the assistant's avatar. Jan-specific property."
example: "https://pic.png"
models:
type: array
description: "List of models associated with the assistant. Jan-specific property."
items:
type: object
properties:
model_id:
type: string
example: model_0
instructions:
type: string
description: "A system prompt for the assistant."
example: Be concise
events:
type: object
description: "Event subscription settings for the assistant."
properties:
in:
type: array
items:
type: string
out:
type: array
items:
type: string
# If there are specific event types, they can be detailed here
metadata:
type: object
description: "Metadata associated with the assistant."
ModifyAssistantObject:
type: object
properties:
id:
type: string
description: "The identifier of the assistant."
example: "asst_abc123"
object:
type: string
description: "Type of the object, indicating it's an assistant."
default: "assistant"
version:
type: integer
description: "Version number of the assistant."
example: 1
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the assistant."
example: 1698984975
name:
type: string
description: "Name of the assistant."
example: "Math Tutor"
description:
type: string
description: "Description of the assistant. Can be null."
example: null
avatar:
type: string
description: "URL of the assistant's avatar. Jan-specific property."
example: "https://pic.png"
models:
type: array
description: "List of models associated with the assistant. Jan-specific property."
items:
type: object
properties:
model_id:
type: string
example: model_0
instructions:
type: string
description: "A system prompt for the assistant."
example: Be concise
events:
type: object
description: "Event subscription settings for the assistant."
properties:
in:
type: array
items:
type: string
out:
type: array
items:
type: string
# If there are specific event types, they can be detailed here
metadata:
type: object
description: "Metadata associated with the assistant."
ModifyAssistantResponse: ModifyAssistantResponse:
type: object type: object
properties:
id:
type: string
description: "The identifier of the assistant."
example: "asst_abc123"
object:
type: string
description: "Type of the object, indicating it's an assistant."
default: "assistant"
version:
type: integer
description: "Version number of the assistant."
example: 1
created_at:
type: integer
format: int64
description: "Unix timestamp representing the creation time of the assistant."
example: 1698984975
name:
type: string
description: "Name of the assistant."
example: "Physics Tutor"
description:
type: string
description: "Description of the assistant. Can be null."
example: null
avatar:
type: string
description: "URL of the assistant's avatar. Jan-specific property."
example: "https://pic.png"
models:
type: array
description: "List of models associated with the assistant. Jan-specific property."
items:
type: object
properties:
model_id:
type: string
example: model_0
instructions:
type: string
description: "A system prompt for the assistant."
example: Be concise!
events:
type: object
description: "Event subscription settings for the assistant."
properties:
in:
type: array
items:
type: string
out:
type: array
items:
type: string
# If there are specific event types, they can be detailed here
metadata:
type: object
description: "Metadata associated with the assistant."
DeleteAssistantResponse: DeleteAssistantResponse:
type: object type: object
properties:
id:
type: string
description: "The identifier of the deleted assistant."
example: asst_abc123
object:
type: string
description: "Type of the object, indicating the assistant has been deleted."
example: assistant.deleted
deleted:
type: boolean
description: "Indicates whether the assistant was successfully deleted."
example: true

View File

@ -109,8 +109,6 @@ components:
description: | description: |
Set probability threshold for more relevant outputs Set probability threshold for more relevant outputs
ChatCompletionResponse: ChatCompletionResponse:
type: object type: object
description: Description of the response structure description: Description of the response structure

View File

@ -44,7 +44,6 @@ components:
description: | description: |
"Type of content, e.g., 'text'." "Type of content, e.g., 'text'."
text: text:
type: object type: object
properties: properties:
@ -207,7 +206,7 @@ components:
data: data:
type: array type: array
items: items:
$ref: '#/components/schemas/ListMessageObject' $ref: "#/components/schemas/ListMessageObject"
first_id: first_id:
type: string type: string
description: "Identifier of the first message in the list." description: "Identifier of the first message in the list."
@ -315,4 +314,4 @@ components:
data: data:
type: array type: array
items: items:
$ref: '#/components/schemas/MessageFileObject' $ref: "#/components/schemas/MessageFileObject"

View File

@ -257,7 +257,6 @@ components:
description: "Indicates whether the model was successfully deleted." description: "Indicates whether the model was successfully deleted."
example: true example: true
StartModelResponse: StartModelResponse:
type: object type: object
properties: properties:
@ -313,4 +312,3 @@ components:
type: string type: string
description: "The current state of the model after the start operation." description: "The current state of the model after the start operation."
example: "downloaded" example: "downloaded"

View File

@ -20,7 +20,6 @@ components:
description: | description: |
"A brief summary or description of the thread, defaults to an empty string." "A brief summary or description of the thread, defaults to an empty string."
example: "funny physics joke" example: "funny physics joke"
assistants: assistants:
type: array type: array
@ -33,7 +32,6 @@ components:
description: | description: |
The identifier of assistant, defaults to "jan" The identifier of assistant, defaults to "jan"
example: jan example: jan
model: model:
type: object type: object
@ -47,14 +45,11 @@ components:
type: object type: object
description: | description: |
Defaults to and overrides assistant.json's "settings" (and if none, then model.json "settings") Defaults to and overrides assistant.json's "settings" (and if none, then model.json "settings")
parameters: parameters:
type: object type: object
description: | description: |
Defaults to and overrides assistant.json's "parameters" (and if none, then model.json "parameters") Defaults to and overrides assistant.json's "parameters" (and if none, then model.json "parameters")
created: created:
type: integer type: integer
format: int64 format: int64
@ -144,7 +139,6 @@ components:
description: | description: |
"Array of file IDs associated with the message, if any." "Array of file IDs associated with the message, if any."
ModifyThreadResponse: ModifyThreadResponse:
type: object type: object
properties: properties: