Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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: 'chart_generator' when i run multi-agent-collaboration.ipynb with gpt-3.5-turbo-1106 #437

Closed
4 tasks done
chuangzhidan opened this issue May 13, 2024 · 1 comment

Comments

@chuangzhidan
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

llm = ChatOpenAI(model="gpt-3.5-turbo-1106")
i used aboved instead of gpt4 like the one showed in the example script ,everything else is the same.

Error Message and Stack Trace (if applicable)

{'Researcher': {'messages': [AIMessage(content='I have gathered the GDP data for the UK over the past 5 years. Here are the GDP values for each year:\n\n- 2017: $2,622.43 billion\n- 2018: $2,651.38 billion\n- 2019: $2,636.29 billion\n- 2020: $2,663.99 billion\n- 2
021: $3,141.51 billion\n\nI will now proceed to create a line graph to visualize this data.', additional_kwargs={'tool_calls': [{'id': 'call_xXe0sgFx0bVlUYOKUhh8p02Q', 'function': {'arguments': '{\n "data": {\n "x": ["2017", "2018", "2019", "2020", "2021"],\n
"y": [2622.43, 2651.38, 2636.29, 2663.99, 3141.51]\n },\n "type": "line",\n "title": "UK GDP Over the Past 5 Years",\n "xLabel": "Year",\n "yLabel": "GDP (in billion USD)"\n}', 'name': 'chart_generator'}, 'type': 'function'}]}, response_metadata={'token_us
age': {'completion_tokens': 220, 'prompt_tokens': 12216, 'total_tokens': 12436}, 'model_name': 'gpt-3.5-turbo-1106', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, name='Researcher', id='run-cb9ac178-2b55-4aa4-9a14-c9adeb6582ba-0', t
ool_calls=[{'name': 'chart_generator', 'args': {'data': {'x': ['2017', '2018', '2019', '2020', '2021'], 'y': [2622.43, 2651.38, 2636.29, 2663.99, 3141.51]}, 'type': 'line', 'title': 'UK GDP Over the Past 5 Years', 'xLabel': 'Year', 'yLabel': 'GDP (in billion USD)'
output = self.tools_by_name[call["name"]].invoke(call["args"], config)
KeyError: 'chart_generator'

KeyError: 'chart_generator'

Description

it always failed the halfway,whichi is really annoying

System Info

langchainhub 0.1.15
langchain 0.1.17
langchain-text-splitters 0.0.1
langchain-openai 0.1.1
langchain-experimental 0.0.58
langchain-core 0.1.52
langchain-community 0.0.37

@hinthornw
Copy link
Contributor

If your model is hallucinating tools, then either update your prompt to reduce the frequency of such hallucinations, or add a fallback to handle errors like this an have it automatically handle afterwards.

The fallback would basically be to append a tool message with the invocation's ID saying that you as the bot don't have access. An example of this is in the customer support bot tutorial: https://langchain-ai.github.io/langgraph/tutorials/customer-support/customer-support/#utilities

@langchain-ai langchain-ai locked and limited conversation to collaborators May 15, 2024
@hinthornw hinthornw converted this issue into discussion #459 May 15, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants