lida-project / lida-streamlit

Example project building a data visualization app using Streamlit and LIDA
MIT License
70 stars 19 forks source link

Exception thrown with lida summarize object when using openai model #3

Open indapa opened 6 months ago

indapa commented 6 months ago

Hi LIDA team

When ever I choose a model other than gpt-3.5-turbo-1106, I get the an exception in the summarize object. For example if I choose gpt-4, I get the error;

File "/Users/indapa/miniconda3/envs/lida/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script exec(code, module.__dict__) File "/Users/indapa/lida_indapa/main.py", line 165, in <module> st.session_state.summary = st.session_state.lida.summarize( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/indapa/miniconda3/envs/lida/lib/python3.11/site-packages/lida/components/manager.py", line 131, in summarize return self.summarizer.summarize( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/indapa/miniconda3/envs/lida/lib/python3.11/site-packages/lida/components/summarizer.py", line 144, in summarize data_summary = self.enrich( ^^^^^^^^^^^^ File "/Users/indapa/miniconda3/envs/lida/lib/python3.11/site-packages/lida/components/summarizer.py", line 115, in enrich raise ValueError(error_msg + "" + response.usage) ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

The relevant code is below. Throws exception when st_session_state.model is anything other than gpt-3.5-turbo-1106

st.session_state.textgen_config = TextGenerationConfig( n=num_visualizations, temperature=st.session_state.temp, model=st.session_state.model, use_cache=st.session_state.use_cache)

` #make summary object and add to session state

** lida.summarize ***

st.session_state.summary = st.session_state.lida.summarize(
    data=st.session_state.df,
    summary_method=selected_method,
    textgen_config=st.session_state.textgen_config)`
hemil26 commented 3 months ago

Hey, I am getting the same error when l use llm to summarize the dataset, I am using cohere model.

Traceback (most recent call last):
  File "/Users/hemilmehta/Desktop/Hemil/Coding/LIDA/myenv/lib/python3.11/site-packages/lida/components/summarizer.py", line 110, in enrich
    enriched_summary = json.loads(json_string)
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 243 column 16 (char 8254)

and then the same error which you got.

indapa commented 3 months ago

Hi @hemil26 - I recently started using the GPT-4o model, and it works fine. But my original issue was never addressed. It;;s not clear if there are any eyes on this repo from the developer.