steven-tey/chathn

Cannot read properties of undefined (reading 'function_call')

sentenza opened this issue · 4 comments

I constantly get this error on Vercel:

TypeError: Cannot read properties of undefined (reading 'function_call')
    at (app/api/chat/route.ts:57:29)
    at (node_modules/.pnpm/next@13.4.7_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/future/route-modules/app-route/module.js:210:36)

The error is happening here: https://github.com/steven-tey/chathn/blob/main/app/api/chat/route.ts#L57

That's probably cause you're not using the right OPENAI_API_KEY? i.e. the first response is returning error and hence the message is undefined

The error is happening here: https://github.com/steven-tey/chathn/blob/main/app/api/chat/route.ts#L57

That's probably cause you're not using the right OPENAI_API_KEY? i.e. the first response is returning error and hence the message is undefined

I've just checked the Environment Variables section on my Vercel project and the key seems correctly defined under OPENAI_API_KEY generated via https://platform.openai.com/account/api-keys. I don't see what else I should do.

jbbae commented

I faced this same issue, and got it fixed by changing the ".env.example" filename to ".env.local".

@jbbae's suggestion should fix this! Closing this for now!