Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# # QandA chatbot
|
2 |
+
# from langchain.llms import OpenAI
|
3 |
+
from langchain.chains import LLMChain
|
4 |
+
from langchain_community.llms import OpenAI
|
5 |
+
|
6 |
+
#from dotenv import load_dotenv
|
7 |
+
import os
|
8 |
+
|
9 |
+
# load_dotenv()
|
10 |
+
|
11 |
+
|
12 |
+
import streamlit as st
|
13 |
+
|
14 |
+
## Function to lod OpenAI model and get responses
|
15 |
+
|
16 |
+
def get_openai_response(question): ## not os.environ["OPEN_API_KEY"] use openai_api_key=os.getenv("OPEN_API_KEY")
|
17 |
+
llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"),temperature=0.6)
|
18 |
+
response = llm(question)
|
19 |
+
|
20 |
+
|
21 |
+
return response
|
22 |
+
|
23 |
+
st.set_page_config(page_title="QandA Chatbot", page_icon=":robot:")
|
24 |
+
|
25 |
+
st.header("Langchain Application")
|
26 |
+
|
27 |
+
input = st.text_input("Enter your question here: ",key="input")
|
28 |
+
response = get_openai_response(input)
|
29 |
+
|
30 |
+
|
31 |
+
submit = st.button("Submit/Generate")
|
32 |
+
|
33 |
+
## If ask button is clicked
|
34 |
+
if submit:
|
35 |
+
st.header("The response is:")
|
36 |
+
st.write(response)
|
37 |
+
|