Spaces:
Sleeping
Sleeping
mehtameet2802
commited on
Commit
•
4dd479a
1
Parent(s):
958c71a
Upload 2 files
Browse files- app.py +27 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from langchain.llms import OpenAI
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
import os
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
|
9 |
+
def get_openai_response(question):
|
10 |
+
llm = OpenAI(openai_api_key=os.environ["OPENAI_API_KEY"],
|
11 |
+
model_name="gpt-3.5-turbo-instruct", temperature=0.5)
|
12 |
+
response = llm(question)
|
13 |
+
return response
|
14 |
+
|
15 |
+
|
16 |
+
st.set_page_config(page_title="Q&A Demo")
|
17 |
+
|
18 |
+
st.header("Langchain Application")
|
19 |
+
|
20 |
+
input = st.text_input("Input: ", key="input")
|
21 |
+
response = get_openai_response(input)
|
22 |
+
|
23 |
+
submit = st.button("Ask the question")
|
24 |
+
|
25 |
+
if submit:
|
26 |
+
st.subheader("The Response is")
|
27 |
+
st.write(response)
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain
|
2 |
+
openai
|
3 |
+
huggingface-hub
|
4 |
+
python-dotenv
|
5 |
+
streamlit
|