Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- bank.db +0 -0
- policyBot.py +67 -0
- requirements.txt +0 -0
bank.db
ADDED
|
Binary file (24.6 kB). View file
|
|
|
policyBot.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import sqlite3
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import time
|
| 6 |
+
|
| 7 |
+
openai.api_key = "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"
|
| 8 |
+
# Database Connection
|
| 9 |
+
|
| 10 |
+
conn = sqlite3.connect('bank.db')
|
| 11 |
+
c = conn.cursor()
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def policyBot():
|
| 15 |
+
st.title("Welcome to OneInsurance ChatBot")
|
| 16 |
+
|
| 17 |
+
policy_doc_link = "https://www.hdfcergo.com/docs/default-source/downloads/policy-wordings/health/arogya-sanjeevani---a5-size---pw---hehi.pdf"
|
| 18 |
+
st.write("Ask any question about the Health Insurance you selected")
|
| 19 |
+
|
| 20 |
+
question_2 = "Select the Institution from where you want the Insurance"
|
| 21 |
+
options_2 = ["Bank of Baroda", "State Bank of India(SBI)", "HDFC Bank", "LIC"]
|
| 22 |
+
|
| 23 |
+
st.subheader(question_2)
|
| 24 |
+
selected_option_2 = st.selectbox("Please enter your option:", options_2)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
c.execute('SELECT Policy_Name FROM BANK WHERE Bank_Name= "{}"'.format(selected_option_2))
|
| 29 |
+
options_3 = c.fetchall()
|
| 30 |
+
|
| 31 |
+
# st.write(options_3)
|
| 32 |
+
my_options = []
|
| 33 |
+
for row in options_3:
|
| 34 |
+
my_options.append(row[0])
|
| 35 |
+
|
| 36 |
+
st.subheader("Select the Policy Name")
|
| 37 |
+
selected_option_3 = st.selectbox("Please enter your option:", my_options)
|
| 38 |
+
|
| 39 |
+
c.execute('SELECT Policy_doc FROM BANK WHERE Policy_Name = "{}"'.format(selected_option_3))
|
| 40 |
+
policy_doc_link = c.fetchone()
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
user_question = st.text_input(
|
| 44 |
+
"Enter some text 👇",
|
| 45 |
+
label_visibility="visible",
|
| 46 |
+
disabled=False,
|
| 47 |
+
placeholder="Please Enter your question here",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
question_response = openai.Completion.create(
|
| 51 |
+
model="text-davinci-003",
|
| 52 |
+
prompt="Read the following PDF Document\n\n{}\n\nAnswer the question based on the document provided\n{}?".format(policy_doc_link, user_question),
|
| 53 |
+
temperature=0,
|
| 54 |
+
max_tokens=260,
|
| 55 |
+
top_p=1,
|
| 56 |
+
frequency_penalty=0.5,
|
| 57 |
+
presence_penalty=0,
|
| 58 |
+
stop=["?"]
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
user_answer = question_response.choices[0].text
|
| 62 |
+
st.write(f"Answer: {user_answer}")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
if __name__ == '__main__':
|
| 67 |
+
policyBot()
|
requirements.txt
ADDED
|
Binary file (220 Bytes). View file
|
|
|