Irodakhan commited on
Commit
7c03828
1 Parent(s): c35b8e3

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q&A Chatbot
2
+ from langchain_openai import OpenAI
3
+ from dotenv import load_dotenv
4
+ import streamlit as st
5
+ import os
6
+
7
+ load_dotenv() # take environment variables from .env.
8
+
9
+ ## Function to load OpenAI model and get responses
10
+
11
+ def get_openai_response(question):
12
+ llm = OpenAI(openai_api_key=os.getenv('OPENAI_API_KEY'),model_name='gpt-3.5-turbo-instruct',
13
+ temperature=0.6)
14
+ response = llm.invoke(question)
15
+
16
+ return response
17
+
18
+ ## Initialize our streamlit app
19
+
20
+ st.set_page_config(page_title="Q&A Demo")
21
+ st.header("Langchain Application")
22
+
23
+ input = st.text_input("Input: ", key='input')
24
+ response = get_openai_response(input)
25
+
26
+ submit = st.button('Ask the question')
27
+
28
+ ## If ask button is clicked
29
+
30
+ if submit:
31
+ st.subheader("The Response is")
32
+ st.write(response)
33
+
34
+
35
+