Ashutosh1127 commited on
Commit
de37483
·
verified ·
1 Parent(s): 2570099

Upload app.py

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