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: 'end' When Accessing Solution Node in LATS Example Notebook #287

Closed
4 tasks done
rohan-uiuc opened this issue Apr 8, 2024 · 3 comments · Fixed by #469
Closed
4 tasks done

KeyError: 'end' When Accessing Solution Node in LATS Example Notebook #287

rohan-uiuc opened this issue Apr 8, 2024 · 3 comments · Fixed by #469

Comments

@rohan-uiuc
Copy link

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

https://github.com/langchain-ai/langgraph/blob/main/examples/lats/lats.ipynb

Error Message and Stack Trace (if applicable)

KeyError                                  Traceback (most recent call last)
[<ipython-input-24-79f0af4b7fd6>](https://localhost:8080/#) in <cell line: 1>()
----> 1 solution_node = step["__end__"]["root"].get_best_solution()
      2 best_trajectory = solution_node.get_trajectory(include_reflections=False)
      3 print(best_trajectory[-1].content)

KeyError: '__end__'

Description

While running the LATS example notebook available at langchain-ai/langgraph/examples/lats/lats.ipynb, I encountered a KeyError when trying to access the solution node using step["__end__"]["root"].get_best_solution(). This error occurs at the end of the notebook, specifically in the cells where the graph stream is being processed to extract the best solution node.

This issue prevents the completion of the example notebook and the extraction of the best solution node for the given questions. Any guidance or fixes would be greatly appreciated.

System Info

langchain==0.1.14
langchain-community==0.0.31
langchain-core==0.1.40
langchain-experimental==0.0.56
langchain-openai==0.1.1
langchain-text-splitters==0.0.1
langchainhub==0.1.15

@rakataprime
Copy link

#247 removes the end key and breaks the lats notebook. if you revert to an earlier commit or version 0.0.26, you can run the notebook

@rohan-uiuc
Copy link
Author

Hi @rakataprime , thanks for responding. I have downgraded langgraph version to 0.0.26 and it works. Is there a permanent fix(proposed) for the newer versions?

@TVScoundrel
Copy link

Instead of using the last step, you could use the step_state like this for the solution (if any)

solution_node = step_state["root"].get_best_solution()
best_trajectory = solution_node.get_trajectory(include_reflections=False)
print(best_trajectory[-1].content)

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

Successfully merging a pull request may close this issue.

3 participants