VRSEN / agency-swarm

The only reliable agent framework built on top of the latest OpenAI Assistants API.
https://vrsen.github.io/agency-swarm/
MIT License
2.05k stars 537 forks source link

AttributeError: 'RetrievalToolCall' object has no attribute 'function' #100

Closed ha-zhcool closed 2 months ago

ha-zhcool commented 3 months ago

I'm facing the following issue when adding files to the agent. Files are uploaded correctly to OpenAI storage but I get the following error when asking the agent to provide a summary.

Exception in thread Thread-6 (get_completion_stream):
Traceback (most recent call last):
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/pydantic/main.py", line 759, in __getattr__
    return pydantic_extra[item]
           ~~~~~~~~~~~~~~^^^^^^
KeyError: 'function'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 143, in get_completion_stream
    next(gen)
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 65, in get_completion
    self._create_run(recipient_agent, event_handler)
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 152, in _create_run
    stream.until_done()
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 102, in until_done
    consume_sync_iterator(self)
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/openai/_utils/_streams.py", line 6, in consume_sync_iterator
    for _ in iterator:
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 69, in __iter__
    for item in self._iterator:
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 405, in __stream__
    self._emit_sse_event(event)
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 368, in _emit_sse_event
    self.on_tool_call_created(self._current_tool_call)
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 261, in on_tool_call_created
    str(tool_call.function))
        ^^^^^^^^^^^^^^^^^^
  File "/home/user/AI/agency-swarm/.agency/lib/python3.11/site-packages/pydantic/main.py", line 761, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}') from exc
AttributeError: 'RetrievalToolCall' object has no attribute 'function'
frdel commented 2 months ago

I am getting the same error. The agent reads a file correctly, I can see that in his thread, but then it crashes on this error.

Traceback (most recent call last): File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/pydantic/main.py", line 759, in getattr return pydantic_extra[item]


KeyError: 'function'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/frdel/pSync/OpenProjects/AI/swarm/Mirka/QueryAnalysisAgency/agency.py", line 37, in <module>
    agency.run_demo()
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 458, in run_demo
    self.get_completion_stream(message=text, event_handler=TermEventHandler, recipient_agent=recipient_agent)
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 143, in get_completion_stream
    next(gen)
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 84, in get_completion
    item = next(output)
           ^^^^^^^^^^^^
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 733, in run
    yield next(gen)
          ^^^^^^^^^
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 65, in get_completion
    self._create_run(recipient_agent, event_handler)
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 152, in _create_run
    stream.until_done()
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 102, in until_done
    consume_sync_iterator(self)
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/openai/_utils/_streams.py", line 6, in consume_sync_iterator
    for _ in iterator:
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 69, in __iter__
    for item in self._iterator:
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 405, in __stream__
    self._emit_sse_event(event)
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 368, in _emit_sse_event
    self.on_tool_call_created(self._current_tool_call)
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 407, in on_tool_call_created
    str(tool_call.function))
        ^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/swarm/lib/python3.11/site-packages/pydantic/main.py", line 761, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}') from exc
AttributeError: 'RetrievalToolCall' object has no attribute 'function'
tspiker03 commented 2 months ago

I am getting the same error as well. Have either of you found a solution?

VRSEN commented 2 months ago

Hey everyone, my apologies for the bug. It's now fixed, so please update to the latest release.