udayr commited on
Commit
d5b0351
·
verified ·
1 Parent(s): 8ae12a3

Upload 3 files

Browse files
Files changed (3) hide show
  1. .env +1 -0
  2. app.py +32 -0
  3. requirements.txt +4 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ OPENAI_API_KEY = ""
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.llms.openai import OpenAI
2
+ from dotenv import load_dotenv
3
+ import os
4
+
5
+ load_dotenv() # load environment variables from .env
6
+ print(os.getenv("OPENAI_API_KEY"))
7
+
8
+ import streamlit as st
9
+
10
+ # Function to load OpenAI model and get response
11
+ def get_openai_response(question):
12
+ llm = OpenAI(openai_api_key=os.getenv("OPENAI_API_KEY"),
13
+ temperature=0.9)
14
+ response = llm(question)
15
+ return response
16
+
17
+
18
+ # initialize our Streamlit App
19
+
20
+ st.set_page_config(layout="wide", page_title="Q&A Demo")
21
+ st.header("LangChain Application")
22
+
23
+ input = st.text_input("Input: ", key="input")
24
+ response = get_openai_response(input)
25
+
26
+ submit = st.button("Ask the Question")
27
+
28
+ # if submit is clicked
29
+ if submit:
30
+ st.subheader("The Response is")
31
+ st.write(response)
32
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ openai
2
+ streamlit
3
+ langhain
4
+ python-dotenv # helps to create and upload the variable with respect to our applications