run-llama / llama-hub

A library of data loaders for LLMs made by the community -- to be used with LlamaIndex and/or LangChain
https://llamahub.ai/
MIT License
3.43k stars 728 forks source link

[Bug]: WikipediaToolSpec--BadRequestError: Error code: 400 #879

Open Alina-Luo opened 6 months ago

Alina-Luo commented 6 months ago

Bug Description

Version 1: BadRequestError: Error code: 400 - {'error': {'message': "This model's maximum context length is 4097 tokens. However, your messages resulted in 13509 tokens (13312 in the messages, 197 in the functions). Please reduce the length of the messages or functions.", 'type': 'invalid_request_error', 'param': 'messages', 'code': 'context_length_exceeded'}}

Version 2: (verbose=True)

Added user message to memory: Who is Ben Afflecks spouse? === Calling Function === Calling function: search_data with args: { "query": "Ben Affleck spouse" } Got output: Error: 'str' object has no attribute 'get_doc_id'

=== Calling Function === Calling function: search_data with args: { "query": "Ben Affleck spouse" } Got output: Error: 'str' object has no attribute 'get_doc_id'

...

Version

0.0.74

Steps to Reproduce

Version 1: from llama_hub.tools.wikipedia import WikipediaToolSpec from llama_index.agent import OpenAIAgent

tool_spec = WikipediaToolSpec()

agent = OpenAIAgent.from_tools(tool_spec.to_tool_list())

agent.chat('Who is Ben Afflecks spouse?')

Version 2: from llama_hub.tools.wikipedia.base import WikipediaToolSpec from llama_index.tools.tool_spec.load_and_search import LoadAndSearchToolSpec

wiki_spec = WikipediaToolSpec() tool = wiki_spec.to_tool_list()[1]

agent = OpenAIAgent.from_tools( LoadAndSearchToolSpec.from_defaults(tool).to_tool_list(), verbose=True ) agent.chat('Who is Ben Afflecks spouse?')

Relevant Logs/Tracbacks

No response