bphc commited on
Commit
7fd6477
1 Parent(s): e7ec5e7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_openai import OpenAI
2
+ from dotenv import load_dotenv
3
+ import streamlit as st
4
+ import os
5
+
6
+ load_dotenv()
7
+
8
+ def get_openai_response(question):
9
+ llm = OpenAI(api_key=os.getenv("OPENAI_API_KEY"), model="gpt-3.5-turbo-instruct", temperature=0.5)
10
+ response = llm.invoke([{"role": "user", "content": question}])
11
+ return response
12
+
13
+ st.set_page_config(page_title="Q&A Demo")
14
+ st.header("Langchain Application")
15
+
16
+ input_text = st.text_input("Input: ", key="input")
17
+ submit = st.button("Ask the question")
18
+
19
+ if submit:
20
+ response = get_openai_response(input_text)
21
+ # print(response)
22
+ st.subheader("The response is:")
23
+ st.write(response)