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

KeyError: 'action' when running langgraph_agentic_rag.ipynb #450

Closed
4 tasks done
cg94301 opened this issue May 14, 2024 · 4 comments
Closed
4 tasks done

KeyError: 'action' when running langgraph_agentic_rag.ipynb #450

cg94301 opened this issue May 14, 2024 · 4 comments

Comments

@cg94301
Copy link

cg94301 commented May 14, 2024

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.

Example Code

Running the exact LangChain notebook form here: https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_agentic_rag.ipynb

The error occurs when running the very last cell:

import pprint

inputs = {
    "messages": [
        ("user", "What does Lilian Weng say about the types of agent memory?"),
    ]
}
for output in graph.stream(inputs):
    for key, value in output.items():
        pprint.pprint(f"Output from node '{key}':")
        pprint.pprint("---")
        pprint.pprint(value, indent=2, width=80, depth=None)
    pprint.pprint("\n---\n")

Error Message and Stack Trace (if applicable)


KeyError Traceback (most recent call last)
Cell In[8], line 8
1 import pprint
3 inputs = {
4 "messages": [
5 ("user", "What does Lilian Weng say about the types of agent memory?"),
6 ]
7 }
----> 8 for output in graph.stream(inputs):
9 for key, value in output.items():
10 pprint.pprint(f"Output from node '{key}':")

File ~/.pyenv/versions/3.11.7/envs/langc2/lib/python3.11/site-packages/langgraph/pregel/init.py:771, in Pregel.stream(self, input, config, stream_mode, output_keys, input_keys, interrupt_before, interrupt_after, debug)
764 done, inflight = concurrent.futures.wait(
765 futures,
766 return_when=concurrent.futures.FIRST_EXCEPTION,
767 timeout=self.step_timeout,
768 )
770 # panic on failure or timeout
--> 771 _panic_or_proceed(done, inflight, step)
773 # combine pending writes from all tasks
774 pending_writes = dequetuple[str, Any]

File ~/.pyenv/versions/3.11.7/envs/langc2/lib/python3.11/site-packages/langgraph/pregel/init.py:1263, in _panic_or_proceed(done, inflight, step)
1261 inflight.pop().cancel()
1262 # raise the exception
-> 1263 raise exc
1264 # TODO this is where retry of an entire step would happen
1266 if inflight:
1267 # if we got here means we timed out

File ~/.pyenv/versions/3.11.7/lib/python3.11/concurrent/futures/thread.py:58, in _WorkItem.run(self)
55 return
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)

File ~/.pyenv/versions/3.11.7/envs/langc2/lib/python3.11/site-packages/langchain_core/runnables/base.py:2499, in RunnableSequence.invoke(self, input, config)
2497 try:
2498 for i, step in enumerate(self.steps):
-> 2499 input = step.invoke(
2500 input,
2501 # mark each step as a child run
2502 patch_config(
2503 config, callbacks=run_manager.get_child(f"seq:step:{i+1}")
2504 ),
2505 )
2506 # finish the root run
2507 except BaseException as e:

File ~/.pyenv/versions/3.11.7/envs/langc2/lib/python3.11/site-packages/langgraph/utils.py:88, in RunnableCallable.invoke(self, input, config)
82 context.run(var_child_runnable_config.set, config)
83 kwargs = (
84 {**self.kwargs, "config": config}
85 if accepts_config(self.func)
86 else self.kwargs
87 )
---> 88 ret = context.run(self.func, input, **kwargs)
89 if isinstance(ret, Runnable) and self.recurse:
90 return ret.invoke(input, config)

File ~/.pyenv/versions/3.11.7/envs/langc2/lib/python3.11/site-packages/langgraph/graph/graph.py:74, in Branch._route(self, input, config, reader, writer)
72 result = [result]
73 if self.ends:
---> 74 destinations = [self.ends[r] for r in result]
75 else:
76 destinations = result

File ~/.pyenv/versions/3.11.7/envs/langc2/lib/python3.11/site-packages/langgraph/graph/graph.py:74, in (.0)
72 result = [result]
73 if self.ends:
---> 74 destinations = [self.ends[r] for r in result]
75 else:
76 destinations = result

KeyError: 'action'

Description

Cannot run the graph from the notebook LangGraph_agentic_rag.ipynb. It fails with KeyError: 'action'.

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030
Python Version: 3.11.7 (main, Apr 4 2024, 12:22:48) [Clang 15.0.0 (clang-1500.3.9.4)]

Package Information

langchain_core: 0.1.52
langchain: 0.1.20
langchain_community: 0.0.38
langsmith: 0.1.57
langchain_openai: 0.1.6
langchain_text_splitters: 0.0.1
langchainhub: 0.1.15
langgraph: 0.0.48

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langserve

@hinthornw
Copy link
Contributor

Looks like I cut the docs release a bit too early - will be fixed in 0.0.49

@hinthornw
Copy link
Contributor

hinthornw commented May 14, 2024

Should be released now. Let me know if the issue persists

@cg94301
Copy link
Author

cg94301 commented May 15, 2024

Works now. Thanks for the quick fix!

@hinthornw
Copy link
Contributor

Will close this then! Thanks for everyone's patience! Want to be quick now to enable long-term stability and usability

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

2 participants