Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error- Cannot read properties of undefined (reading '0') #1

Open
brinrbc opened this issue May 5, 2023 · 3 comments
Open

Error- Cannot read properties of undefined (reading '0') #1

brinrbc opened this issue May 5, 2023 · 3 comments

Comments

@brinrbc
Copy link

brinrbc commented May 5, 2023

Hi! Thank you very much for your work.
Please tell me which way to look. When I start, I get this error, I see the problem, but I can't figure out what to do.

How can I help? Who is Neil Armstrong?
file:///User/GitHub/langchain-mini/index.mjs:59
    .then((res) => res.choices[0].text)
                              ^

TypeError: Cannot read properties of undefined (reading '0')
    at file:///User/GitHub/langchain-mini/index.mjs:59:31
    at process.process Ticks And Rejection (node:internal/process/task_queues:95:5)
    at asynccomplete Prompt (file:///User/GitHub/langchain-mini/index.mjs:43:3)
    at async answer Question (file:///User/GitHub/langchain-mini/index.mjs:77:22)
    at async file:///User/GitHub/langchain-mini/index.mjs:109:18

Node.js v18.15.0

The line index.mjs:59 says .then((res) => res.choices[0].text)

@MikeRalphson
Copy link

Do you have a SERPAPI_API_KEY defined in your .env file?

@ColinEberhardt
Copy link
Owner

Hi @brinrbc - thanks for raising this issue. This project is intended for educational purposes, to help you learn how to create 'chain of reasoning' applications with LLM. It isn't designed to be production ready. As a result, the code lacks any error checking :-)

This is your opportunity to learn! Clearly the OpenAI API has not returned the expected result. I'd recommend adding a console.log or breakpoint at that line of code to find out what it returned instead. It will likely be an error message (perhaps a lack of API as @MikeRalphson pointed out), that you can then debug.

@brinrbc
Copy link
Author

brinrbc commented May 8, 2023

Do you have a SERPAPI_API_KEY defined in your .env file?

if we are talking about this Api key 2996****...***3f96df from this address https://serpapi.com/manage-api-key , then yes, it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants