vaish026 commited on
Commit
12d13db
1 Parent(s): cd4f5d0

Uploading app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q & A chatbot
2
+ from langchain.llms 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
+ def get_open_ai_response(question):
10
+ llm = OpenAI(api_key = os.getenv("OPEN_AI_KEY"), model_name = "gpt-3.5-turbo-instruct", temperature=0.5)
11
+ response = llm(question)
12
+ return response
13
+
14
+ # initialise streamlit app
15
+ st.set_page_config(page_title="Q&A Demo")
16
+ st.header("Langchain Application")
17
+
18
+ input = st.text_input("Input: ", key = input)
19
+ response = get_open_ai_response(input)
20
+
21
+ submit = st.button("Ask the question now")
22
+
23
+ # If ask button is clicked
24
+ if submit:
25
+ st.subheader("The Response is")
26
+ st.write(response)