diff --git a/src/index.ts b/src/index.ts index 1537c3e..58a3f24 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,6 @@ import { ModelsAPI } from "./models-api.js"; const server = createServer(async (request, response) => { if (request.method === "GET") { - // health check response.statusCode = 200; response.end(`OK`); return; @@ -90,14 +89,18 @@ const server = createServer(async (request, response) => { console.time("tool-call"); const toolCaller = await capiClient.chat.completions.create({ + // @ts-expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m messages: toolCallMessages, stream: false, model: "gpt-4", tools: functions.map((f) => f.tool), - }) + }); console.timeEnd("tool-call"); - const [functionToCall] = getFunctionCalls(toolCaller) + const [functionToCall] = getFunctionCalls( + // @ts-expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m + toolCaller.choices[0].message + ) if ( !functionToCall @@ -107,6 +110,8 @@ const server = createServer(async (request, response) => { const stream = await capiClient.chat.completions.create({ stream: true, model: "gpt-4", + // @ts-expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m + messages: payload.messages, }); for await (const chunk of stream) { @@ -133,7 +138,11 @@ const server = createServer(async (request, response) => { console.log("\t with args", args); const func = new funcClass(modelsAPI); - functionCallRes = await func.execute(payload.messages, args); + functionCallRes = await func.execute( + // @ts-expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m + payload.messages, + args + ); } catch (err) { console.error(err); response.statusCode = 500