File tree Expand file tree Collapse file tree
src/routes/chat-completions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export async function handleCompletion(c: Context) {
1818 await checkRateLimit ( state )
1919
2020 let payload = await c . req . json < ChatCompletionsPayload > ( )
21+ consola . debug ( "Request payload:" , JSON . stringify ( payload ) )
2122
2223 consola . info ( "Current token count:" , getTokenCount ( payload . messages ) )
2324
@@ -32,16 +33,20 @@ export async function handleCompletion(c: Context) {
3233 ...payload ,
3334 max_tokens : selectedModel ?. capabilities . limits . max_output_tokens ,
3435 }
36+ consola . debug ( "Set max_tokens to:" , JSON . stringify ( payload . max_tokens ) )
3537 }
3638
3739 const response = await createChatCompletions ( payload )
3840
3941 if ( isNonStreaming ( response ) ) {
42+ consola . debug ( "Non-streaming response:" , JSON . stringify ( response ) )
4043 return c . json ( response )
4144 }
4245
46+ consola . debug ( "Streaming response" )
4347 return streamSSE ( c , async ( stream ) => {
4448 for await ( const chunk of response ) {
49+ consola . debug ( "Streaming chunk:" , JSON . stringify ( chunk ) )
4550 await stream . writeSSE ( chunk as SSEMessage )
4651 }
4752 } )
You can’t perform that action at this time.
0 commit comments