Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from config import settings | |
| import constants | |
| from llms import Agents | |
| import datetime | |
| agents = Agents(model="gpt-4o", model_type="openai", temperature=0.5, is_structured=False) | |
| def get_county_info(county_name): | |
| today = datetime.datetime.today().strftime("%Y-%m-%d") | |
| user_input = {"county": county_name, "today": today} | |
| response = agents.generate_tavily_search(f"{user_input}") | |
| return response["output"], gr.update(visible=False) | |
| # return "## ๐ Please select a county and click submit." | |
| # A list of county names for the dropdown. | |
| county_choices = constants.county_list | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("# IBHS County Profiler") | |
| gr.Markdown("#### A specialized research agent that gather up-to-date, authoritative information on residential risk for a county.") | |
| gr.Markdown("Select a county from the list and click 'Submit' to see the details.") | |
| with gr.Column(): | |
| county_dropdown = gr.Dropdown( | |
| choices=county_choices, | |
| label="Select a County" | |
| ) | |
| submit_button = gr.Button("Submit") | |
| progress = gr.Textbox(label="Progress bar", value="Status: Waiting for input...", interactive=False) | |
| output_markdown = gr.Markdown() | |
| # The click event of the button now triggers the function | |
| submit_button.click( | |
| fn=get_county_info, | |
| inputs=county_dropdown, | |
| outputs=[output_markdown, progress] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |