Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,24 @@
|
|
1 |
# q & a chatbot
|
2 |
from langchain.llms import OpenAI
|
3 |
-
|
4 |
from dotenv import load_dotenv
|
5 |
-
|
6 |
-
load_dotenv() # take environment varibales from .env
|
7 |
-
|
8 |
import streamlit as st
|
9 |
-
import os
|
|
|
|
|
10 |
|
11 |
# lets make a function for calling the llm
|
12 |
def get_openai_response(question):
|
13 |
-
llm=OpenAI(openai_api_key
|
14 |
response = llm(question)
|
15 |
return response
|
16 |
|
17 |
-
# Streamlit app
|
18 |
-
|
19 |
-
|
20 |
st.header("Langchain Application")
|
21 |
|
22 |
-
|
23 |
-
get_openai_response(input)
|
24 |
-
|
25 |
-
submit = st.button("Ask the question")
|
26 |
|
27 |
# if ask button is clicked
|
28 |
-
|
29 |
-
|
30 |
st.subheader("the response is")
|
31 |
-
st.write(response)
|
|
|
1 |
# q & a chatbot
|
2 |
from langchain.llms import OpenAI
|
|
|
3 |
from dotenv import load_dotenv
|
|
|
|
|
|
|
4 |
import streamlit as st
|
5 |
+
import os
|
6 |
+
|
7 |
+
load_dotenv() # take environment variables from .env
|
8 |
|
9 |
# lets make a function for calling the llm
|
10 |
def get_openai_response(question):
|
11 |
+
llm = OpenAI(openai_api_key="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", temperature=0.6)
|
12 |
response = llm(question)
|
13 |
return response
|
14 |
|
15 |
+
# Streamlit app
|
|
|
|
|
16 |
st.header("Langchain Application")
|
17 |
|
18 |
+
input_question = st.text_input("input : ", key="input")
|
|
|
|
|
|
|
19 |
|
20 |
# if ask button is clicked
|
21 |
+
if st.button("Ask the question"):
|
22 |
+
response = get_openai_response(input_question)
|
23 |
st.subheader("the response is")
|
24 |
+
st.write(response)
|