File tree Expand file tree Collapse file tree 3 files changed +17
-20
lines changed
packages/openai-adapters/src/apis Expand file tree Collapse file tree 3 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ function testLLM(
145145 description : "Say Hello" ,
146146 parameters : {
147147 type : "object" ,
148+ required : [ "name" ] ,
148149 properties : {
149150 name : {
150151 type : "string" ,
@@ -165,7 +166,7 @@ function testLLM(
165166 } ,
166167 ) ) {
167168 const typedChunk = chunk as AssistantChatMessage ;
168- if ( ! typedChunk . toolCalls ) {
169+ if ( ! typedChunk . toolCalls || typedChunk . toolCalls . length === 0 ) {
169170 continue ;
170171 }
171172 const toolCall = typedChunk . toolCalls [ 0 ] ;
Original file line number Diff line number Diff line change @@ -190,24 +190,20 @@ export function fromChatCompletionChunk(
190190 content : delta . content ,
191191 } ;
192192 } else if ( delta ?. tool_calls ) {
193- const toolCalls = delta ?. tool_calls
194- . filter ( ( tool_call ) => tool_call . type === "function" )
195- . map ( ( tool_call ) => ( {
196- id : tool_call . id ,
197- type : "function" as const ,
198- function : {
199- name : ( tool_call as any ) . function ?. name ,
200- arguments : ( tool_call as any ) . function ?. arguments ,
201- } ,
202- } ) ) ;
203-
204- if ( toolCalls . length > 0 ) {
205- return {
206- role : "assistant" ,
207- content : "" ,
208- toolCalls,
209- } ;
210- }
193+ return {
194+ role : "assistant" ,
195+ content : "" ,
196+ toolCalls : delta ?. tool_calls
197+ . filter ( ( tool_call ) => ! tool_call . type || tool_call . type === "function" )
198+ . map ( ( tool_call ) => ( {
199+ id : tool_call . id ,
200+ type : "function" as const ,
201+ function : {
202+ name : ( tool_call as any ) . function ?. name ,
203+ arguments : ( tool_call as any ) . function ?. arguments ,
204+ } ,
205+ } ) ) ,
206+ } ;
211207 }
212208
213209 return undefined ;
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export class AzureApi extends OpenAIApi {
1919 const { baseURL, defaultQuery } = this . _getAzureBaseURL ( azureConfig ) ;
2020
2121 this . openai = new OpenAI ( {
22- apiKey : azureConfig . apiKey ?? "" ,
22+ apiKey : azureConfig . apiKey ,
2323 baseURL,
2424 fetch : customFetch ( azureConfig . requestOptions ) ,
2525 defaultQuery,
You can’t perform that action at this time.
0 commit comments