Merge branch 'dev' into docs-pena-team

This commit is contained in:
Henry 2024-03-02 17:32:06 +09:00 committed by GitHub
commit fabc279db6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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. <a href
= "https://platform.openai.com/docs/api-reference/chat/create">
Equivalent to OpenAI's create chat completion. </a>
Creates a model response for the given chat conversation. <a href =
"https://platform.openai.com/docs/api-reference/chat/create"> Equivalent
to OpenAI's create chat completion. </a>
requestBody:
content:
application/json:
schema:
$ref: specs/chat.yaml#/components/schemas/ChatCompletionRequest
responses:
"200":
'200':
description: OK
content:
application/json:
@ -93,6 +93,110 @@ paths:
"temperature": 0.7,
"top_p": 0.95
}'
- lang: JavaScript
source: |-
const data = {
messages: [
{
content: 'You are a helpful assistant.',
role: 'system'
},
{
content: 'Hello!',
role: 'user'
}
],
model: 'tinyllama-1.1b',
stream: true,
max_tokens: 2048,
stop: ['hello'],
frequency_penalty: 0,
presence_penalty: 0,
temperature: 0.7,
top_p: 0.95
};
fetch('http://localhost:1337/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data));
- lang: Node.js
source: |-
const fetch = require('node-fetch');
const data = {
messages: [
{
content: 'You are a helpful assistant.',
role: 'system'
},
{
content: 'Hello!',
role: 'user'
}
],
model: 'tinyllama-1.1b',
stream: true,
max_tokens: 2048,
stop: ['hello'],
frequency_penalty: 0,
presence_penalty: 0,
temperature: 0.7,
top_p: 0.95
};
fetch('http://localhost:1337/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data));
- lang: Python
source: >-
import requests
import json
data = {
"messages": [
{
"content": "You are a helpful assistant.",
"role": "system"
},
{
"content": "Hello!",
"role": "user"
}
],
"model": "tinyllama-1.1b",
"stream": true,
"max_tokens": 2048,
"stop": [
"hello"
],
"frequency_penalty": 0,
"presence_penalty": 0,
"temperature": 0.7,
"top_p": 0.95
}
response =
requests.post('http://localhost:1337/v1/chat/completions',
json=data)
print(response.json())
/models:
get:
operationId: listModels
@ -100,12 +204,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. <a href
= "https://platform.openai.com/docs/api-reference/models/list">
Equivalent to OpenAI's list model. </a>
Lists the currently available models, and provides basic information
about each one such as the owner and availability. <a href =
"https://platform.openai.com/docs/api-reference/models/list"> Equivalent
to OpenAI's list model. </a>
responses:
"200":
'200':
description: OK
content:
application/json:
@ -113,11 +217,39 @@ paths:
$ref: specs/models.yaml#/components/schemas/ListModelsResponse
x-codeSamples:
- lang: cURL
source: |
source: |-
curl -X 'GET' \
'http://localhost:1337/v1/models' \
-H 'accept: application/json'
"/models/download/{model_id}":
- lang: JavaScript
source: |-
const response = await fetch('http://localhost:1337/v1/models', {
method: 'GET',
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');
const url = 'http://localhost:1337/v1/models';
const options = {
method: 'GET',
headers: { Accept: 'application/json' }
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json));
/models/download/{model_id}:
get:
operationId: downloadModel
tags:
@ -135,7 +267,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
"200":
'200':
description: OK
content:
application/json:
@ -143,19 +275,49 @@ paths:
$ref: specs/models.yaml#/components/schemas/DownloadModelResponse
x-codeSamples:
- lang: cURL
source: |
source: |-
curl -X 'GET' \
'http://localhost:1337/v1/models/download/{model_id}' \
-H 'accept: application/json'
"/models/{model_id}":
- lang: JavaScript
source: >-
const response = await
fetch('http://localhost:1337/v1/models/download/{model_id}', {
method: 'GET',
headers: {accept: 'application/json'}
});
const data = await response.json();
- lang: Node.js
source: |-
const fetch = require('node-fetch');
fetch('http://localhost:1337/v1/models/download/{model_id}', {
method: 'GET',
headers: {accept: 'application/json'}
})
.then(res => res.json())
.then(data => console.log(data));
- lang: Python
source: >-
import requests
response =
requests.get('http://localhost:1337/v1/models/download/{model_id}',
headers={'accept': 'application/json'})
data = response.json()
/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. <a href =
Get a model instance, providing basic information about the model such
as the owner and permissioning. <a href =
"https://platform.openai.com/docs/api-reference/models/retrieve">
Equivalent to OpenAI's retrieve model. </a>
parameters:
@ -168,7 +330,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
"200":
'200':
description: OK
content:
application/json:
@ -176,10 +338,47 @@ paths:
$ref: specs/models.yaml#/components/schemas/GetModelResponse
x-codeSamples:
- lang: cURL
source: |
source: |-
curl -X 'GET' \
'http://localhost:1337/v1/models/{model_id}' \
-H 'accept: application/json'
- lang: JavaScript
source: |-
const fetch = require('node-fetch');
const modelId = 'mistral-ins-7b-q4';
fetch(`http://localhost:1337/v1/models/${modelId}`, {
method: 'GET',
headers: {'accept': 'application/json'}
})
.then(res => res.json())
.then(json => console.log(json));
- lang: Node.js
source: |-
const fetch = require('node-fetch');
const modelId = 'mistral-ins-7b-q4';
fetch(`http://localhost:1337/v1/models/${modelId}`, {
method: 'GET',
headers: {'accept': 'application/json'}
})
.then(res => res.json())
.then(json => console.log(json));
- lang: Python
source: >-
import requests
model_id = 'mistral-ins-7b-q4'
response =
requests.get(f'http://localhost:1337/v1/models/{model_id}',
headers={'accept': 'application/json'})
print(response.json())
delete:
operationId: deleteModel
tags:
@ -199,7 +398,7 @@ paths:
description: |
The model id to delete
responses:
"200":
'200':
description: OK
content:
application/json:
@ -207,10 +406,45 @@ paths:
$ref: specs/models.yaml#/components/schemas/DeleteModelResponse
x-codeSamples:
- lang: cURL
source: |
source: |-
curl -X 'DELETE' \
'http://localhost:1337/v1/models/{model_id}' \
-H 'accept: application/json'
- lang: JavaScript
source: |-
const fetch = require('node-fetch');
const modelId = 'mistral-ins-7b-q4';
fetch(`http://localhost:1337/v1/models/${modelId}`, {
method: 'DELETE',
headers: { 'accept': 'application/json' }
})
.then(res => res.json())
.then(json => console.log(json));
- lang: Node.js
source: |-
const fetch = require('node-fetch');
const modelId = 'mistral-ins-7b-q4';
fetch(`http://localhost:1337/v1/models/${modelId}`, {
method: 'DELETE',
headers: { 'accept': 'application/json' }
})
.then(res => res.json())
.then(json => console.log(json));
- lang: Python
source: >-
import requests
model_id = 'mistral-ins-7b-q4'
response =
requests.delete(f'http://localhost:1337/v1/models/{model_id}',
headers={'accept': 'application/json'})
/threads:
post:
operationId: createThread
@ -228,7 +462,7 @@ paths:
schema:
$ref: specs/threads.yaml#/components/schemas/CreateThreadObject
responses:
"200":
'200':
description: Thread created successfully
content:
application/json:
@ -257,7 +491,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 +519,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 +539,7 @@ paths:
description: |
The ID of the thread to retrieve.
responses:
"200":
'200':
description: Thread details retrieved successfully
content:
application/json:
@ -345,7 +579,7 @@ paths:
items:
$ref: specs/threads.yaml#/components/schemas/ThreadMessageObject
responses:
"200":
'200':
description: Thread modified successfully
content:
application/json:
@ -384,7 +618,7 @@ paths:
description: |
The ID of the thread to be deleted.
responses:
"200":
'200':
description: Thread deleted successfully
content:
application/json:
@ -405,7 +639,7 @@ paths:
"https://platform.openai.com/docs/api-reference/assistants/listAssistants">
Equivalent to OpenAI's list assistants. </a>
responses:
"200":
'200':
description: List of assistants retrieved successfully
content:
application/json:
@ -445,7 +679,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 +699,19 @@ 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: |
curl http://localhost:1337/v1/assistants/{assistant_id} \
-H "Content-Type: application/json" \
"/threads/{thread_id}/messages":
/threads/{thread_id}/messages:
get:
operationId: listMessages
tags:
@ -495,7 +730,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 +782,7 @@ paths:
- role
- content
responses:
"200":
'200':
description: Message created successfully
content:
application/json:
@ -562,7 +797,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 +824,7 @@ paths:
description: |
The ID of the message to retrieve.
responses:
"200":
'200':
description: OK
content:
application/json:
@ -598,8 +833,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 +856,9 @@ x-webhooks:
post:
summary: The assistant object
description: >
Build assistants that can call models and use tools to perform
tasks. <a href =
"https://platform.openai.com/docs/api-reference/assistants"> Equivalent
to OpenAI's assistants object. </a>
Build assistants that can call models and use tools to perform tasks.
<a href = "https://platform.openai.com/docs/api-reference/assistants">
Equivalent to OpenAI's assistants object. </a>
operationId: AssistantObjects
tags:
- Assistants
@ -651,7 +885,8 @@ x-webhooks:
ThreadObject:
post:
summary: The thread object
description: Represents a thread that contains messages. <a href =
description: >-
Represents a thread that contains messages. <a href =
"https://platform.openai.com/docs/api-reference/threads/object">
Equivalent to OpenAI's thread object. </a>
operationId: ThreadObject