Skip to content

Commit

Permalink
Function call: increase debug verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Jun 7, 2024
1 parent 358d8a5 commit 11c41e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/llms/server/openai/openai.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const llmOpenAIRouter = createTRPCRouter({
.output(llmsChatGenerateWithFunctionsOutputSchema)
.mutation(async ({ input }) => {

const { access, model, history, functions, forceFunctionName } = input;
const { access, model, history, functions, forceFunctionName, context } = input;
const isFunctionsCall = !!functions && functions.length > 0;

const completionsBody = openAIChatCompletionPayload(access.dialect, model, history, isFunctionsCall ? functions : null, forceFunctionName ?? null, 1, false);
Expand All @@ -280,7 +280,7 @@ export const llmOpenAIRouter = createTRPCRouter({

// expect a single output
if (wireCompletions?.choices?.length !== 1) {
console.error(`[POST] llmOpenAI.chatGenerateWithFunctions: ${access.dialect}: unexpected output${forceFunctionName ? ` (fn: ${forceFunctionName})` : ''}:`, wireCompletions?.choices?.length);
console.error(`[POST] llmOpenAI.chatGenerateWithFunctions: ${access.dialect}: ${context?.name || 'no context'}: unexpected output${forceFunctionName ? ` (fn: ${forceFunctionName})` : ''}:`, model.id, wireCompletions?.choices);
throw new TRPCError({
code: 'UNPROCESSABLE_CONTENT',
message: `[OpenAI Issue] Expected 1 completion, got ${wireCompletions?.choices?.length}`,
Expand Down

0 comments on commit 11c41e7

Please sign in to comment.