CoolFace
Apppublic

nikesh66/comparepolicy

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
app.py83 linesDownload Raw Back to root
1import openai2import streamlit as st3import sqlite34from PIL import Image5import pandas as pd6 7openai.api_key = "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"8# Database Connection9 10conn = sqlite3.connect('bank.db')11c = conn.cursor()12 13def 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].text80        st.write(f"Answer: {compare_response}")81 82if __name__ == '__main__':83    policyCompare()