dincertolga commited on
Commit
b2bf0dd
·
verified ·
1 Parent(s): ca6b0dd

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q&A Chatbot
2
+ from langchain_openai import OpenAI
3
+ from dotenv import load_dotenv
4
+ load_dotenv()
5
+ import streamlit as st
6
+ import os
7
+
8
+ #Function to load openAI model and get response
9
+
10
+ def get_openai_response(question):
11
+ llm = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"), temperature = 0.5)
12
+ response = llm(question)
13
+ return response
14
+ # initialize streamlit app
15
+
16
+ st.set_page_config(page_title="Q&A Demo")
17
+
18
+ st.header("Langchain Application")
19
+
20
+ input = st.text_input("Input: ", key=input)
21
+ response = get_openai_response(input)
22
+
23
+ submit = st.button("Ask the question")
24
+
25
+ #If ask button is clicked
26
+ if submit:
27
+ st.subheader("The Response is")
28
+ st.write(response)
29
+