Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ yarn-error.log*
.env
.env.template
.env.staging
.env.local

# vercel
.vercel
Expand Down
35 changes: 22 additions & 13 deletions src/app/api/chat/openaiFunctionCall/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,28 @@ const conversationToMessages = (
}

async function handler(req: AuthenticatedRequest): Promise<NextResponse> {
const {
conversation,
tools,
openaiKey,
imageUrls = [],
imageDescription = '',
}: {
tools: ChatCompletionTool[]
conversation: Conversation
imageUrls?: string[]
imageDescription?: string
openaiKey: string
} = await req.json()
let conversation: Conversation
let tools: ChatCompletionTool[]
let openaiKey: string
let imageUrls: string[] = []
let imageDescription: string = ''

try {
const body = await req.json()
conversation = body.conversation
tools = body.tools
openaiKey = body.openaiKey
imageUrls = body.imageUrls || []
imageDescription = body.imageDescription || ''

console.log('🔵 Received openaiFunctionCall request with', tools.length, 'tools')
} catch (parseError) {
console.error('❌ Failed to parse request body:', parseError)
return NextResponse.json(
{ error: 'Invalid request body: ' + (parseError instanceof Error ? parseError.message : String(parseError)) },
{ status: 400 }
)
}

// console.log('Received request with openaiKey:', openaiKey)
let decryptedKey = openaiKey
Expand Down
Loading