No need to mock models response anymore

This commit is contained in:
johnd0e
2024-07-23 23:58:40 +02:00
parent e4983bc63a
commit 56f10cf248
2 changed files with 7 additions and 26 deletions

View File

@@ -145,6 +145,13 @@ For some command-line tools, you may need to set an environment variable, _e.g._
set OPENAI_API_KEY=ghu_... set OPENAI_API_KEY=ghu_...
``` ```
### Models
The list of available models can be accessed through the standard `/v1/models` endpoint
and may vary depending on the provided API key.
Examples: `gpt-3.5-turbo`, `gpt-4`, `gpt-4-0125-preview`, `gpt-4-o-preview`.
## Tech notes ## Tech notes
@@ -159,6 +166,4 @@ Copilot provides following endpoints:
- Output is not altered in any way, and has some minor differences from OpenAI's: - Output is not altered in any way, and has some minor differences from OpenAI's:
- no `object` property (`"object": "embedding"`) - no `object` property (`"object": "embedding"`)
- no `model` property (`"model": "text-embedding-3-small"`) - no `model` property (`"model": "text-embedding-3-small"`)
- `/v1/models`: Copilot does not provide models list, so it was determined empirically,
and this API endpoint is served with `openai-github-copilot` itself.
- `/token`: serves a Web page that allows you to obtain a Github Copilot access token. - `/token`: serves a Web page that allows you to obtain a Github Copilot access token.

View File

@@ -6,9 +6,6 @@ export default {
return handleOPTIONS(request); return handleOPTIONS(request);
} }
const url = new URL(request.url); const url = new URL(request.url);
if (url.pathname === "/v1/models") {
return handleModels(request);
}
if (url.pathname === "/token") { if (url.pathname === "/token") {
return new Response(token_html, { return new Response(token_html, {
headers: { "Content-Type": "text/html" } headers: { "Content-Type": "text/html" }
@@ -51,27 +48,6 @@ export default {
} }
}; };
const handleModels = async () => {
const data = {
"object": "list",
"data": [
//{"id": "text-embedding-3-large", "object": "model", "created": 1705953180, "owned_by": "system"},
{"id": "text-embedding-3-small", "object": "model", "created": 1705948997, "owned_by": "system"},
{"id": "text-embedding-ada-002", "object": "model", "created": 1671217299, "owned_by": "openai-internal"},
{"id": "gpt-3.5-turbo", "object": "model", "created": 1677610602, "owned_by": "openai"},
{"id": "gpt-4", "object": "model", "created": 1687882411, "owned_by": "openai"},
]
};
const json = JSON.stringify(data, null, 2);
return new Response(json, {
headers: {
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/json",
"X-Robots-Tag": "noindex",
},
});
};
const handleOPTIONS = async () => { const handleOPTIONS = async () => {
return new Response(null, { return new Response(null, {
headers: { headers: {