Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +34 -0
- requirement.txt +6 -0
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Q&A Chatbot
|
2 |
+
from langchain.llms import OpenAI
|
3 |
+
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
load_dotenv() # takes the enveronment vareable from .env
|
7 |
+
|
8 |
+
import streamlit as st
|
9 |
+
import os
|
10 |
+
|
11 |
+
## function to lad the openai model and to get the response
|
12 |
+
|
13 |
+
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
|
14 |
+
|
15 |
+
|
16 |
+
def get_openai_response(question):
|
17 |
+
llm = OpenAI(model_name="gpt-3.5-turbo-0125",temperature =0.6)
|
18 |
+
response = llm(question)
|
19 |
+
return response
|
20 |
+
#initialize out streamlit app
|
21 |
+
st.set_page_config(page_title='Q&A Demo')
|
22 |
+
|
23 |
+
st.header("langchain application")
|
24 |
+
|
25 |
+
input=st.text_input("Input: ", key = "input")
|
26 |
+
response=get_openai_response(input)
|
27 |
+
|
28 |
+
|
29 |
+
submit=st.button("generate")
|
30 |
+
|
31 |
+
|
32 |
+
if submit:
|
33 |
+
st.subheader("The response is ")
|
34 |
+
st.write(response)
|
requirement.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
langchain
|
3 |
+
streamlit
|
4 |
+
ipykernel
|
5 |
+
huggingface_hub
|
6 |
+
python-dotenv
|