Hi - I am currently trying to wrap an agent over the free Polygion.io (financial markets data) API and so far the agent is having a hard time parsing the response it gets back.
I have fiddled a lot with prompting it to better parse the data but we're running into an error that I believe is in the RequestsToolSpec object:
My code:
# Wrap the Polygon API spec with LoadAndSearchToolSpec
wrapped_tools = LoadAndSearchToolSpec.from_defaults(
api_spec.to_tool_list()[0],
).to_tool_list()
agent = ReActAgent.from_tools(
[*wrapped_tools, requests_spec.to_tool_list()[0]]
, verbose=True
, llm=llm
, context=CONTEXT
, max_iterations=20
)
agent.chat("What are all the exchanges you have access to?")
Error:
File /workspaces/pye/pye/.venv/lib/python3.10/site-packages/llama_hub/tools/requests/base.py:75, in RequestsToolSpec._get_headers_for_url(self, url)
74 def _get_headers_for_url(self, url: str) -> dict:
---> 75 return self.domain_headers[self._get_domain(url)]
KeyError: 'api.polygon.io'
It looks like its trying to look in the response headers for a key
api.polygon.io
even though I've never prompted it to do so. It also looks like its hardcoded to do this in the RequestsToolSpec object?
Any ideas on how to resolve this? Modifying the prompt doesn't seem to do anything.