Spaces:
Runtime error
Runtime error
piotrpolska
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from langchain.llms import OpenAI
|
3 |
+
|
4 |
+
def get_response_from_openai(question):
|
5 |
+
llm = OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0.1)
|
6 |
+
answer=llm(question)
|
7 |
+
return answer
|
8 |
+
|
9 |
+
st.set_page_config(page_title="Ask GPT", page_icon=":robot:")
|
10 |
+
st.header("Ask GPT")
|
11 |
+
|
12 |
+
def get_user_text():
|
13 |
+
text = st.text_input("Ask: ", key="input")
|
14 |
+
return text
|
15 |
+
|
16 |
+
user_input = get_user_text()
|
17 |
+
response = get_response_from_openai(user_input)
|
18 |
+
|
19 |
+
submit = st.button('Ask')
|
20 |
+
|
21 |
+
if submit:
|
22 |
+
|
23 |
+
st.subheader("Answer:")
|
24 |
+
|
25 |
+
st.write(response)
|