AIdvisor / app.py
Krishna Kumar S
cc
049b08c
# This is a Gradio app that includes a chat interface and a button to run a function.
import gradio as gr
import random
# Define a function that returns a random response for the chat interface.
def random_response(message, history):
return random.choice(["Yes", "No"])
# Define a function that returns a message when the button is clicked.
def run_button_clicked(input_text):
insurer_name = input_text
#df = fetch_and_download_policy_documents(insurer=insurer_name, UIN='', results=999, save_path='./policy_docs')
#return f"Fetched {len(df)} policies for insurer '{insurer_name}'."
return insurer_name
# Create a Gradio Blocks app.
with gr.Blocks() as demo:
with gr.Tab("Chat"):
# Create a chat interface that uses the random_response function.
chat_interface = gr.ChatInterface(random_response, type="messages", autofocus=False)
with gr.Tab("Run"):
input_text = gr.Textbox(label="Insurer Name...")
run_button = gr.Button("Get Policies from IRDAI")
text_output = gr.Textbox(label="Result", interactive=False)
run_button.click(fn=run_button_clicked, inputs=[input_text], outputs=[text_output])
# Launch the Gradio app.
if __name__ == "__main__":
demo.launch(show_error=True)