ryanshrott / autogen

24 stars 9 forks source link

Fails when I run it with module 'autogen' has no attribute 'config_list_from_json' #1

Open yepher opened 11 months ago

yepher commented 11 months ago

I was trying to follow the code for Integrate AutoGen into your Chatbot: Code Interpreter Clone The article and repo do not seem to have much detail on how to run this and I am not familiar with chainlit.

Here is what I tried:

❯ git clone git@github.com:ryanshrott/autogen.git demo_autogen
❯ cd  demo_autogen
❯ python -m venv ./.venv
❯ source ./.venv/bin/activate
❯ pip install chainlit autogen openai
[lots of output but success]

❯ ./.venv/bin/chainlit run app.py
2023-10-25 16:41:59 - Your app is available at http://localhost:8000
2023-10-25 16:42:02 - module 'autogen' has no attribute 'config_list_from_json'
Traceback (most recent call last):
  File ".../demo_autogen/.venv/lib/python3.10/site-packages/chainlit/utils.py", line 39, in wrapper
    return await user_function(**params_values)
  File "...//demo_autogen/app.py", line 12, in setup_agent
    config_list = autogen.config_list_from_json(
AttributeError: module 'autogen' has no attribute 'config_list_from_json'

I did see in the comments of the Medium article that others had an issue, too, but I believe the author updated the code to fix the problem.

yepher commented 11 months ago

This Fork are the changes that worked for me, along with some extra documentation and a requirements.txt

I am not sure if this is the correct answer but I changed the imports in app.py to:

import os
import chainlit as cl
#import autogen
from flaml import autogen

and did:

pip install "flaml[openai]"
pip install "flaml[autogen]"

And now it works by running ./.venv/bin/chainlit run app.py

That was based on a search I did for the error and found this colab notebook that had similar code for the part that was failing.

Not sure if it is needed but I created a file called OAI_CONFIG_LIST and put the following in it:

[
    {
        "model": "gpt-4",
        "api_key": "sk-..."
    },
    {
        "model": "gpt-3.5-turbo",
        "api_key": "sk-..."
    }
]