Gavroche43 commited on
Commit
62a419d
·
verified ·
1 Parent(s): 924eedc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -33
app.py CHANGED
@@ -10,39 +10,6 @@ from Agents import Head_Agent
10
 
11
  st.title("Mini Project 2: Streamlit Chatbot")
12
 
13
- if Config.openai_key:
14
- openai_key = Config.openai_key
15
- else:
16
- openai_key = st.sidebar.text_input("OpenAI API Key", type="password")
17
- if not openai_key:
18
- st.info("Please add your OpenAI API key to continue.")
19
- st.stop()
20
-
21
- if Config.pinecone_key:
22
- pinecone_key = Config.pinecone_key
23
- else:
24
- pinecone_key = st.sidebar.text_input("Pinecone API Key", type="password")
25
- if not pinecone_key:
26
- st.info("Please add your Pinecone API key to continue.")
27
- st.stop()
28
-
29
- try:
30
- client = OpenAI(api_key=openai_key)
31
- message = {"role": "user", "content": "ping"}
32
- client.chat.completions.create(model="gpt-3.5-turbo", messages=[message])
33
- Head_Agent(openai_key, pinecone_key, Config.pinecone_index_name)
34
- except AuthenticationError:
35
- st.error("Failed to authenticate with OpenAI. Please check your API key.")
36
- st.stop()
37
- except OpenAIError as e:
38
- st.error(f"An error occurred while trying to communicate with OpenAI: {e}")
39
- st.stop()
40
-
41
- try:
42
- Pinecone(api_key=pinecone_key)
43
- except requests.exceptions.HTTPError as e:
44
- st.error(f"Failed to authenticate with Pinecone or communicate properly: {e}")
45
- st.stop()
46
 
47
  run = Head_Agent(openai_key, pinecone_key, Config.pinecone_index_name)
48
  run.main_loop()
 
10
 
11
  st.title("Mini Project 2: Streamlit Chatbot")
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  run = Head_Agent(openai_key, pinecone_key, Config.pinecone_index_name)
15
  run.main_loop()