lightmate commited on
Commit
9b6dcfb
1 Parent(s): 6fc1518

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.llms import OpenAI
2
+
3
+ from dotenv import load_dotenv
4
+
5
+ load_dotenv() # take environment variables from .env
6
+
7
+ import streamlit as st
8
+ import os
9
+
10
+ ## Function to load OpenAI model and get response
11
+ def get_openai_reponse(question):
12
+ llm = OpenAI(openai_api_key = os.getenv("OPEN_API_KEY"), model_name="text-davinci-003", temperature=0.5)
13
+ response = llm(question)
14
+ return response
15
+
16
+ # Initialize our streamlit app
17
+
18
+ st.set_page_config(page_title="Q&A Demo")
19
+ st.header("LangChain Application")
20
+
21
+ input = st.text_input("Input: ", key="input")
22
+
23
+ response = get_openai_reponse(input)
24
+
25
+ submit = st.button("Ask a question")
26
+
27
+ # If ask button is clicked
28
+ if submit:
29
+ st.subheader("The Response is")
30
+ st.write(response)
31
+
32
+
33
+