mbhoge commited on
Commit
43fba69
·
verified ·
1 Parent(s): b069c3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from langchain.llms import OpenAI
4
+
5
+ # Function to return the response
6
+ def load_answer(question):
7
+ # Initialize the OpenAI API
8
+ llm = OpenAI(model_name="text-davinci-003", temperature=0.9)
9
+ # Generate the response
10
+ response = llm(question)
11
+
12
+ return response
13
+
14
+ # App UI Starts here
15
+ st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
16
+ st.header("LangChain Demo")
17
+
18
+ # Get the user input
19
+ def get_text():
20
+ input_text = st.text_input("Enter your question:", key="input")
21
+ return input_text
22
+
23
+ user_input = get_text()
24
+ response = load_answer(user_input)
25
+
26
+ submit = st.button("Submit")
27
+
28
+ # If the submit button is clicked
29
+ if submit:
30
+ # Display the response
31
+ st.write(response)
32
+ st.subheader("Answer = ")
33
+ st.balloons()