Spaces:
Sleeping
Sleeping
File size: 1,509 Bytes
851b838 | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 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()
|