langchain-ai / langgraphjs

⚡ Build language agents as graphs ⚡
https://langchain-ai.github.io/langgraphjs/
MIT License
493 stars 71 forks source link

Corrective RAG fails with error 422 when tavily web search is needed #381

Open n30tri8 opened 3 weeks ago

n30tri8 commented 3 weeks ago

I am running the code in a node env using node --env-file .env --import=tsx src/corrective-RAG.ts.

Normal flow when retrieved docs are relevant work with no error. When it goes for a web search, I get the error: Error: Request failed with status code 422: undefined

It seems after transforming query, the new query is not received correctly in function call const docs = await tool.invoke({query: state.question});. When I debug it, it shows the query arg is null, hence Tavily tool call results in that exception.

I also tried compiling with tsc, the same happended.

bracesproul commented 3 weeks ago

@n30tri8 are you talking about this notebook? examples/rag/langgraph_crag.ipynb

If so, i would assume it's an issue with your API keys or something simliar, I just ran the notebook and it worked as expected (langsmith trace)

n30tri8 commented 3 weeks ago

Yes, I am trying to get this code running. As I saw in your langsmith trace, you asked for information that was available in the context; hence, RAG find relevant information and does not trigger web-search tool call. Can you try to ask for information not available in the online blog. I tried with "When did human land on moon?"

I can call tavily api search with my API key. I get error code 422, which is consistent with the fact that tavily API is called with empty argument query.