Upload app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# from langchain.llms import OpenAI
|
4 |
+
from langchain.llms import HuggingFace
|
5 |
+
|
6 |
+
## Function to return the response
|
7 |
+
def load_answer(question):
|
8 |
+
# llm = OpenAI(model_name="gpt-3.5-turbo")
|
9 |
+
llm = HuggingFace(model_name="google/flan-t5-large")
|
10 |
+
answer = llm(question)
|
11 |
+
return answer
|
12 |
+
|
13 |
+
## App UI starts here
|
14 |
+
st.set_page_config(page_title="LangChain Demo", page_icon="🦜")
|
15 |
+
st.header("🦜️🔗 LangChain Demo")
|
16 |
+
|
17 |
+
## Gets the user input
|
18 |
+
def get_text():
|
19 |
+
input_text = st.text_input("You: ", key="input")
|
20 |
+
return input_text
|
21 |
+
|
22 |
+
user_input = get_text()
|
23 |
+
response = load_answer(user_input)
|
24 |
+
|
25 |
+
submit = st.button("Generate")
|
26 |
+
|
27 |
+
## If generate button is clicked
|
28 |
+
if submit:
|
29 |
+
st.subheader("Answer:")
|
30 |
+
|
31 |
+
st.write(response)
|