saint324 commited on
Commit
5dbfcd2
·
1 Parent(s): 350ba01

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q & A Chatbot demo
2
+ from langchain.llms import OpenAI
3
+ from dotenv import load_dotenv
4
+ import streamlit as st
5
+ import os
6
+ load_dotenv()
7
+
8
+ # Function to load OpenAI model and get response
9
+
10
+ def get_openai_response(question):
11
+ llm = OpenAI(model_name= 'text-davinci-003',
12
+ temperature=0.6,
13
+ openai_api_key=os.getenv('OPENAI_API_KEY'))
14
+ response = llm(question)
15
+ return response
16
+
17
+
18
+ st.set_page_config(page_title='Q&A Demo')
19
+ st.header("Simple Question and Answer App")
20
+
21
+ input = st.text_input("Write here:", key="input")
22
+ response = get_openai_response(input)
23
+
24
+ submit = st.button("What did you say?")
25
+
26
+ if submit:
27
+ st.subheader("Hmmm... \n")
28
+ st.write(response)