Spaces:
No application file
No application file
File size: 1,263 Bytes
049b08c | 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 | # 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) |