Spaces:
Runtime error
Runtime error
Upload 3 files
Browse filesFiles changed (3)
- bank.dbAdded
- policyBot.pyAdded+67
- requirements.txtAdded
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import openaiimport streamlit as stimport sqlite3from PIL import Imageimport time
openai.api_key = "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"# Database Connection
conn = sqlite3.connect('bank.db')c = conn.cursor()
def policyBot(): st.title("Welcome to OneInsurance ChatBot")
policy_doc_link = "https://www.hdfcergo.com/docs/default-source/downloads/policy-wordings/health/arogya-sanjeevani---a5-size---pw---hehi.pdf" st.write("Ask any question about the Health Insurance you selected")
question_2 = "Select the Institution from where you want the Insurance" options_2 = ["Bank of Baroda", "State Bank of India(SBI)", "HDFC Bank", "LIC"]
st.subheader(question_2) selected_option_2 = st.selectbox("Please enter your option:", options_2)
c.execute('SELECT Policy_Name FROM BANK WHERE Bank_Name= "{}"'.format(selected_option_2)) options_3 = c.fetchall()
# st.write(options_3) my_options = [] for row in options_3: my_options.append(row[0])
st.subheader("Select the Policy Name") selected_option_3 = st.selectbox("Please enter your option:", my_options) c.execute('SELECT Policy_doc FROM BANK WHERE Policy_Name = "{}"'.format(selected_option_3)) policy_doc_link = c.fetchone()
user_question = st.text_input( "Enter some text 👇", label_visibility="visible", disabled=False, placeholder="Please Enter your question here", )
question_response = openai.Completion.create( model="text-davinci-003", prompt="Read the following PDF Document\n\n{}\n\nAnswer the question based on the document provided\n{}?".format(policy_doc_link, user_question), temperature=0, max_tokens=260, top_p=1, frequency_penalty=0.5, presence_penalty=0, stop=["?"] ) user_answer = question_response.choices[0].text st.write(f"Answer: {user_answer}")
if __name__ == '__main__': policyBot()bank.dbAdded
policyBot.pyAdded+67
requirements.txtAdded