Spaces:
Runtime error
Runtime error
amitguitarist
commited on
Commit
•
3a326d9
1
Parent(s):
296c92d
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.llms import OpenAI
|
2 |
+
#from dotenv import load_dotenv
|
3 |
+
|
4 |
+
#load_dotenv() #take environment variables from .env
|
5 |
+
|
6 |
+
import streamlit as st
|
7 |
+
import os
|
8 |
+
# Function to load OpenAI and get response
|
9 |
+
|
10 |
+
def get_openai_response(question):
|
11 |
+
llm=OpenAI(model_name="gpt-3.5-turbo-instruct",
|
12 |
+
temperature=0.6)
|
13 |
+
response = llm(question)
|
14 |
+
return response
|
15 |
+
|
16 |
+
# Initialize the Streamlit APP #
|
17 |
+
|
18 |
+
st.set_page_config(page_title="Q&A Demo")
|
19 |
+
st.header("Langchain Application")
|
20 |
+
|
21 |
+
input = st.text_input(label="Input: ", key="input")
|
22 |
+
|
23 |
+
response = get_openai_response(input)
|
24 |
+
|
25 |
+
submit = st.button(label="Ask the question")
|
26 |
+
|
27 |
+
# If the button is clicked
|
28 |
+
|
29 |
+
if submit:
|
30 |
+
st.subheader("The response is")
|
31 |
+
st.write(response)
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|