From 69bdfccddb7e9fa7f1c9c91911419975449eab56 Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:15:19 +0900 Subject: [PATCH 1/9] docs: add assistants endpoint --- docs/openapi/jan.yaml | 13 +++++++ docs/openapi/specs/assistant.yaml | 59 ----------------------------- docs/openapi/specs/assistants.yaml | 61 ++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 59 deletions(-) delete mode 100644 docs/openapi/specs/assistant.yaml create mode 100644 docs/openapi/specs/assistants.yaml diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml index 43c07cb3c..fd2a6fe44 100644 --- a/docs/openapi/jan.yaml +++ b/docs/openapi/jan.yaml @@ -709,6 +709,19 @@ x-webhooks: application/json: schema: $ref: 'specs/models.yaml#/components/schemas/ModelObject' + AssistantObject: + post: + summary: The assistant object + description: | + Build assistants that can call models and use tools to perform tasks. Equivalent to OpenAI's assistants object. + operationId: AssistantObject + tags: + - Assistants + requestBody: + content: + application/json: + schema: + $ref: 'specs/assistants.yaml#/components/schemas/AssistantObject' MessageObject: post: summary: The message object diff --git a/docs/openapi/specs/assistant.yaml b/docs/openapi/specs/assistant.yaml deleted file mode 100644 index 95b4cd22d..000000000 --- a/docs/openapi/specs/assistant.yaml +++ /dev/null @@ -1,59 +0,0 @@ -AssistantObject: - type: object - properties: - avatar: - type: string - description: "URL of the assistant's avatar. Jan-specific property." - example: "https://lala.png" - 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." - name: - type: string - description: "Name of the assistant." - example: "Math Tutor" - description: - type: string - description: "Description of the assistant. Can be null." - models: - type: array - description: "List of models associated with the assistant. Jan-specific property." - items: - type: object - properties: - model_id: - type: string - # Additional properties for models can be added here - 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." - required: - - name - - models - - events \ No newline at end of file diff --git a/docs/openapi/specs/assistants.yaml b/docs/openapi/specs/assistants.yaml new file mode 100644 index 000000000..bb9c96455 --- /dev/null +++ b/docs/openapi/specs/assistants.yaml @@ -0,0 +1,61 @@ +components: + schemas: + AssistantObject: + type: object + properties: + avatar: + type: string + description: "URL of the assistant's avatar. Jan-specific property." + example: "https://lala.png" + 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." + name: + type: string + description: "Name of the assistant." + example: "Math Tutor" + description: + type: string + description: "Description of the assistant. Can be null." + models: + type: array + description: "List of models associated with the assistant. Jan-specific property." + items: + type: object + properties: + model_id: + type: string + # Additional properties for models can be added here + 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." + required: + - name + - models + - events \ No newline at end of file From 2187408604eaf2cd2b27033c650f85f6a373036f Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:30:33 +0900 Subject: [PATCH 2/9] docs: add assistant endpoint --- docs/openapi/jan.yaml | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml index fd2a6fe44..ee646f1eb 100644 --- a/docs/openapi/jan.yaml +++ b/docs/openapi/jan.yaml @@ -476,7 +476,46 @@ paths: - lang: "curl" source: | curl http://localhost:1337/v1/threads/{thread_id} + ### ASSISTANTS + /assistants/: + get: + operationId: listAssistants + tags: + - Assistants + summary: List assistants + description: | + Return a list of assistants. Equivalent to OpenAI's list assistants. + post: + operationId: createAssistants + tags: + - Assistants + summary: Create assistant + description: | + Create an assistant with a model and instructions. Equivalent to OpenAI's create assistants. + /assistants/{assistant_id}: + get: + operationId: getAssistant + tags: + - Assistants + summary: Retrieve assistants + description: | + Retrieves an assistant. Equivalent to OpenAI's retrieve assistants. + post: + operationId: modifyAssistant + tags: + - Assistants + summary: Modify assistant + description: | + Modifies an assistant. Equivalent to OpenAI's modify assistant. + delete: + operationId: deleteAssistant + tags: + - Assistants + summary: Delete assistant + description: | + Delete an assistant. Equivalent to OpenAI's delete assistant. + ### MESSAGES /threads/{thread_id}/messages: get: @@ -714,7 +753,7 @@ x-webhooks: summary: The assistant object description: | Build assistants that can call models and use tools to perform tasks. Equivalent to OpenAI's assistants object. - operationId: AssistantObject + operationId: AssistantObjects tags: - Assistants requestBody: From a5446b038dc85308120d0d5c6a4e9bf92030c282 Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:45:45 +0900 Subject: [PATCH 3/9] docs: fix endpoint url --- docs/openapi/jan.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml index ee646f1eb..8f5ee08b2 100644 --- a/docs/openapi/jan.yaml +++ b/docs/openapi/jan.yaml @@ -486,7 +486,7 @@ paths: description: | Return a list of assistants. Equivalent to OpenAI's list assistants. post: - operationId: createAssistants + operationId: createAssistant tags: - Assistants summary: Create assistant @@ -498,7 +498,7 @@ paths: operationId: getAssistant tags: - Assistants - summary: Retrieve assistants + summary: Retrieve assistant description: | Retrieves an assistant. Equivalent to OpenAI's retrieve assistants. post: From 198cf2e2fcf9f370959f3c654c40084baf62dc20 Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:24:27 +0900 Subject: [PATCH 4/9] docs: add response structure --- docs/openapi/jan.yaml | 31 ++++++++++- docs/openapi/specs/assistants.yaml | 82 +++++++++++++++++++++++++++++- 2 files changed, 111 insertions(+), 2 deletions(-) diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml index 8f5ee08b2..ccf54f2ce 100644 --- a/docs/openapi/jan.yaml +++ b/docs/openapi/jan.yaml @@ -485,6 +485,13 @@ paths: summary: List assistants description: | Return a list of assistants. Equivalent to OpenAI's list assistants. + responses: + "200": + description: + content: + application/json: + schema: + $ref: "specs/assistants.yaml#/components/schemas/ListAssistantsResponse" post: operationId: createAssistant tags: @@ -492,6 +499,13 @@ paths: summary: Create assistant description: | Create an assistant with a model and instructions. Equivalent to OpenAI's create assistants. + responses: + "200": + description: + content: + application/json: + schema: + $ref: "specs/assistants.yaml#/components/schemas/CreateAssistantResponse" /assistants/{assistant_id}: get: @@ -501,6 +515,14 @@ paths: summary: Retrieve assistant description: | Retrieves an assistant. Equivalent to OpenAI's retrieve assistants. + responses: + "200": + description: + content: + application/json: + schema: + $ref: "specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse" + post: operationId: modifyAssistant tags: @@ -515,7 +537,14 @@ paths: summary: Delete assistant description: | Delete an assistant. Equivalent to OpenAI's delete assistant. - + responses: + "200": + description: + content: + application/json: + schema: + $ref: "specs/assistants.yaml#/components/schemas/ModifyAssistantResponse" + ### MESSAGES /threads/{thread_id}/messages: get: diff --git a/docs/openapi/specs/assistants.yaml b/docs/openapi/specs/assistants.yaml index bb9c96455..9db27e308 100644 --- a/docs/openapi/specs/assistants.yaml +++ b/docs/openapi/specs/assistants.yaml @@ -58,4 +58,84 @@ components: required: - name - models - - events \ No newline at end of file + - events + + ListAssistantsResponse: + 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 + + CreateAssistantResponse: + 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 + + RetrieveAssistantResponse: + 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 + + ModifyAssistantResponse: + 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 + + DeleteAssistantResponse: + 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 \ No newline at end of file From ece03faee3106e189025f3f1047529486bf77374 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Fri, 1 Dec 2023 18:02:19 +0800 Subject: [PATCH 5/9] docs: add assistants nits --- docs/docs/specs/engineering/assistants.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/docs/specs/engineering/assistants.md b/docs/docs/specs/engineering/assistants.md index ea0ec0955..d03989d66 100644 --- a/docs/docs/specs/engineering/assistants.md +++ b/docs/docs/specs/engineering/assistants.md @@ -38,6 +38,10 @@ In Jan, assistants are `primary` entities with the following capabilities: ## `assistant.json` +- Each `assistant` folder contains an `assistant.json` file, which is a representation of an assistant. +- `assistant.json` contains metadata and model parameter overrides +- There are no required fields. + ```js { "id": "asst_abc123", // Defaults to foldername From 87484e84288d2cf959f50ace9f1c58bc36933d21 Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:25:32 +0900 Subject: [PATCH 6/9] docs: update assistant object --- docs/openapi/specs/assistants.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/openapi/specs/assistants.yaml b/docs/openapi/specs/assistants.yaml index 9db27e308..4565d6ef0 100644 --- a/docs/openapi/specs/assistants.yaml +++ b/docs/openapi/specs/assistants.yaml @@ -3,10 +3,6 @@ components: AssistantObject: type: object properties: - avatar: - type: string - description: "URL of the assistant's avatar. Jan-specific property." - example: "https://lala.png" id: type: string description: "The identifier of the assistant." @@ -23,6 +19,7 @@ components: type: integer format: int64 description: "Unix timestamp representing the creation time of the assistant." + example: 1698984975 name: type: string description: "Name of the assistant." @@ -30,6 +27,11 @@ components: 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." @@ -38,7 +40,11 @@ components: properties: model_id: type: string - # Additional properties for models can be added here + 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." @@ -55,10 +61,6 @@ components: metadata: type: object description: "Metadata associated with the assistant." - required: - - name - - models - - events ListAssistantsResponse: type: object From 5dfa40d57d0e08d8faa0a9e796da6131931b0896 Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:27:40 +0900 Subject: [PATCH 7/9] remove current response --- docs/openapi/specs/assistants.yaml | 69 +----------------------------- 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/docs/openapi/specs/assistants.yaml b/docs/openapi/specs/assistants.yaml index 4565d6ef0..c5fb12b6d 100644 --- a/docs/openapi/specs/assistants.yaml +++ b/docs/openapi/specs/assistants.yaml @@ -64,80 +64,15 @@ components: ListAssistantsResponse: 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 CreateAssistantResponse: 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 RetrieveAssistantResponse: 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 - + ModifyAssistantResponse: 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 DeleteAssistantResponse: - 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 \ No newline at end of file + type: object \ No newline at end of file From ba2341e4c359a67ee3546adf02515b2a65315909 Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 8 Dec 2023 03:59:02 +0900 Subject: [PATCH 8/9] add assistants request and response --- docs/openapi/jan.yaml | 277 ++++++++++++++++++++++------- docs/openapi/specs/assistants.yaml | 267 ++++++++++++++++++++++++++- docs/openapi/specs/chat.yaml | 2 - docs/openapi/specs/messages.yaml | 5 +- docs/openapi/specs/models.yaml | 6 +- docs/openapi/specs/threads.yaml | 18 +- 6 files changed, 477 insertions(+), 98 deletions(-) diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml index ccf54f2ce..62d26b79b 100644 --- a/docs/openapi/jan.yaml +++ b/docs/openapi/jan.yaml @@ -16,7 +16,7 @@ servers: tags: - name: Models description: List and describe the various models available in the API. - - name: Chat + - name: Chat description: | Given a list of messages comprising a conversation, the model will return a response. @@ -42,7 +42,7 @@ paths: operationId: createChatCompletion tags: - Chat - summary: | + summary: | Create chat completion description: | Creates a model response for the given chat conversation. Equivalent to OpenAI's create chat completion. @@ -72,7 +72,7 @@ paths: }, ] }' - + ### MODELS /models: get: @@ -111,7 +111,7 @@ paths: - lang: "curl" source: | curl -X POST https://localhost:1337/v1/models - /models/{model_id}: + /models/{model_id}: get: operationId: retrieveModel tags: @@ -166,7 +166,7 @@ paths: x-codeSamples: - lang: "curl" source: | - curl -X DELETE https://localhost:1337/v1/models/zephyr-7b + curl -X DELETE https://localhost:1337/v1/models/zephyr-7b /models/{model_id}/start: put: operationId: startModel @@ -195,7 +195,7 @@ paths: x-codeSamples: - lang: "curl" source: | - curl -X PUT https://localhost:1337/v1/models/zephyr-7b/start + curl -X PUT https://localhost:1337/v1/models/zephyr-7b/start /models/{model_id}/stop: put: operationId: stopModel @@ -245,14 +245,14 @@ paths: type: array description: "Initial set of messages for the thread." items: - $ref: 'specs/threads.yaml#/components/schemas/ThreadMessageObject' + $ref: "specs/threads.yaml#/components/schemas/ThreadMessageObject" responses: "200": description: Thread created successfully content: application/json: schema: - $ref: 'specs/threads.yaml#/components/schemas/CreateThreadResponse' + $ref: "specs/threads.yaml#/components/schemas/CreateThreadResponse" x-codeSamples: - lang: "cURL" source: | @@ -267,7 +267,7 @@ paths: "role": "user", "content": "How does AI work? Explain it in simple terms." }] - }' + }' get: operationId: listThreads tags: @@ -283,7 +283,7 @@ paths: schema: type: array items: - $ref: 'specs/threads.yaml#/components/schemas/ThreadObject' + $ref: "specs/threads.yaml#/components/schemas/ThreadObject" example: - id: "thread_abc123" object: "thread" @@ -299,9 +299,9 @@ paths: x-codeSamples: - lang: "curl" source: | - curl http://localhost:1337/v1/threads \ - -H "Content-Type: application/json" \ - + curl http://localhost:1337/v1/threads \ + -H "Content-Type: application/json" \ + /threads/{thread_id}: get: operationId: getThread @@ -359,29 +359,29 @@ paths: type: array description: "Set of messages to update in the thread." items: - $ref: 'specs/threads.yaml#/components/schemas/ThreadMessageObject' + $ref: "specs/threads.yaml#/components/schemas/ThreadMessageObject" responses: "200": description: Thread modified successfully content: application/json: schema: - $ref: 'specs/threads.yaml#/components/schemas/ModifyThreadResponse' + $ref: "specs/threads.yaml#/components/schemas/ModifyThreadResponse" x-codeSamples: - lang: "curl" source: | - curl -X POST http://localhost:1337/v1/threads/{thread_id} \ - -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." - }] - }' + curl -X POST http://localhost:1337/v1/threads/{thread_id} \ + -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." + }] + }' delete: operationId: deleteThread tags: @@ -404,7 +404,7 @@ paths: content: application/json: schema: - $ref: 'specs/threads.yaml#/components/schemas/DeleteThreadResponse' + $ref: "specs/threads.yaml#/components/schemas/DeleteThreadResponse" x-codeSamples: - lang: "curl" source: | @@ -445,17 +445,17 @@ paths: - Threads summary: Modify Thread.Assistants description: | - + Can achieve this goal by calling Modify Assistant API with thread.assistant[] - + /threads/{thread_id}/: get: operationId: listThreadMessage tags: - Threads summary: List Thread.Messages - description: | + description: | Can achieve this goal by calling Get Thread API parameters: - in: path @@ -486,12 +486,48 @@ paths: description: | Return a list of assistants. Equivalent to OpenAI's list assistants. responses: + responses: "200": - description: + description: List of threads retrieved successfully content: application/json: 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: operationId: createAssistant tags: @@ -499,6 +535,22 @@ paths: summary: Create assistant description: | Create an assistant with a model and instructions. Equivalent to OpenAI's create assistants. + 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: "200": description: @@ -506,7 +558,18 @@ paths: application/json: schema: $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}: get: operationId: getAssistant @@ -514,7 +577,16 @@ paths: - Assistants summary: Retrieve assistant description: | - Retrieves an assistant. Equivalent to OpenAI's retrieve assistants. + Retrieves an assistant. Equivalent to OpenAI's retrieve assistants. + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + example: asst_abc123 + description: | + The ID of the assistant to retrieve. responses: "200": description: @@ -522,7 +594,11 @@ paths: application/json: schema: $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: operationId: modifyAssistant tags: @@ -530,13 +606,39 @@ paths: summary: Modify assistant description: | Modifies an assistant. Equivalent to OpenAI's modify assistant. - delete: - operationId: deleteAssistant - tags: - - Assistants - summary: Delete assistant - description: | - Delete an assistant. Equivalent to OpenAI's delete assistant. + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + 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: "200": description: @@ -544,6 +646,48 @@ paths: application/json: schema: $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. Equivalent to OpenAI's delete assistant. + 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 /threads/{thread_id}/messages: @@ -601,18 +745,14 @@ paths: role: type: string description: | - "Role of the sender, either 'user' or 'assistant'." - - OpenAI compatible + Role of the sender, either 'user' or 'assistant'. example: "user" enum: ["user", "assistant"] content: type: string description: | - "Text content of the message." - - OpenAI compatible - example: "How does AI work? Explain it in simple terms." + Text content of the message. + example: How does AI work? Explain it in simple terms. required: - role - content @@ -626,12 +766,12 @@ paths: x-codeSamples: - lang: "curl" source: | - curl -X POST http://localhost:1337/v1/threads/{thread_id}/messages \ - -H "Content-Type: application/json" \ - -d '{ - "role": "user", - "content": "How does AI work? Explain it in simple terms." - }' + curl -X POST http://localhost:1337/v1/threads/{thread_id}/messages \ + -H "Content-Type: application/json" \ + -d '{ + "role": "user", + "content": "How does AI work? Explain it in simple terms." + }' /threads/{thread_id}/messages/{message_id}: get: @@ -650,7 +790,6 @@ paths: example: thread_abc123 description: | The ID of the thread containing the message. - - in: path name: message_id required: true @@ -670,8 +809,8 @@ paths: x-codeSamples: - lang: "curl" source: | - curl http://localhost:1337/v1/threads/{thread_id}/messages/{message_id} \ - -H "Content-Type: application/json" + curl http://localhost:1337/v1/threads/{thread_id}/messages/{message_id} \ + -H "Content-Type: application/json" /threads/{thread_id}/messages/{message_id}/files: get: @@ -679,8 +818,8 @@ paths: tags: - Messages summary: | - List message files - description: | + List message files + description: | Returns a list of message files. Equivalent to OpenAI's list message files. parameters: - in: path @@ -698,9 +837,9 @@ paths: schema: type: string example: msg_abc123 - description: | - The ID of the message whose files are to be listed. - + description: | + The ID of the message whose files are to be listed. + responses: "200": description: List of files retrieved successfully @@ -749,7 +888,7 @@ paths: example: file-abc123 description: | The ID of the file to retrieve. - + responses: "200": description: File retrieved successfully @@ -776,7 +915,7 @@ x-webhooks: content: application/json: schema: - $ref: 'specs/models.yaml#/components/schemas/ModelObject' + $ref: "specs/models.yaml#/components/schemas/ModelObject" AssistantObject: post: summary: The assistant object @@ -789,7 +928,7 @@ x-webhooks: content: application/json: schema: - $ref: 'specs/assistants.yaml#/components/schemas/AssistantObject' + $ref: "specs/assistants.yaml#/components/schemas/AssistantObject" MessageObject: post: summary: The message object @@ -802,7 +941,7 @@ x-webhooks: content: application/json: schema: - $ref: 'specs/messages.yaml#/components/schemas/MessageObject' + $ref: "specs/messages.yaml#/components/schemas/MessageObject" ThreadObject: post: summary: The thread object @@ -814,4 +953,4 @@ x-webhooks: content: application/json: schema: - $ref: 'specs/threads.yaml#/components/schemas/ThreadObject' + $ref: "specs/threads.yaml#/components/schemas/ThreadObject" diff --git a/docs/openapi/specs/assistants.yaml b/docs/openapi/specs/assistants.yaml index c5fb12b6d..687fb12ff 100644 --- a/docs/openapi/specs/assistants.yaml +++ b/docs/openapi/specs/assistants.yaml @@ -40,10 +40,10 @@ components: properties: model_id: type: string - example: model_0 + example: model_0 instructions: type: string - description: "A system prompt for the assistant" + description: "A system prompt for the assistant." example: Be concise events: type: object @@ -61,18 +61,269 @@ components: metadata: type: object description: "Metadata associated with the assistant." - + ListAssistantsResponse: - type: object CreateAssistantResponse: 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: 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: 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: - type: object \ No newline at end of file + 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 diff --git a/docs/openapi/specs/chat.yaml b/docs/openapi/specs/chat.yaml index 05444c444..166a6bd6c 100644 --- a/docs/openapi/specs/chat.yaml +++ b/docs/openapi/specs/chat.yaml @@ -109,8 +109,6 @@ components: description: | Set probability threshold for more relevant outputs - - ChatCompletionResponse: type: object description: Description of the response structure diff --git a/docs/openapi/specs/messages.yaml b/docs/openapi/specs/messages.yaml index b99fc4221..3ab578f0c 100644 --- a/docs/openapi/specs/messages.yaml +++ b/docs/openapi/specs/messages.yaml @@ -44,7 +44,6 @@ components: description: | "Type of content, e.g., 'text'." - text: type: object properties: @@ -207,7 +206,7 @@ components: data: type: array items: - $ref: '#/components/schemas/ListMessageObject' + $ref: "#/components/schemas/ListMessageObject" first_id: type: string description: "Identifier of the first message in the list." @@ -315,4 +314,4 @@ components: data: type: array items: - $ref: '#/components/schemas/MessageFileObject' \ No newline at end of file + $ref: "#/components/schemas/MessageFileObject" diff --git a/docs/openapi/specs/models.yaml b/docs/openapi/specs/models.yaml index aa5cc4155..b27e4bc8f 100644 --- a/docs/openapi/specs/models.yaml +++ b/docs/openapi/specs/models.yaml @@ -130,7 +130,7 @@ components: created: type: integer format: int64 - description: | + description: | "Unix timestamp representing the creation time of the model." example: "1253935178" @@ -240,7 +240,7 @@ components: - source_url - parameters - metadata - + DeleteModelResponse: type: object properties: @@ -257,7 +257,6 @@ components: description: "Indicates whether the model was successfully deleted." example: true - StartModelResponse: type: object properties: @@ -313,4 +312,3 @@ components: type: string description: "The current state of the model after the start operation." example: "downloaded" - diff --git a/docs/openapi/specs/threads.yaml b/docs/openapi/specs/threads.yaml index c009381e3..0c3a30ce8 100644 --- a/docs/openapi/specs/threads.yaml +++ b/docs/openapi/specs/threads.yaml @@ -17,15 +17,14 @@ components: example: thread title: type: string - description: | + description: | "A brief summary or description of the thread, defaults to an empty string." - example: "funny physics joke" assistants: type: array - description: | - + description: | + items: properties: assistant_id: @@ -33,7 +32,6 @@ components: description: | The identifier of assistant, defaults to "jan" - example: jan model: type: object @@ -41,20 +39,17 @@ components: id: type: string description: | - + example: ... - settings: + settings: type: object description: | Defaults to and overrides assistant.json's "settings" (and if none, then model.json "settings") - - parameters: type: object description: | Defaults to and overrides assistant.json's "parameters" (and if none, then model.json "parameters") - created: type: integer format: int64 @@ -143,7 +138,6 @@ components: type: string description: | "Array of file IDs associated with the message, if any." - ModifyThreadResponse: type: object @@ -181,4 +175,4 @@ components: deleted: type: boolean description: "Indicates whether the thread was successfully deleted." - example: true \ No newline at end of file + example: true From 78b620896d88cbff5a9ac9c9bd818677bc4798c2 Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 8 Dec 2023 04:03:02 +0900 Subject: [PATCH 9/9] fix: minor bugs on models endpoints --- docs/openapi/jan.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml index 62d26b79b..ed558d14d 100644 --- a/docs/openapi/jan.yaml +++ b/docs/openapi/jan.yaml @@ -139,7 +139,7 @@ paths: x-codeSamples: - lang: "curl" source: | - curl https://localhost:1337/v1/models/zephyr-7b + curl https://localhost:1337/v1/models/{model_id} delete: operationId: deleteModel tags: @@ -166,7 +166,7 @@ paths: x-codeSamples: - lang: "curl" source: | - curl -X DELETE https://localhost:1337/v1/models/zephyr-7b + curl -X DELETE https://localhost:1337/v1/models/{model_id} /models/{model_id}/start: put: operationId: startModel @@ -195,7 +195,7 @@ paths: x-codeSamples: - lang: "curl" source: | - curl -X PUT https://localhost:1337/v1/models/zephyr-7b/start + curl -X PUT https://localhost:1337/v1/models/{model_id}/start /models/{model_id}/stop: put: operationId: stopModel @@ -223,7 +223,7 @@ paths: x-codeSamples: - lang: "curl" source: | - curl -X PUT https://localhost:1337/v1/models/zephyr-7b/stop + curl -X PUT https://localhost:1337/v1/models/{model_id}/stop ### THREADS /threads: