Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- bank.db +0 -0
- comparePolicy.py +83 -0
- requirements.txt +0 -0
bank.db
ADDED
Binary file (24.6 kB). View file
|
|
comparePolicy.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import streamlit as st
|
3 |
+
import sqlite3
|
4 |
+
from PIL import Image
|
5 |
+
import pandas as pd
|
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 |
+
def policyCompare():
|
14 |
+
st.title("Compare Two Policy")
|
15 |
+
|
16 |
+
with st.container():
|
17 |
+
st.header("Select Policy 1")
|
18 |
+
question_2 = "Select the Institution from where you want the Insurance"
|
19 |
+
options_policy1 = ["Bank of Baroda", "State Bank of India(SBI)", "HDFC Bank", "LIC"]
|
20 |
+
|
21 |
+
st.subheader(question_2)
|
22 |
+
selected_option_policy1 = st.selectbox("Please enter your option for Policy 1:", options_policy1)
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
c.execute('SELECT Policy_Name FROM BANK WHERE Bank_Name= "{}"'.format(selected_option_policy1))
|
27 |
+
options_3 = c.fetchall()
|
28 |
+
|
29 |
+
|
30 |
+
my_options = []
|
31 |
+
for row in options_3:
|
32 |
+
my_options.append(row[0])
|
33 |
+
|
34 |
+
st.subheader("Select the Policy Name")
|
35 |
+
selected_policy1 = st.selectbox("Please enter your option for Policy 1:", my_options)
|
36 |
+
|
37 |
+
c.execute('SELECT Policy_doc FROM BANK WHERE Policy_Name = "{}"'.format(selected_policy1))
|
38 |
+
policy_doc_link1 = c.fetchone()
|
39 |
+
|
40 |
+
with st.container():
|
41 |
+
st.header("Select Policy 2")
|
42 |
+
question_2 = "Select the Institution from where you want the Insurance"
|
43 |
+
options_policy2 = ["Bank of Baroda", "State Bank of India(SBI)", "HDFC Bank", "LIC"]
|
44 |
+
|
45 |
+
st.subheader(question_2)
|
46 |
+
selected_option_policy2 = st.selectbox("Please enter your option for Policy 2:", options_policy2)
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
c.execute('SELECT Policy_Name FROM BANK WHERE Bank_Name= "{}"'.format(selected_option_policy2))
|
51 |
+
options_3 = c.fetchall()
|
52 |
+
|
53 |
+
# st.write(options_3)
|
54 |
+
my_options2 = []
|
55 |
+
for row in options_3:
|
56 |
+
my_options2.append(row[0])
|
57 |
+
|
58 |
+
st.subheader("Select the Policy Name")
|
59 |
+
selected_policy2 = st.selectbox("Please enter your option for Policy 2:", my_options2)
|
60 |
+
|
61 |
+
c.execute('SELECT Policy_doc FROM BANK WHERE Policy_Name = "{}"'.format(selected_policy1))
|
62 |
+
policy_doc_link2 = c.fetchone()
|
63 |
+
|
64 |
+
if(selected_policy2 != 0):
|
65 |
+
st.header("Comparison")
|
66 |
+
st.subheader("Policy 1 : {}".format(selected_policy1))
|
67 |
+
st.subheader("Policy 2 : {}".format(selected_policy2))
|
68 |
+
response = openai.Completion.create(
|
69 |
+
model="text-davinci-003",
|
70 |
+
prompt="Compare the two health insurance policy using the policy document\nPolicy 1 Document: {},\nPolicy 2 Document: {}\nStrictly show the answer in tabular format:-".format(policy_doc_link1, policy_doc_link2),
|
71 |
+
temperature=0.05,
|
72 |
+
max_tokens=300,
|
73 |
+
top_p=1,
|
74 |
+
frequency_penalty=0,
|
75 |
+
presence_penalty=0,
|
76 |
+
stop=[":-"]
|
77 |
+
)
|
78 |
+
|
79 |
+
compare_response = response.choices[0].text
|
80 |
+
st.write(f"Answer: {compare_response}")
|
81 |
+
|
82 |
+
if __name__ == '__main__':
|
83 |
+
policyCompare()
|
requirements.txt
ADDED
Binary file (220 Bytes). View file
|
|