Spaces:
Sleeping
Sleeping
Walterchamy
commited on
Commit
•
b0f9a29
1
Parent(s):
5614071
Update app.py
Browse files
app.py
CHANGED
@@ -190,14 +190,10 @@ For contact information:
|
|
190 |
|
191 |
#if __name__ == '__main__':
|
192 |
# main()
|
193 |
-
import streamlit as st
|
194 |
-
from openai import OpenAI
|
195 |
-
client = OpenAI()
|
196 |
-
|
197 |
def generate_response(user_input):
|
198 |
-
response =
|
199 |
-
|
200 |
-
|
201 |
{"role": "system", "content": "i have create a streamlit app of question and answering and i'm using chatgpt by using openaiAPI but gives me the error provided"},
|
202 |
{"role": "user", "content": user_input}
|
203 |
],
|
@@ -207,12 +203,14 @@ def generate_response(user_input):
|
|
207 |
frequency_penalty=0.0,
|
208 |
presence_penalty=0.0
|
209 |
)
|
210 |
-
return response
|
211 |
|
212 |
def main():
|
213 |
st.title("Question and Answering with OpenAI")
|
214 |
st.write("Ask a question and get an answer!")
|
|
|
215 |
user_input = st.text_input("Enter your question:")
|
|
|
216 |
if st.button("Answer"):
|
217 |
with st.spinner("Generating Response..."):
|
218 |
response_text = generate_response(user_input)
|
|
|
190 |
|
191 |
#if __name__ == '__main__':
|
192 |
# main()
|
|
|
|
|
|
|
|
|
193 |
def generate_response(user_input):
|
194 |
+
response = openai.Completion.create(
|
195 |
+
engine="davinci-codex",
|
196 |
+
prompt=[
|
197 |
{"role": "system", "content": "i have create a streamlit app of question and answering and i'm using chatgpt by using openaiAPI but gives me the error provided"},
|
198 |
{"role": "user", "content": user_input}
|
199 |
],
|
|
|
203 |
frequency_penalty=0.0,
|
204 |
presence_penalty=0.0
|
205 |
)
|
206 |
+
return response.choices[0].message.content
|
207 |
|
208 |
def main():
|
209 |
st.title("Question and Answering with OpenAI")
|
210 |
st.write("Ask a question and get an answer!")
|
211 |
+
|
212 |
user_input = st.text_input("Enter your question:")
|
213 |
+
|
214 |
if st.button("Answer"):
|
215 |
with st.spinner("Generating Response..."):
|
216 |
response_text = generate_response(user_input)
|