Upload 3 files
Browse files- .env +1 -0
- app.py +32 -0
- 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
|