Link-AGI / AutoAgents

[IJCAI 2024] Generate different roles for GPTs to form a collaborative entity for complex tasks.
https://huggingface.co/spaces/LinkSoul/AutoAgents
MIT License
1.15k stars 146 forks source link

TypeError: 'async for' requires an object with __aiter__ method, got generator #27

Closed drnic closed 10 months ago

drnic commented 10 months ago

I'm getting this error for python 3.10 + 3.11. Suggestions on what might fix it?

conda create -n AutoAgents python=3.10 -y
conda activate AutoAgents
pip3 install -r requirements.txt
python setup.py install

python main.py --mode commandline --idea "Write a poem about the last five Australian prime ministers" --llm_api_key=$OPENAI_API_KEY --serpapi_key=$SERPAPI_API_KEY

The output is an error:

2023-10-15 18:16:16.657 | INFO     | autoagents.system.config:__init__:43 - Config loading done.
2023-10-15 18:16:17.477 | INFO     | autoagents.explorer:invest:33 - Investment: $10.0.
Traceback (most recent call last):
  File "/Users/drnic/workspace/aiagents/AutoAgents/main.py", line 56, in <module>
    asyncio.run(commanline(proxy=proxy, llm_api_key=args.llm_api_key, serpapi_key=args.serpapi_key, idea=args.idea))
  File "/opt/homebrew/Caskroom/miniconda/base/envs/AutoAgents/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/AutoAgents/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/drnic/workspace/aiagents/AutoAgents/main.py", line 30, in commanline
    await startup.startup(idea, investment, n_round, llm_api_key=llm_api_key, serpapi_key=serpapi_key, proxy=proxy)
  File "/Users/drnic/workspace/aiagents/AutoAgents/startup.py", line 14, in startup
    await explorer.run(n_round=n_round)
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/explorer.py", line 57, in run
    await self.environment.run()
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/environment.py", line 192, in run
    await asyncio.gather(*futures)
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/roles/role.py", line 239, in run
    rsp = await self._react()
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/roles/role.py", line 207, in _react
    await self._think()
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/roles/role.py", line 155, in _think
    next_state = await self._llm.aask(prompt)
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/system/provider/base_gpt_api.py", line 42, in aask
    rsp = await self.acompletion_text(message, stream=True)
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/system/provider/openai_api.py", line 33, in wrapper
    return await f(*args, **kwargs)
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/system/provider/openai_api.py", line 230, in acompletion_text
    return await self._achat_completion_stream(messages)
  File "/Users/drnic/workspace/aiagents/AutoAgents/autoagents/system/provider/openai_api.py", line 173, in _achat_completion_stream
    async for chunk in response:
TypeError: 'async for' requires an object with __aiter__ method, got generator

Installed packages:

$ pip3 list
Package                 Version
----------------------- ------------
aiohttp                 3.8.5
aiosignal               1.3.1
anthropic               0.3.6
anyio                   3.7.1
appdirs                 1.4.4
asgiref                 3.7.2
async-timeout           4.0.3
attrs                   23.1.0
autoagents              0.1
backoff                 2.2.1
camel-converter         3.0.3
certifi                 2023.7.22
channels                4.0.0
charset-normalizer      3.3.0
click                   8.1.7
cohere                  4.27
dataclasses-json        0.5.14
diskcache               5.6.3
distro                  1.8.0
Django                  4.2.6
duckduckgo-search       2.9.4
et-xmlfile              1.1.0
exceptiongroup          1.1.3
faiss-cpu               1.7.4
fastavro                1.8.2
filelock                3.12.4
fire                    0.4.0
frozenlist              1.4.0
fsspec                  2023.9.2
h11                     0.14.0
httpcore                0.18.0
httpx                   0.25.0
huggingface-hub         0.17.3
idna                    3.4
importlib-metadata      6.8.0
iniconfig               2.0.0
langchain               0.0.236
langsmith               0.0.10
litellm                 0.1.236
loguru                  0.6.0
lxml                    4.9.3
marshmallow             3.20.1
meilisearch             0.21.0
multidict               6.0.4
mypy-extensions         1.0.0
numexpr                 2.8.7
numpy                   1.24.3
openai                  0.27.8
openapi-schema-pydantic 1.2.4
openpyxl                3.1.2
packaging               23.2
pandas                  1.4.1
pandas-stubs            2.0.2.230605
pip                     23.2.1
pluggy                  1.3.0
pydantic                1.10.7
pytest                  7.2.2
python-dateutil         2.8.2
python-docx             0.8.11
python-dotenv           1.0.0
pytz                    2023.3.post1
PyYAML                  6.0
regex                   2023.10.3
replicate               0.15.4
requests                2.31.0
setuptools              65.6.3
six                     1.16.0
sniffio                 1.3.0
SQLAlchemy              2.0.22
sqlparse                0.4.4
tenacity                8.2.2
termcolor               2.3.0
tiktoken                0.3.3
tokenizers              0.14.1
tomli                   2.0.1
tqdm                    4.64.0
types-pytz              2023.3.1.1
typing_extensions       4.5.0
typing-inspect          0.8.0
urllib3                 2.0.6
websockets              11.0.3
wheel                   0.41.2
yarl                    1.9.2
zipp                    3.17.0
fxtoofaan commented 10 months ago

same error here

iCGY96 commented 10 months ago

We have just made some updates to the requirements.txt file and you can give it another try. The updated file includes some additional packages that are not essential, and we plan to streamline the requirements.txt file in the future.

drnic commented 10 months ago

Thanks. Closing in lieu of discussion in #29