Error in deployment open api ap-->streamlit

I am trying to deploy an app from open ai , the app got deployed, however when i run the app, I get a streamlit error message

Source code: - openai-cookbook/apps/chatbot-kickstarter at main · openai/openai-cookbook · GitHub

TypeError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)File "/app/chatbotkb/chat.py", line 71, in <module>
    response = query(messages)File "/app/chatbotkb/chat.py", line 51, in query
    response = st.session_state['chat'].ask_assistant(question)File "/app/chatbotkb/chatbot.py", line 58, in ask_assistant
    if 'searching for answers' in assistant_response['content'].lower():

Unfortunately the error message you posted is redacted to prevent data leaks.

Take a look at the full error details that have been recorded in the logs, hopefully there will be more useful messages there.

Where can i find the logs in streamlit? I am new to stremlit and this my first app, any help is appreciated @Goyo

If you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app.

1 Like

When i Login, I only see the above screen and on click of 3 dots I see

I don’t see a logs option anywhere. Please assist @Goyo

You need to navigate to your actual app, then look in the lower right corner. You don’t see it in the admin panel or the three dots menu in the admin panel.

There are screenshots if you follow the link @Goyo provided.

1 Like

1 Like

Got it now. I got the error logs and see below (Pasting only the error part)

[18:55:29] 📦 Processed dependencies!

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.




2023-03-31 18:57:08.657 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/app/chatbotkb/chat.py", line 71, in <module>
    response = query(messages)
  File "/app/chatbotkb/chat.py", line 51, in query
    response = st.session_state['chat'].ask_assistant(question)
  File "/app/chatbotkb/chatbot.py", line 58, in ask_assistant
    if 'searching for answers' in assistant_response['content'].lower():
TypeError: string indices must be integers
2023-03-31 19:13:32.893 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/app/chatbotkb/chat.py", line 71, in <module>
    response = query(messages)
  File "/app/chatbotkb/chat.py", line 51, in query
    response = st.session_state['chat'].ask_assistant(question)
  File "/app/chatbotkb/chatbot.py", line 58, in ask_assistant
    if 'searching for answers' in assistant_response['content'].lower():
TypeError: string indices must be integers
2023-04-02 16:01:31.507 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/app/chatbotkb/chat.py", line 71, in <module>
    response = query(messages)
  File "/app/chatbotkb/chat.py", line 51, in query
    response = st.session_state['chat'].ask_assistant(question)
  File "/app/chatbotkb/chatbot.py", line 58, in ask_assistant
    if 'searching for answers' in assistant_response['content'].lower():
TypeError: string indices must be integers

The error implies it’s unrelated to Streamlit and a programming error, specifically that “string indices must be integers”. The code is trying to access the value of assistant_response using a string key ‘content’, but Python is expecting an integer index instead. This suggests that assistant_response is not a dict, as the code seems to assume, but rather str or another type that requires an integer index.

To fix this, you should first check the data type and structure of assistant_response and ensure that it’s a dict with a ‘content’ key. If it’s not a dict, you will need to modify the code accordingly to handle the actual data type and structure of assistant_response.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.