From 11ff9a2a2fe500d41a2fc817ff79be399e532f09 Mon Sep 17 00:00:00 2001
From: avb-is-me <104213687+avb-is-me@users.noreply.github.com>
Date: Wed, 28 Feb 2024 16:29:18 +0000
Subject: [PATCH 1/3] adds code samples for the assistant_id endpoints
---
docs/openapi/jan.yaml | 128 +++++++++++++++++++++++++++---------------
1 file changed, 82 insertions(+), 46 deletions(-)
diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml
index 864c80fdf6..09916415aa 100644
--- a/docs/openapi/jan.yaml
+++ b/docs/openapi/jan.yaml
@@ -1,11 +1,11 @@
----
openapi: 3.0.0
info:
title: API Reference
description: >
# Introduction
- Jan API is compatible with the [OpenAI API](https://platform.openai.com/docs/api-reference).
+ Jan API is compatible with the [OpenAI
+ API](https://platform.openai.com/docs/api-reference).
version: 0.1.8
contact:
name: Jan Discord
@@ -20,12 +20,12 @@ tags:
description: List and describe the various models available in the API.
- name: Chat
description: >
- Given a list of messages comprising a conversation, the model will
- return a response.
+ Given a list of messages comprising a conversation, the model will return
+ a response.
- name: Messages
description: >
- Messages capture a conversation's content. This can include the
- content from LLM responses and other metadata from [chat
+ Messages capture a conversation's content. This can include the content
+ from LLM responses and other metadata from [chat
completions](/specs/chats).
- name: Threads
- name: Assistants
@@ -49,16 +49,16 @@ paths:
summary: |
Create chat completion
description: >
- Creates a model response for the given chat conversation.
- Equivalent to OpenAI's create chat completion.
+ Creates a model response for the given chat conversation. Equivalent
+ to OpenAI's create chat completion.
requestBody:
content:
application/json:
schema:
$ref: specs/chat.yaml#/components/schemas/ChatCompletionRequest
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -100,12 +100,12 @@ paths:
- Models
summary: List models
description: >
- Lists the currently available models, and provides basic
- information about each one such as the owner and availability.
- Equivalent to OpenAI's list model.
+ Lists the currently available models, and provides basic information
+ about each one such as the owner and availability. Equivalent
+ to OpenAI's list model.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -117,7 +117,7 @@ paths:
curl -X 'GET' \
'http://localhost:1337/v1/models' \
-H 'accept: application/json'
- "/models/download/{model_id}":
+ /models/download/{model_id}:
get:
operationId: downloadModel
tags:
@@ -135,7 +135,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -147,15 +147,15 @@ paths:
curl -X 'GET' \
'http://localhost:1337/v1/models/download/{model_id}' \
-H 'accept: application/json'
- "/models/{model_id}":
+ /models/{model_id}:
get:
operationId: retrieveModel
tags:
- Models
summary: Retrieve model
description: >
- Get a model instance, providing basic information about the model
- such as the owner and permissioning.
Equivalent to OpenAI's retrieve model.
parameters:
@@ -168,7 +168,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -199,7 +199,7 @@ paths:
description: |
The model id to delete
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -228,7 +228,7 @@ paths:
schema:
$ref: specs/threads.yaml#/components/schemas/CreateThreadObject
responses:
- "200":
+ '200':
description: Thread created successfully
content:
application/json:
@@ -257,7 +257,7 @@ paths:
description: |
Retrieves a list of all threads available in the system.
responses:
- "200":
+ '200':
description: List of threads retrieved successfully
content:
application/json:
@@ -285,7 +285,7 @@ paths:
source: |
curl http://localhost:1337/v1/threads \
-H "Content-Type: application/json" \
- "/threads/{thread_id}":
+ /threads/{thread_id}:
get:
operationId: getThread
tags:
@@ -305,7 +305,7 @@ paths:
description: |
The ID of the thread to retrieve.
responses:
- "200":
+ '200':
description: Thread details retrieved successfully
content:
application/json:
@@ -345,7 +345,7 @@ paths:
items:
$ref: specs/threads.yaml#/components/schemas/ThreadMessageObject
responses:
- "200":
+ '200':
description: Thread modified successfully
content:
application/json:
@@ -384,7 +384,7 @@ paths:
description: |
The ID of the thread to be deleted.
responses:
- "200":
+ '200':
description: Thread deleted successfully
content:
application/json:
@@ -405,7 +405,7 @@ paths:
"https://platform.openai.com/docs/api-reference/assistants/listAssistants">
Equivalent to OpenAI's list assistants.
responses:
- "200":
+ '200':
description: List of assistants retrieved successfully
content:
application/json:
@@ -445,7 +445,7 @@ paths:
source: |
curl http://localhost:1337/v1/assistants \
-H "Content-Type: application/json" \
- "/assistants/{assistant_id}":
+ /assistants/{assistant_id}:
get:
operationId: getAssistant
tags:
@@ -465,18 +465,54 @@ paths:
description: |
The ID of the assistant to retrieve.
responses:
- "200":
+ '200':
description: null
content:
application/json:
schema:
- $ref: specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse
+ $ref: >-
+ specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse
x-codeSamples:
- lang: cURL
- source: |
+ source: |-
curl http://localhost:1337/v1/assistants/{assistant_id} \
- -H "Content-Type: application/json" \
- "/threads/{thread_id}/messages":
+ -H "Content-Type: application/json"
+ - lang: JavaScript
+ source: |-
+ const fetch = require('node-fetch');
+
+ let assistantId = 'abc123';
+
+ fetch(`http://localhost:1337/v1/assistants/${assistantId}`, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ })
+ - lang: Node.js
+ source: |-
+ const fetch = require('node-fetch');
+
+ let assistantId = 'abc123';
+
+ fetch(`http://localhost:1337/v1/assistants/${assistantId}`, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ })
+ - lang: Python
+ source: >-
+ import requests
+
+
+ assistant_id = 'abc123'
+
+
+ response =
+ requests.get(f'http://localhost:1337/v1/assistants/{assistant_id}',
+ headers={'Content-Type': 'application/json'})
+ /threads/{thread_id}/messages:
get:
operationId: listMessages
tags:
@@ -495,7 +531,7 @@ paths:
description: |
The ID of the thread from which to retrieve messages.
responses:
- "200":
+ '200':
description: List of messages retrieved successfully
content:
application/json:
@@ -547,7 +583,7 @@ paths:
- role
- content
responses:
- "200":
+ '200':
description: Message created successfully
content:
application/json:
@@ -562,7 +598,7 @@ paths:
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}'
- "/threads/{thread_id}/messages/{message_id}":
+ /threads/{thread_id}/messages/{message_id}:
get:
operationId: retrieveMessage
tags:
@@ -589,7 +625,7 @@ paths:
description: |
The ID of the message to retrieve.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -598,8 +634,8 @@ paths:
x-codeSamples:
- lang: cURL
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"
x-webhooks:
ModelObject:
@@ -621,10 +657,9 @@ x-webhooks:
post:
summary: The assistant object
description: >
- Build assistants that can call models and use tools to perform
- tasks. Equivalent
- to OpenAI's assistants object.
+ Build assistants that can call models and use tools to perform tasks.
+
+ Equivalent to OpenAI's assistants object.
operationId: AssistantObjects
tags:
- Assistants
@@ -651,7 +686,8 @@ x-webhooks:
ThreadObject:
post:
summary: The thread object
- description: Represents a thread that contains messages. -
+ Represents a thread that contains messages.
Equivalent to OpenAI's thread object.
operationId: ThreadObject
From 02f2536410b73b130d8c5925e108e43b35eb3fa8 Mon Sep 17 00:00:00 2001
From: hieu-jan <150573299+hieu-jan@users.noreply.github.com>
Date: Sun, 3 Mar 2024 07:34:10 +0900
Subject: [PATCH 2/3] docs: re-order language support consistency
---
docs/openapi/jan.yaml | 94 +++++++++++++++++++------------------------
1 file changed, 42 insertions(+), 52 deletions(-)
diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml
index 3d147299e4..d227c018ba 100644
--- a/docs/openapi/jan.yaml
+++ b/docs/openapi/jan.yaml
@@ -1,11 +1,11 @@
+---
openapi: 3.0.0
info:
title: API Reference
description: >
# Introduction
- Jan API is compatible with the [OpenAI
- API](https://platform.openai.com/docs/api-reference).
+ Jan API is compatible with the [OpenAI API](https://platform.openai.com/docs/api-reference).
version: 0.1.8
contact:
name: Jan Discord
@@ -20,12 +20,12 @@ tags:
description: List and describe the various models available in the API.
- name: Chat
description: >
- Given a list of messages comprising a conversation, the model will return
- a response.
+ Given a list of messages comprising a conversation, the model will
+ return a response.
- name: Messages
description: >
- Messages capture a conversation's content. This can include the content
- from LLM responses and other metadata from [chat
+ Messages capture a conversation's content. This can include the
+ content from LLM responses and other metadata from [chat
completions](/specs/chats).
- name: Threads
- name: Assistants
@@ -49,9 +49,9 @@ paths:
summary: |
Create chat completion
description: >
- Creates a model response for the given chat conversation. Equivalent
- to OpenAI's create chat completion.
+ Creates a model response for the given chat conversation.
+ Equivalent to OpenAI's create chat completion.
requestBody:
content:
application/json:
@@ -192,9 +192,7 @@ paths:
}
- response =
- requests.post('http://localhost:1337/v1/chat/completions',
- json=data)
+ response = requests.post('http://localhost:1337/v1/chat/completions', json=data)
print(response.json())
/models:
@@ -204,10 +202,10 @@ paths:
- Models
summary: List models
description: >
- Lists the currently available models, and provides basic information
- about each one such as the owner and availability. Equivalent
- to OpenAI's list model.
+ Lists the currently available models, and provides basic
+ information about each one such as the owner and availability.
+ Equivalent to OpenAI's list model.
responses:
'200':
description: OK
@@ -228,14 +226,7 @@ paths:
headers: {Accept: 'application/json'}
});
const data = await response.json();
- - lang: Python
- source: |-
- import requests
- url = 'http://localhost:1337/v1/models'
- headers = {'Accept': 'application/json'}
- response = requests.get(url, headers=headers)
- data = response.json()
- lang: Node.js
source: |-
const fetch = require('node-fetch');
@@ -249,7 +240,15 @@ paths:
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json));
- /models/download/{model_id}:
+ - lang: Python
+ source: |-
+ import requests
+
+ url = 'http://localhost:1337/v1/models'
+ headers = {'Accept': 'application/json'}
+ response = requests.get(url, headers=headers)
+ data = response.json()
+ '/models/download/{model_id}':
get:
operationId: downloadModel
tags:
@@ -304,20 +303,18 @@ paths:
import requests
- response =
- requests.get('http://localhost:1337/v1/models/download/{model_id}',
- headers={'accept': 'application/json'})
+ response = requests.get('http://localhost:1337/v1/models/download/{model_id}', headers={'accept': 'application/json'})
data = response.json()
- /models/{model_id}:
+ '/models/{model_id}':
get:
operationId: retrieveModel
tags:
- Models
summary: Retrieve model
description: >
- Get a model instance, providing basic information about the model such
- as the owner and permissioning.
Equivalent to OpenAI's retrieve model.
parameters:
@@ -374,9 +371,7 @@ paths:
model_id = 'mistral-ins-7b-q4'
- response =
- requests.get(f'http://localhost:1337/v1/models/{model_id}',
- headers={'accept': 'application/json'})
+ response = requests.get(f'http://localhost:1337/v1/models/{model_id}', headers={'accept': 'application/json'})
print(response.json())
delete:
@@ -442,9 +437,7 @@ paths:
model_id = 'mistral-ins-7b-q4'
- response =
- requests.delete(f'http://localhost:1337/v1/models/{model_id}',
- headers={'accept': 'application/json'})
+ response = requests.delete(f'http://localhost:1337/v1/models/{model_id}', headers={'accept': 'application/json'})
/threads:
post:
operationId: createThread
@@ -613,7 +606,7 @@ paths:
response = requests.get(url, headers=headers)
print(response.json())
- /threads/{thread_id}:
+ '/threads/{thread_id}':
get:
operationId: getThread
tags:
@@ -799,7 +792,7 @@ paths:
headers = {'Content-Type': 'application/json'}
response = requests.get(url, headers=headers)
- /assistants/{assistant_id}:
+ '/assistants/{assistant_id}':
get:
operationId: getAssistant
tags:
@@ -824,8 +817,7 @@ paths:
content:
application/json:
schema:
- $ref: >-
- specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse
+ $ref: specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse
x-codeSamples:
- lang: cURL
source: |-
@@ -863,10 +855,8 @@ paths:
assistant_id = 'abc123'
- response =
- requests.get(f'http://localhost:1337/v1/assistants/{assistant_id}',
- headers={'Content-Type': 'application/json'})
- /threads/{thread_id}/messages:
+ response = requests.get(f'http://localhost:1337/v1/assistants/{assistant_id}', headers={'Content-Type': 'application/json'})
+ '/threads/{thread_id}/messages':
get:
operationId: listMessages
tags:
@@ -952,7 +942,7 @@ paths:
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}'
- /threads/{thread_id}/messages/{message_id}:
+ '/threads/{thread_id}/messages/{message_id}':
get:
operationId: retrieveMessage
tags:
@@ -988,8 +978,8 @@ paths:
x-codeSamples:
- lang: cURL
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"
x-webhooks:
ModelObject:
@@ -1011,9 +1001,10 @@ x-webhooks:
post:
summary: The assistant object
description: >
- Build assistants that can call models and use tools to perform tasks.
-
- Equivalent to OpenAI's assistants object.
+ Build assistants that can call models and use tools to perform
+ tasks. Equivalent
+ to OpenAI's assistants object.
operationId: AssistantObjects
tags:
- Assistants
@@ -1040,8 +1031,7 @@ x-webhooks:
ThreadObject:
post:
summary: The thread object
- description: >-
- Represents a thread that contains messages.
Equivalent to OpenAI's thread object.
operationId: ThreadObject
From 497020c7a355ea3169d2807eff6fbc981fddbc34 Mon Sep 17 00:00:00 2001
From: hieu-jan <150573299+hieu-jan@users.noreply.github.com>
Date: Sun, 3 Mar 2024 07:39:39 +0900
Subject: [PATCH 3/3] docs: yaml lint
---
docs/openapi/jan.yaml | 43 +++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml
index d227c018ba..f45db7d2da 100644
--- a/docs/openapi/jan.yaml
+++ b/docs/openapi/jan.yaml
@@ -58,7 +58,7 @@ paths:
schema:
$ref: specs/chat.yaml#/components/schemas/ChatCompletionRequest
responses:
- '200':
+ "200":
description: OK
content:
application/json:
@@ -207,7 +207,7 @@ paths:
= "https://platform.openai.com/docs/api-reference/models/list">
Equivalent to OpenAI's list model.
responses:
- '200':
+ "200":
description: OK
content:
application/json:
@@ -226,7 +226,6 @@ paths:
headers: {Accept: 'application/json'}
});
const data = await response.json();
-
- lang: Node.js
source: |-
const fetch = require('node-fetch');
@@ -248,7 +247,7 @@ paths:
headers = {'Accept': 'application/json'}
response = requests.get(url, headers=headers)
data = response.json()
- '/models/download/{model_id}':
+ "/models/download/{model_id}":
get:
operationId: downloadModel
tags:
@@ -266,7 +265,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
- '200':
+ "200":
description: OK
content:
application/json:
@@ -306,7 +305,7 @@ paths:
response = requests.get('http://localhost:1337/v1/models/download/{model_id}', headers={'accept': 'application/json'})
data = response.json()
- '/models/{model_id}':
+ "/models/{model_id}":
get:
operationId: retrieveModel
tags:
@@ -327,7 +326,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
- '200':
+ "200":
description: OK
content:
application/json:
@@ -393,7 +392,7 @@ paths:
description: |
The model id to delete
responses:
- '200':
+ "200":
description: OK
content:
application/json:
@@ -455,7 +454,7 @@ paths:
schema:
$ref: specs/threads.yaml#/components/schemas/CreateThreadObject
responses:
- '200':
+ "200":
description: Thread created successfully
content:
application/json:
@@ -551,7 +550,7 @@ paths:
description: |
Retrieves a list of all threads available in the system.
responses:
- '200':
+ "200":
description: List of threads retrieved successfully
content:
application/json:
@@ -606,7 +605,7 @@ paths:
response = requests.get(url, headers=headers)
print(response.json())
- '/threads/{thread_id}':
+ "/threads/{thread_id}":
get:
operationId: getThread
tags:
@@ -626,7 +625,7 @@ paths:
description: |
The ID of the thread to retrieve.
responses:
- '200':
+ "200":
description: Thread details retrieved successfully
content:
application/json:
@@ -666,7 +665,7 @@ paths:
items:
$ref: specs/threads.yaml#/components/schemas/ThreadMessageObject
responses:
- '200':
+ "200":
description: Thread modified successfully
content:
application/json:
@@ -705,7 +704,7 @@ paths:
description: |
The ID of the thread to be deleted.
responses:
- '200':
+ "200":
description: Thread deleted successfully
content:
application/json:
@@ -726,7 +725,7 @@ paths:
"https://platform.openai.com/docs/api-reference/assistants/listAssistants">
Equivalent to OpenAI's list assistants.
responses:
- '200':
+ "200":
description: List of assistants retrieved successfully
content:
application/json:
@@ -792,7 +791,7 @@ paths:
headers = {'Content-Type': 'application/json'}
response = requests.get(url, headers=headers)
- '/assistants/{assistant_id}':
+ "/assistants/{assistant_id}":
get:
operationId: getAssistant
tags:
@@ -812,7 +811,7 @@ paths:
description: |
The ID of the assistant to retrieve.
responses:
- '200':
+ "200":
description: null
content:
application/json:
@@ -856,7 +855,7 @@ paths:
response = requests.get(f'http://localhost:1337/v1/assistants/{assistant_id}', headers={'Content-Type': 'application/json'})
- '/threads/{thread_id}/messages':
+ "/threads/{thread_id}/messages":
get:
operationId: listMessages
tags:
@@ -875,7 +874,7 @@ paths:
description: |
The ID of the thread from which to retrieve messages.
responses:
- '200':
+ "200":
description: List of messages retrieved successfully
content:
application/json:
@@ -927,7 +926,7 @@ paths:
- role
- content
responses:
- '200':
+ "200":
description: Message created successfully
content:
application/json:
@@ -942,7 +941,7 @@ paths:
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}'
- '/threads/{thread_id}/messages/{message_id}':
+ "/threads/{thread_id}/messages/{message_id}":
get:
operationId: retrieveMessage
tags:
@@ -969,7 +968,7 @@ paths:
description: |
The ID of the message to retrieve.
responses:
- '200':
+ "200":
description: OK
content:
application/json: