File size: 2,968 Bytes
fe8dffe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce483e6
a480eeb
 
fe8dffe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import openai
import streamlit as st
import sqlite3
from PIL import Image
import pandas as pd

openai.api_key = "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"
# Database Connection

conn = sqlite3.connect('bank.db')
c = conn.cursor()

def policyCompare():
    st.title("Compare Two Policy")

    with st.container():
        st.header("Select Policy 1")
        question_2 = "Select the Institution from where you want the Insurance"
        options_policy1 = ["Bank of Baroda", "State Bank of India(SBI)", "HDFC Bank", "LIC"]

        st.subheader(question_2)
        selected_option_policy1 = st.selectbox("Please enter your option for Policy 1:", options_policy1)



        c.execute('SELECT Policy_Name FROM BANK WHERE Bank_Name= "{}"'.format(selected_option_policy1))
        options_3 = c.fetchall()

            
        my_options = []
        for row in options_3:
            my_options.append(row[0])

        st.subheader("Select the Policy Name")
        selected_policy1 = st.selectbox("Please enter your option for Policy 1:", my_options)
                
        c.execute('SELECT Policy_doc FROM BANK WHERE Policy_Name = "{}"'.format(selected_policy1))
        policy_doc_link1 = c.fetchone()
    


    
    with st.container():
        st.header("Select Policy 2")
        question_2 = "Select the Institution from where you want the Insurance"
        options_policy2 = ["Bank of Baroda", "State Bank of India(SBI)", "HDFC Bank", "LIC"]

        st.subheader(question_2)
        selected_option_policy2 = st.selectbox("Please enter your option for Policy 2:", options_policy2)



        c.execute('SELECT Policy_Name FROM BANK WHERE Bank_Name= "{}"'.format(selected_option_policy2))
        options_3 = c.fetchall()

                # st.write(options_3)
        my_options2 = []
        for row in options_3:
            my_options2.append(row[0])

        st.subheader("Select the Policy Name")
        selected_policy2 = st.selectbox("Please enter your option for Policy 2:", my_options2)
                
        c.execute('SELECT Policy_doc FROM BANK WHERE Policy_Name = "{}"'.format(selected_policy1))
        policy_doc_link2 = c.fetchone()

    if(selected_policy2 != 0):
        st.header("Comparison")
        st.subheader("Policy 1 : {}".format(selected_policy1))
        st.subheader("Policy 2 : {}".format(selected_policy2))
        response = openai.Completion.create(
        model="text-davinci-003",
        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),
        temperature=0.05,
        max_tokens=300,
        top_p=1,
        frequency_penalty=0,
        presence_penalty=0,
        stop=[":-"]
        )

        compare_response = response.choices[0].text
        st.write(f"Answer: {compare_response}")

if __name__ == '__main__':
    policyCompare()