@@ -12,7 +12,6 @@ import { ModelsAPI } from "./models-api.js";
12
12
13
13
const server = createServer ( async ( request , response ) => {
14
14
if ( request . method === "GET" ) {
15
- // health check
16
15
response . statusCode = 200 ;
17
16
response . end ( `OK` ) ;
18
17
return ;
@@ -90,14 +89,18 @@ const server = createServer(async (request, response) => {
90
89
91
90
console . time ( "tool-call" ) ;
92
91
const toolCaller = await capiClient . chat . completions . create ( {
92
+ // @ts -expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m
93
93
messages : toolCallMessages ,
94
94
stream : false ,
95
95
model : "gpt-4" ,
96
96
tools : functions . map ( ( f ) => f . tool ) ,
97
- } )
97
+ } ) ;
98
98
console . timeEnd ( "tool-call" ) ;
99
99
100
- const [ functionToCall ] = getFunctionCalls ( toolCaller )
100
+ const [ functionToCall ] = getFunctionCalls (
101
+ // @ts -expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m
102
+ toolCaller . choices [ 0 ] . message
103
+ )
101
104
102
105
if (
103
106
! functionToCall
@@ -107,6 +110,8 @@ const server = createServer(async (request, response) => {
107
110
const stream = await capiClient . chat . completions . create ( {
108
111
stream : true ,
109
112
model : "gpt-4" ,
113
+ // @ts -expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m
114
+ messages : payload . messages ,
110
115
} ) ;
111
116
112
117
for await ( const chunk of stream ) {
@@ -133,7 +138,11 @@ const server = createServer(async (request, response) => {
133
138
134
139
console . log ( "\t with args" , args ) ;
135
140
const func = new funcClass ( modelsAPI ) ;
136
- functionCallRes = await func . execute ( payload . messages , args ) ;
141
+ functionCallRes = await func . execute (
142
+ // @ts -expect-error - type error due to Copilot/OpenAI SDKs interop, I'll look into it ~@gr2m
143
+ payload . messages ,
144
+ args
145
+ ) ;
137
146
} catch ( err ) {
138
147
console . error ( err ) ;
139
148
response . statusCode = 500
0 commit comments