Spaces:
Sleeping
Sleeping
DannyDCoder
commited on
Commit
•
7a4eda4
1
Parent(s):
19c9ee7
Upload 2 files
Browse files- app.py +20 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.llms import OpenAI
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
import streamlit as st
|
4 |
+
import os
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
def get_openai_response(request):
|
9 |
+
llm = OpenAI(openai_api_key = os.getenv("OPENAI_API_KEY") , temperature=0.6)
|
10 |
+
return llm.predict(request)
|
11 |
+
|
12 |
+
st.set_page_config(page_title="Q&A Demo")
|
13 |
+
st.header("Langchain Application")
|
14 |
+
input = st.text_input("Input: ", key = "input")
|
15 |
+
submit = st.button("Generate")
|
16 |
+
|
17 |
+
if submit:
|
18 |
+
response = get_openai_response(input)
|
19 |
+
st.subheader("The response is : ")
|
20 |
+
st.write(response)
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain
|
2 |
+
openai
|
3 |
+
huggingface_hub
|
4 |
+
python-dotenv
|
5 |
+
streamlit
|