Error Cannot read properties of undefined (reading 'function_call')
let finalResponse;
> if (initialResponseMessage.function_call) {
^ (this arrow is at the dot between these words)
58 | const { name, arguments: args } = initialResponseMessage.function_call;
59 | const functionResponse = await runFunction(name, JSON.parse(args));
Unhandled Runtime Error
Error: <!DOCTYPE html><html><head><meta charSet="utf-8"/><link rel="preload" as="script"
href="/_next/static/chunks/webpack.js?ts=1691270902524"/><link rel="preload" as="script"
href="/_next/static/chunks/main.js?ts=1691270902524"/><link rel="preload" as="script"
href="/_next/static/chunks/pages/_app.js?ts=1691270902524"/><link rel="preload" as="script"
href="/_next/static/chunks/pages/_error.js?ts=1691270902524"/><link rel="preload" as="script"
href="/_next/static/development/_buildManifest.js?ts=1691270902524"/><link rel="preload" as="script"
href="/_next/static/development/_ssgManifest.js?ts=1691270902524"/><link rel="preload" as="script"
href="/_next/static/chunks/react-refresh.js?ts=1691270902524"/><meta name="viewport" content="width=device-width"/>
<meta name="next-head-count" content="2"/><style data-next-hide-fouc="true">body{display:none}</style><noscript data-
next-hide-fouc="true"><style>body{display:block}</style></noscript><noscript data-n-css=""></noscript><script defer=""
noModule="" src="/_next/static/chunks/polyfills.js?ts=1691270902524"></script><script src="/_next/static/chunks/webpack.js?
ts=1691270902524" defer=""></script><script src="/_next/static/chunks/main.js?ts=1691270902524" defer=""></script>
<script src="/_next/static/chunks/pages/_app.js?ts=1691270902524" defer=""></script><script
src="/_next/static/chunks/pages/_error.js?ts=1691270902524" defer=""></script><script
src="/_next/static/development/_buildManifest.js?ts=1691270902524" defer=""></script><script
src="/_next/static/development/_ssgManifest.js?ts=1691270902524" defer=""></script><noscript
id="__next_css__DO_NOT_USE__"></noscript></head><body><div id="__next"></div><script
src="/_next/static/chunks/react-refresh.js?ts=1691270902524"></script><script id="__NEXT_DATA__"
type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":
{"__NEXT_PAGE":"/api/chat"},"buildId":"development","isFallback":false,"err":{"name":"TypeError","source":"edge-
server","message":"Cannot read properties of undefined (reading 'function_call')","stack":"TypeError: Cannot read properties of
undefined (reading 'function_call')\n at POST (webpack-internal:///(sc_server)/./app/api/chat/route.ts:35:32)\n at
process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async eval (webpack-
internal:///(sc_server)/./node_modules/.pnpm/[email protected]_react-
[email protected][email protected]/node_modules/next/dist/esm/server/future/route-modules/app-
route/module.js:229:37)"},"gip":true,"scriptLoader":[]}</script></body></html>
My env file is setup properly and I've tried renaming it to .env.local too but it doesn't work.