Merge pull request #660 from janhq/add-methods

docs: Add model methods to swagger
This commit is contained in:
Daniel 2023-11-19 23:39:14 +08:00 committed by GitHub
commit 53fec0563c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2309,6 +2309,7 @@ paths:
] ]
} }
# Models
/models: /models:
get: get:
operationId: listModels operationId: listModels
@ -2374,6 +2375,61 @@ paths:
], ],
"object": "list" "object": "list"
} }
post:
operationId: importModel
tags:
- Models
summary: Import Model
description: Imports a model instance. The model can be from a local folder, remote source, or an API endpoint. The model importer will examine the source_url for formatting.
parameters:
- in: path
name: source_url
required: true
schema:
type: string
# ideally this will be an actual ID, so this will always work from browser
example: https://huggingface.com/thebloke/example.gguf
description: The ID of the model to use for this request
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Model"
x-oaiMeta:
name: Import model
returns: The [model](/docs/api-reference/models/object) object matching the specified ID.
examples:
request:
curl: |
curl https://api.openai.com/v1/models/VAR_model_id \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
from openai import OpenAI
client = OpenAI()
client.models.retrieve("VAR_model_id")
node.js: |-
import OpenAI from "openai";
const openai = new OpenAI();
async function main() {
const model = await openai.models.retrieve("gpt-3.5-turbo");
console.log(model);
}
main();
response: &retrieve_model_response |
{
"id": "VAR_model_id",
"object": "model",
"created": 1686935002,
"owned_by": "openai",
"state": "ready"
}
/models/{model}: /models/{model}:
get: get:
operationId: retrieveModel operationId: retrieveModel
@ -2481,6 +2537,70 @@ paths:
"object": "model", "object": "model",
"deleted": true "deleted": true
} }
post:
operationId: startModel
tags:
- Models
summary: Start Model
description: Starts an imported model. Loads the model into V/RAM.
parameters:
- in: path
name: model
required: true
schema:
type: string
# ideally this will be an actual ID, so this will always work from browser
example: gpt-3.5-turbo
description: The ID of the model to use for this request
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Model"
x-oaiMeta:
name: Import model
returns: The [model](/docs/api-reference/models/object) object matching the specified ID.
examples:
response: &retrieve_model_response |
{
"id": "VAR_model_id",
"object": "model",
"created": 1686935002,
"owned_by": "openai"
}
/models/{model}/stop:
post:
operationId: stopModel
tags:
- Models
summary: Stop Model
description: Stops a running model. Unloads the model from V/RAM.
parameters:
- in: path
name: model
required: true
schema:
type: string
description: The ID of the model that is running.
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/RunObject"
x-oaiMeta:
name: Stop a running model
beta: true
returns: The modified [run](/docs/api-reference/runs/object) object matching the specified ID.
examples:
request:
response: |
{
"todo": "run_BeRGmpGt2wb1VI22ZRniOkrR"
}
/moderations: /moderations:
post: post:
@ -3062,6 +3182,7 @@ paths:
"deleted": true "deleted": true
} }
# Threads
/threads: /threads:
post: post:
operationId: createThread operationId: createThread
@ -7333,14 +7454,14 @@ components:
format: uri format: uri
example: https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/blob/main/zephyr-7b-beta.Q4_K_M.gguf example: https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/blob/main/zephyr-7b-beta.Q4_K_M.gguf
description: The model download source. It can be an external url or a local filepath. description: The model download source. It can be an external url or a local filepath.
id: # OpenAI-equivalent id: # OpenAI-equivalent
type: string type: string
description: The model identifier, which can be referenced in the API endpoints. description: The model identifier, which can be referenced in the API endpoints.
example: zephyr-7b example: zephyr-7b
name: name:
type: string type: string
description: Human-readable name that is used for UI description: Human-readable name that is used for UI
owned_by: # OpenAI-equivalent owned_by: # OpenAI-equivalent
type: string type: string
description: The organization that owns the model (you!) description: The organization that owns the model (you!)
default: you # TODO default: you # TODO
@ -7389,15 +7510,16 @@ components:
type: string type: string
description: TODO description: TODO
default: "ASSISTANT:" default: "ASSISTANT:"
default: { default:
ctx_len: 2048, {
ngl: 100, ctx_len: 2048,
embedding: true, ngl: 100,
n_parallel: 4, embedding: true,
pre_prompt: "A chat between a curious user and an artificial intelligence", n_parallel: 4,
user_prompt: "USER:", pre_prompt: "A chat between a curious user and an artificial intelligence",
ai_prompt: "ASSISTANT:" user_prompt: "USER:",
} ai_prompt: "ASSISTANT:",
}
runtime: runtime:
type: object type: object
properties: properties:
@ -7421,19 +7543,20 @@ components:
type: string type: string
description: TODO description: TODO
default: true default: true
default: { default:
temperature: 0.7, {
token_limit: 2048, temperature: 0.7,
top_k: 0, token_limit: 2048,
top_p: 1, top_k: 0,
stream: true top_p: 1,
} stream: true,
}
metadata: metadata:
type: object type: object
properties: properties:
engine: engine:
type: string type: string
enum: [llamacpp, api,tensorrt] enum: [llamacpp, api, tensorrt]
default: llamacpp default: llamacpp
quantization: quantization:
type: string type: string
@ -7446,19 +7569,15 @@ components:
type: array type: array
description: TODO description: TODO
default: TODO default: TODO
default: { default:
engine: llamacpp, { engine: llamacpp, quantization: Q4_K_M, size: 7b, binaries: TODO }
quantization: Q4_K_M,
size: 7b,
binaries: TODO
}
required: required:
- id # From OpenAI - id # From OpenAI
- version - version
- source_url - source_url
- created # From OpenAI, autogenerated in Jan - created # From OpenAI, autogenerated in Jan
- object # From OpenAI, autogenerated in Jan - object # From OpenAI, autogenerated in Jan
- owned_by # From OpenAI, autogenerated in Jan - owned_by # From OpenAI, autogenerated in Jan
x-oaiMeta: x-oaiMeta:
name: The model object name: The model object
example: *retrieve_model_response example: *retrieve_model_response