import gradio as gr from deal_agent_framework import DealAgentFramework from agents.deals import Opportunity, Deal class App: def __init__(self): self.agent_framework = None def run(self): with gr.Blocks(title="The Price is Right", fill_width=True) as ui: def table_for(opps): return [[opp.deal.product_description, f"${opp.deal.price:.2f}", f"${opp.estimate:.2f}", f"${opp.discount:.2f}", opp.deal.url] for opp in opps] def start(): self.agent_framework = DealAgentFramework() self.agent_framework.init_agents_as_needed() opportunities = self.agent_framework.memory table = table_for(opportunities) return table def go(): self.agent_framework.run() new_opportunities = self.agent_framework.memory table = table_for(new_opportunities) return table def do_select(selected_index: gr.SelectData): opportunities = self.agent_framework.memory row = selected_index.index[0] opportunity = opportunities[row] self.agent_framework.planner.messenger.alert(opportunity) with gr.Row(): gr.Markdown('