Spaces:
Sleeping
Sleeping
Mateus Sousa
commited on
Commit
·
b0b4a2d
1
Parent(s):
fa5e74e
add chat with openai
Browse files- app.py +22 -2
- requirements.txt +3 -0
app.py
CHANGED
|
@@ -1,5 +1,25 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
st.write(x, 'squared is', x * x)
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from langchain.llms import OpenAI
|
| 3 |
|
| 4 |
+
MODEL="gpt-3.5-turbo"
|
|
|
|
| 5 |
|
| 6 |
+
def get_response_from_openai(question):
|
| 7 |
+
llm=OpenAI(model=MODEL,temperature=0.1)
|
| 8 |
+
answer=llm(question)
|
| 9 |
+
return answer
|
| 10 |
+
|
| 11 |
+
st.set_page_config(page_title="Pergunte ao GPT",page_icon=":robot:")
|
| 12 |
+
st.header("Pergunte ao GPT")
|
| 13 |
+
|
| 14 |
+
def get_user_text():
|
| 15 |
+
text=st.text_input("Ask: ", key="input")
|
| 16 |
+
return text
|
| 17 |
+
|
| 18 |
+
user_input=get_user_text()
|
| 19 |
+
response=get_response_from_openai(user_input)
|
| 20 |
+
|
| 21 |
+
submit=st.button("PERGUNTE")
|
| 22 |
+
|
| 23 |
+
if submit:
|
| 24 |
+
st.subheader("Resposta: ")
|
| 25 |
+
st.write(response)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
langchain
|
| 2 |
+
openai
|
| 3 |
+
streamlit
|