steven-tey / chathn Goto Github PK
View Code? Open in Web Editor NEWChat with Hacker News using natural language. Built with OpenAI Functions and Vercel AI SDK.
Home Page: https://chathn.vercel.app
License: MIT License
Chat with Hacker News using natural language. Built with OpenAI Functions and Vercel AI SDK.
Home Page: https://chathn.vercel.app
License: MIT License
I get this error as soon as I send a message:
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.
The POST method call to URL: https://chathn-rosy.vercel.app/api/chat
with the Payload: {
"role": "user",
"content": "Get me the top 5 stories on Hacker News in markdown table format. Use columns like title, link, score, and comments."
}
Fails, this fails with any message
I also changed the OPENAI API KEY to a recently generated one.
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/[email protected][email protected][email protected]/node_modules/next/dist/esm/server/future/route-modules/app-route/module.js:210:36)
On nextjs 13.4.7 (and above), this app will not compile/build successfully when using npm run build
, however works in it works when in local dev mode, and works when deploying via one click to Vercel from the (templates)[https://vercel.com/templates] page.
It appears to be related to CompletionCreateParams
which is being used/imported in the api/chat/functions.ts
file. The linter error states that this has been deprecated and to use ChatCompletionCreateParams
instead .. which I tried, and that successfully makes linter errors go away ... however then I get this error at build time:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.