Files changed (1) hide show
  1. app.py +30 -48
app.py CHANGED
@@ -1,48 +1,30 @@
1
- # import os
2
- # import openai
3
- # openai.api_type = "azure"
4
- # openai.api_base = "https://fevaworksopenai.openai.azure.com/"
5
- # openai.api_version = "2023-03-15-preview"
6
- # openai.api_key = os.getenv("OPENAI_API_KEY")
7
- #  
8
- # response = openai.ChatCompletion.create(
9
- # engine="gpt-35-turbo",
10
- # messages = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":"<input>"
11
- # max_tokens=800,
12
- # top_p=0.95,
13
- # frequency_penalty=0,
14
- # presence_penalty=0,
15
- # stop=None)
16
- # &nbsp;
17
- # above is an openai chat API call, create a streamlit app with a chat interface that takes user input that enter button to send request and reply with openai API response
18
-
19
- import os
20
- import openai
21
- import streamlit as st
22
-
23
- # Set up OpenAI API
24
- openai.api_type = "azure"
25
- openai.api_base = "https://fevaworksopenai.openai.azure.com/"
26
- openai.api_version = "2023-03-15-preview"
27
- openai.api_key = os.getenv("OPENAI_API_KEY")
28
-
29
- # Streamlit app
30
- st.title("AI Chatbot")
31
- st.write("Ask your question and get a response from the AI.")
32
-
33
- user_input = st.text_input("Your question:")
34
- if st.button("Send"):
35
- if user_input:
36
- response = openai.ChatCompletion.create(
37
- engine="gpt-35-turbo",
38
- messages=[{"role": "system", "content": "You are an AI assistant that helps people find information."},
39
- {"role": "user", "content": user_input}],
40
- max_tokens=800,
41
- top_p=0.95,
42
- frequency_penalty=0,
43
- presence_penalty=0,
44
- stop=None)
45
-
46
- st.write("AI response:", response.choices[0].message["content"])
47
- else:
48
- st.write("Please enter a question.")
 
1
+ import os
2
+ import openai
3
+ import streamlit as st
4
+
5
+ # Set up OpenAI API
6
+ openai.api_type = "azure"
7
+ openai.api_base = "https://fevaworksopenai.openai.azure.com/"
8
+ openai.api_version = "2023-03-15-preview"
9
+ openai.api_key = os.getenv("OPENAI_API_KEY")
10
+
11
+ # Streamlit app
12
+ st.title("AI Chatbot")
13
+ st.write("Ask your question and get a response from the AI.")
14
+
15
+ user_input = st.text_input("Your question:")
16
+ if st.button("Send"):
17
+ if user_input:
18
+ response = openai.ChatCompletion.create(
19
+ engine="gpt-35-turbo",
20
+ messages=[{"role": "system", "content": "You are an AI assistant that helps people find information."},
21
+ {"role": "user", "content": user_input}],
22
+ max_tokens=800,
23
+ top_p=0.95,
24
+ frequency_penalty=0,
25
+ presence_penalty=0,
26
+ stop=None)
27
+
28
+ st.text_area("AI response:", value=response.choices[0].text)
29
+ else:
30
+ st.write("Please enter a question.")