Anoop Srivastava commited on
Commit
6b75f5e
·
1 Parent(s): 811e2c8

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q&A chatbot
2
+
3
+ from langchain.llms import openai, OpenAI
4
+ from dotenv import load_dotenv
5
+ import streamlit as st
6
+ import os
7
+
8
+ # take environment variables from .env
9
+ load_dotenv()
10
+
11
+ # Function to load OpenAI model and get response
12
+
13
+ def get_openai_reponse(question):
14
+ llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"), model_name='text-davinci-003',
15
+ temperature=0.6)
16
+ response = llm(question)
17
+ return response
18
+
19
+ # initialize our streamlit app
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_reponse(input)
25
+
26
+ submit = st.button("Ask the question")
27
+
28
+ # If ask button is clicked
29
+ if submit:
30
+ st.subheader("The response is: ")
31
+ st.write(response)
32
+