Spaces:
Sleeping
Sleeping
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
def get_llm_response(question):
|
9 |
+
llm = OpenAI(openai_api_key=os.getenv("OPENAI_API_KEY"), model_name="gpt-3.5-turbo-instruct", temperature=0.5)
|
10 |
+
response = llm(question)
|
11 |
+
return response
|
12 |
+
|
13 |
+
st.set_page_config(page_title="Q&A Demo", page_icon="🔗", layout="wide")
|
14 |
+
st.header("LangChain Application")
|
15 |
+
|
16 |
+
input = st.text_input("INPUT: ", key="input")
|
17 |
+
submit_button = st.button("Ask a question")
|
18 |
+
|
19 |
+
response = get_llm_response(input)
|
20 |
+
if submit_button:
|
21 |
+
st.subheader("The response is")
|
22 |
+
st.write(response)
|