Spaces:
Sleeping
Sleeping
Kabirsingla
commited on
Commit
·
a2088b7
1
Parent(s):
3171f22
Upload 2 files
Browse files- app.py +28 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.llms import OpenAI
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
load_dotenv()
|
4 |
+
import streamlit as st
|
5 |
+
import os
|
6 |
+
|
7 |
+
|
8 |
+
# Function to load OpenAI model and get response
|
9 |
+
def get_openAI_respnse(question):
|
10 |
+
llm = OpenAI(model_name="text-davinci-003", temperature=0.5)
|
11 |
+
response = llm(question)
|
12 |
+
return response
|
13 |
+
|
14 |
+
|
15 |
+
## Intitialize Streamlit app
|
16 |
+
st.set_page_config(page_title = "Q&A Demo")
|
17 |
+
st.header("LangChain App")
|
18 |
+
|
19 |
+
input = st.text_input("Enter your question here", key="input")
|
20 |
+
response = get_openAI_respnse(input)
|
21 |
+
|
22 |
+
submit = st.button("Generate")
|
23 |
+
|
24 |
+
|
25 |
+
#If submit button is clicked
|
26 |
+
if submit:
|
27 |
+
st.subheader("The response is")
|
28 |
+
st.write(response)
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain
|
2 |
+
openai
|
3 |
+
huggingface_hub
|
4 |
+
python-dotenv
|
5 |
+
streamlit
|