yrobel-lima commited on
Commit
89fb387
·
verified ·
1 Parent(s): 81b1a3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -1,14 +1,18 @@
1
  import logging
2
  from typing import Optional
3
 
4
- import openai
5
  import streamlit as st
6
  from langchain_core.messages import AIMessage, HumanMessage
7
- from openai import OpenAI, OpenAIError
8
-
9
- from rag.runnable_and_memory import get_runnable_and_memory
10
  from utils.error_message_template import ERROR_MESSAGE
11
 
 
 
 
 
 
 
 
 
12
  logging.basicConfig(level=logging.ERROR)
13
 
14
  # Streamlit page configuration
@@ -33,7 +37,7 @@ def initialize_session_state():
33
  )
34
  # Clear the memory
35
  st.session_state["memory"].clear()
36
- except openai.AuthenticationError:
37
  handle_errors()
38
  except Exception:
39
  handle_errors()
 
1
  import logging
2
  from typing import Optional
3
 
 
4
  import streamlit as st
5
  from langchain_core.messages import AIMessage, HumanMessage
 
 
 
6
  from utils.error_message_template import ERROR_MESSAGE
7
 
8
+ try:
9
+ import openai
10
+ from openai import OpenAI, OpenAIError
11
+ from rag.runnable_and_memory import get_runnable_and_memory
12
+ except OpenAIError:
13
+ handle_errors()
14
+ st.stop()
15
+
16
  logging.basicConfig(level=logging.ERROR)
17
 
18
  # Streamlit page configuration
 
37
  )
38
  # Clear the memory
39
  st.session_state["memory"].clear()
40
+ except openai.OpenAIError:
41
  handle_errors()
42
  except Exception:
43
  handle_errors()