Add pages

add-more-languages
Meng Zhang 2023-04-06 18:48:26 +08:00
parent 07b3ce53c9
commit 53c77c4609
3 changed files with 217 additions and 0 deletions

View File

@ -7,6 +7,7 @@ on:
paths-ignore:
- '**/README.md'
- '.github/**'
- 'docs/**'
pull_request:
branches: [ "main" ]

30
docs/index.html Normal file
View File

@ -0,0 +1,30 @@
<html>
<head>
<!-- Load the latest Swagger UI code and style from npm using unpkg.com -->
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css"/>
<title>Text Generation Inference API</title>
</head>
<body>
<div id="swagger-ui"></div> <!-- Div to hold the UI component -->
<script>
window.onload = function () {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "openapi.json", //Location of Open API spec in the repo
dom_id: '#swagger-ui',
deepLinking: true,
supportedSubmitMethods: [],
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
})
window.ui = ui
}
</script>
</body>
</html>

186
docs/openapi.json Normal file
View File

@ -0,0 +1,186 @@
{
"openapi": "3.0.2",
"info": {
"title": "TabbyServer",
"description": "TabbyServer is the backend for tabby, serving code completion requests from code editor / IDE.\n*",
"version": "0.1.0"
},
"paths": {
"/v1/completions": {
"post": {
"summary": "Completions",
"operationId": "completions_v1_completions_post",
"requestBody": {
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CompletionRequest" }
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CompletionResponse" }
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/HTTPValidationError" }
}
}
}
}
}
},
"/v1/events": {
"post": {
"summary": "Events",
"operationId": "events_v1_events_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"title": "E",
"anyOf": [
{ "$ref": "#/components/schemas/ChoiceEvent" },
{ "$ref": "#/components/schemas/CompletionEvent" }
]
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": { "application/json": { "schema": {} } }
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/HTTPValidationError" }
}
}
}
}
}
}
},
"components": {
"schemas": {
"Choice": {
"title": "Choice",
"required": ["index", "text"],
"type": "object",
"properties": {
"index": { "title": "Index", "type": "integer" },
"text": { "title": "Text", "type": "string" }
}
},
"ChoiceEvent": {
"title": "ChoiceEvent",
"required": ["type", "completion_id", "choice_index"],
"type": "object",
"properties": {
"type": { "$ref": "#/components/schemas/EventType" },
"completion_id": { "title": "Completion Id", "type": "string" },
"choice_index": { "title": "Choice Index", "type": "integer" }
}
},
"CompletionEvent": {
"title": "CompletionEvent",
"required": ["type", "id", "language", "prompt", "created", "choices"],
"type": "object",
"properties": {
"type": { "$ref": "#/components/schemas/EventType" },
"id": { "title": "Id", "type": "string" },
"language": { "$ref": "#/components/schemas/Language" },
"prompt": { "title": "Prompt", "type": "string" },
"created": { "title": "Created", "type": "integer" },
"choices": {
"title": "Choices",
"type": "array",
"items": { "$ref": "#/components/schemas/Choice" }
}
}
},
"CompletionRequest": {
"title": "CompletionRequest",
"required": ["prompt"],
"type": "object",
"properties": {
"language": {
"allOf": [{ "$ref": "#/components/schemas/Language" }],
"description": "Language for completion request",
"default": "unknown",
"example": "python"
},
"prompt": {
"title": "Prompt",
"type": "string",
"description": "The context to generate completions for, encoded as a string.",
"example": "def binarySearch(arr, left, right, x):\n mid = (left +"
}
}
},
"CompletionResponse": {
"title": "CompletionResponse",
"required": ["id", "created", "choices"],
"type": "object",
"properties": {
"id": { "title": "Id", "type": "string" },
"created": { "title": "Created", "type": "integer" },
"choices": {
"title": "Choices",
"type": "array",
"items": { "$ref": "#/components/schemas/Choice" }
}
}
},
"EventType": {
"title": "EventType",
"enum": ["completion", "view", "select"],
"type": "string",
"description": "An enumeration."
},
"HTTPValidationError": {
"title": "HTTPValidationError",
"type": "object",
"properties": {
"detail": {
"title": "Detail",
"type": "array",
"items": { "$ref": "#/components/schemas/ValidationError" }
}
}
},
"Language": {
"title": "Language",
"enum": ["unknown", "python", "javascript"],
"type": "string",
"description": "An enumeration."
},
"ValidationError": {
"title": "ValidationError",
"required": ["loc", "msg", "type"],
"type": "object",
"properties": {
"loc": {
"title": "Location",
"type": "array",
"items": { "anyOf": [{ "type": "string" }, { "type": "integer" }] }
},
"msg": { "title": "Message", "type": "string" },
"type": { "title": "Error Type", "type": "string" }
}
}
}
}
}