Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,34 @@
|
|
| 1 |
-
from
|
| 2 |
-
from dotenv import load_dotenv
|
| 3 |
-
import streamlit as st
|
| 4 |
-
import os
|
| 5 |
-
|
| 6 |
-
load_dotenv()
|
| 7 |
-
|
| 8 |
-
## Function to load OpenAI model and get response
|
| 9 |
-
|
| 10 |
-
def get_openai_response(question):
|
| 11 |
-
llm = OpenAI(openai_api_key = os.getenv("OPEN_API_KEY"),
|
| 12 |
-
temperature= 0.5)
|
| 13 |
-
|
| 14 |
-
response = llm(question)
|
| 15 |
-
|
| 16 |
-
return response
|
| 17 |
-
|
| 18 |
-
## Initialize our streamlit app
|
| 19 |
-
|
| 20 |
-
st.set_page_config(page_title="Q&A Demo")
|
| 21 |
-
|
| 22 |
-
st.header("Langchain Application")
|
| 23 |
-
|
| 24 |
-
input1 = st.text_input("Input: ", key="input")
|
| 25 |
-
response = get_openai_response(input1)
|
| 26 |
-
|
| 27 |
-
submit = st.button("Generate")
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
## If generate button is clicked
|
| 31 |
-
|
| 32 |
-
if submit:
|
| 33 |
-
st.subheader("The response is")
|
| 34 |
st.write(response)
|
|
|
|
| 1 |
+
from langchain.llms import OpenAI
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
## Function to load OpenAI model and get response
|
| 9 |
+
|
| 10 |
+
def get_openai_response(question):
|
| 11 |
+
llm = OpenAI(openai_api_key = os.getenv("OPEN_API_KEY"),
|
| 12 |
+
temperature= 0.5)
|
| 13 |
+
|
| 14 |
+
response = llm(question)
|
| 15 |
+
|
| 16 |
+
return response
|
| 17 |
+
|
| 18 |
+
## Initialize our streamlit app
|
| 19 |
+
|
| 20 |
+
st.set_page_config(page_title="Q&A Demo")
|
| 21 |
+
|
| 22 |
+
st.header("Langchain Application")
|
| 23 |
+
|
| 24 |
+
input1 = st.text_input("Input: ", key="input")
|
| 25 |
+
response = get_openai_response(input1)
|
| 26 |
+
|
| 27 |
+
submit = st.button("Generate")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
## If generate button is clicked
|
| 31 |
+
|
| 32 |
+
if submit:
|
| 33 |
+
st.subheader("The response is")
|
| 34 |
st.write(response)
|