Spaces:
Sleeping
Sleeping
Commit
·
22d62f4
1
Parent(s):
9c62673
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from langchain.llms import OpenAI
|
| 4 |
+
|
| 5 |
+
#Function to return response
|
| 6 |
+
def load_answer(question):
|
| 7 |
+
llm = OpenAI(model_name="text-davinci-003", temperature=0)
|
| 8 |
+
answer=llm(question)
|
| 9 |
+
return answer
|
| 10 |
+
|
| 11 |
+
#App UI starts here
|
| 12 |
+
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
|
| 13 |
+
st.header("LangChain Demo")
|
| 14 |
+
|
| 15 |
+
#Get the user input
|
| 16 |
+
def get_input():
|
| 17 |
+
input_text = st.text_input("You: ", key="input")
|
| 18 |
+
return input_text
|
| 19 |
+
|
| 20 |
+
user_input=get_input()
|
| 21 |
+
response = load_answer(user_input)
|
| 22 |
+
|
| 23 |
+
submit = st.button('Generate')
|
| 24 |
+
|
| 25 |
+
#If generate button is clicked
|
| 26 |
+
if submit:
|
| 27 |
+
st.subheader("Answer:")
|
| 28 |
+
st.write(response)
|