Skip to content

Commit

Permalink
Update route.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
berkingurcan committed Aug 6, 2024
1 parent 233a83b commit 09c459b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/api/talhasearch/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ export async function POST(req: Request) {
const response = await openai.chat.completions.create({
model: model,
messages,
functions: [demoSearchToolRunnable.function],
function_call: { name: 'demo_search_for_thread' },
tools: [demoSearchToolRunnable.function],
tool_choice: {"type": "function", "function": {"name": demoSearchToolRunnable.function.name}},
});

const functionOutput = response.data.choices[0].message?.function_call?.arguments;
return functionOutput ? JSON.parse(functionOutput) : 'No results found';
return response
} else {
return NextResponse.json(
{ error: 'OPENAI API KEY NOT FOUND' },
Expand Down

0 comments on commit 09c459b

Please sign in to comment.