microsoft / lida

Automatic Generation of Visualizations and Infographics using Large Language Models
https://microsoft.github.io/lida/
MIT License
2.57k stars 260 forks source link

Facing this issue: Got unknown type o #82

Closed anshumankmr closed 6 months ago

anshumankmr commented 6 months ago
Traceback (most recent call last):
  File "C:\Users\anshumankumar1\Documents\repos\langchain\src\main.py", line 91, in generate_visualization
    run_analysis(user_query=user_query)
  File "C:\Users\anshumankumar1\Documents\repos\langchain\src\main.py", line 52, in run_analysis
    lida = Manager(text_gen=llm("openai")) # !! api key
                            ^^^^^^^^^^^^^
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_core\_api\deprecation.py", line 142, in warning_emitting_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", 
line 690, in __call__
    generation = self.generate(
                 ^^^^^^^^^^^^^^
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", 
line 407, in generate
    raise e
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", 
line 397, in generate
    self._generate_with_cache(
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_core\language_models\chat_models.py", 
line 576, in _generate_with_cache
    return self._generate(
           ^^^^^^^^^^^^^^^
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_community\chat_models\openai.py", line 431, in _generate
    message_dicts, params = self._create_message_dicts(messages, stop)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_community\chat_models\openai.py", line 450, in _create_message_dicts
    message_dicts = [convert_message_to_dict(m) for m in messages]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\anshumankumar1\AppData\Roaming\Python\Python312\site-packages\langchain_community\adapters\openai.py", line 145, in convert_message_to_dict
    raise TypeError(f"Got unknown type {message}")
TypeError: Got unknown type o

Code

def run_analysis(user_query):
    lida = Manager(text_gen=llm("openai")) # !! api key

which is being called from

@app.route('/generate-visualization', methods=['POST'])
@cross_origin()
def generate_visualization():
    if request.method == 'POST':
        user_query = request.form.get('user_query')
        try:
            run_analysis(user_query=user_query)
            return jsonify({'result': True, 'error': None})
        except Exception as e:
            print(e)
            print(traceback.format_exc())
            return jsonify({'result': False, 'error': str(e)})

requirements.txt file is

aiosignal==1.3.1
altair==5.2.0
annotated-types==0.6.0
anyio==4.2.0
attrs==23.2.0
backoff==2.2.1
blinker==1.7.0
cachetools==5.3.2
certifi==2023.11.17
charset-normalizer==3.3.2
click==8.1.7
click-plugins==1.1.1
cligj==0.7.2
cohere==4.40
colorama==0.4.6
contourpy==1.2.0
cycler==0.12.1
dataclasses-json==0.6.3
diskcache==5.6.3
environ==1.0
fastapi==0.108.0
fastavro==1.9.2
fiona==1.9.5
Flask==3.0.0
Flask-Cors==4.0.0
fonttools==4.47.0
frozenlist==1.4.1
geopandas==0.14.2
google-auth==2.26.1
greenlet==3.0.3
h11==0.14.0
idna==3.6
importlib-metadata==6.11.0
itsdangerous==2.1.2
Jinja2==3.1.2
jsonpatch==1.33
jsonpointer==2.4
jsonschema==4.20.0
jsonschema-specifications==2023.12.1
kaleido==0.2.1
kiwisolver==1.4.5
langchain==0.0.354
langchain-community==0.0.10
langchain-core==0.1.8
langchain-experimental==0.0.47
langsmith==0.0.77
lida==0.0.11
llmx==0.0.18a0
MarkupSafe==2.1.3
marshmallow==3.20.1
matplotlib==3.8.2
matplotlib-venn==0.11.9
mizani==0.9.3
multidict==6.0.4
mypy-extensions==1.0.0
networkx==3.2.1
numpy==1.26.3
openai==0.28.1
packaging==23.2
pandas==2.1.4
patsy==0.5.6
pillow==10.2.0
plotly==5.18.0
plotnine==0.12.4
psycopg2-binary==2.9.9
pyasn1==0.5.1
pyasn1-modules==0.3.0
pydantic==2.5.3
pydantic_core==2.14.6
pyparsing==3.1.1
pyproj==3.6.1
python-dateutil==2.8.2
python-decouple==3.8
python-dotenv==1.0.0
python-multipart==0.0.6
pytz==2023.3.post1
PyYAML==6.0.1
referencing==0.32.1
regex==2023.12.25
requests==2.31.0
rpds-py==0.16.2
rsa==4.9
scipy==1.11.4
seaborn==0.13.1
setuptools==69.0.3
shapely==2.0.2
six==1.16.0
sniffio==1.3.0
SQLAlchemy==2.0.25
starlette==0.32.0.post1
statsmodels==0.14.1
tenacity==8.2.3
tiktoken==0.5.2
toolz==0.12.0
tqdm==4.66.1
typer==0.9.0
typing-inspect==0.9.0
typing_extensions==4.9.0
tzdata==2023.4
urllib3==2.1.0
uvicorn==0.25.0
Werkzeug==3.0.1
wordcloud==1.9.3
yarl==1.9.4
zipp==3.17.0
anshumankmr commented 6 months ago

Sorry figured it out. Issue was I passing a wrong argument

Ripperox commented 6 days ago

hey im getting a similar issue can i know what you did exactly

anshumankmr commented 6 days ago

Hey @Ripperox I don't exactly remember but if I am not wrong it was something with my Azure Open AI key. I used Open AI and it worked fine.