{ "cells": [ { "cell_type": "markdown", "id": "a71ed017-e1b0-4299-88b3-f0eb05adc4df", "metadata": {}, "source": [ "# The Price is Right\n", "\n", "The final step is to build a User Interface\n", "\n", "We will use more advanced aspects of Gradio - building piece by piece." ] }, { "cell_type": "code", "execution_count": null, "id": "614c6202-4575-448d-98ee-78b735775d2b", "metadata": {}, "outputs": [], "source": [ "import gradio as gr\n", "from deal_agent_framework import DealAgentFramework\n", "from agents.deals import Opportunity, Deal" ] }, { "cell_type": "code", "execution_count": null, "id": "0534e714-5a9c-45c6-998c-3472ac0bb8b5", "metadata": {}, "outputs": [], "source": [ "with gr.Blocks(title=\"The Price is Right\", fill_width=True) as ui:\n", "\n", " with gr.Row():\n", " gr.Markdown('
The Price is Right - Deal Hunting Agentic AI
')\n", " with gr.Row():\n", " gr.Markdown('
Autonomous agent framework that finds online deals, collaborating with a proprietary fine-tuned LLM deployed on Modal, and a RAG pipeline with a frontier model and Chroma.
')\n", " \n", "\n", "ui.launch(inbrowser=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "18c12c10-750c-4da3-8df5-f2bc3393f9e0", "metadata": {}, "outputs": [], "source": [ "# Updated to change from height to max_height due to change in Gradio v5\n", "# With much thanks to student Ed B. for raising this\n", "\n", "with gr.Blocks(title=\"The Price is Right\", fill_width=True) as ui:\n", "\n", " initial_deal = Deal(product_description=\"Example description\", price=100.0, url=\"https://cnn.com\")\n", " initial_opportunity = Opportunity(deal=initial_deal, estimate=200.0, discount=100.0)\n", " opportunities = gr.State([initial_opportunity])\n", "\n", " def get_table(opps):\n", " return [[opp.deal.product_description, opp.deal.price, opp.estimate, opp.discount, opp.deal.url] for opp in opps]\n", "\n", " with gr.Row():\n", " gr.Markdown('
\"The Price is Right\" - Deal Hunting Agentic AI
')\n", " with gr.Row():\n", " gr.Markdown('
Deals surfaced so far:
')\n", " with gr.Row():\n", " opportunities_dataframe = gr.Dataframe(\n", " headers=[\"Description\", \"Price\", \"Estimate\", \"Discount\", \"URL\"],\n", " wrap=True,\n", " column_widths=[4, 1, 1, 1, 2],\n", " row_count=10,\n", " col_count=5,\n", " max_height=400,\n", " )\n", "\n", " ui.load(get_table, inputs=[opportunities], outputs=[opportunities_dataframe])\n", "\n", "ui.launch(inbrowser=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "87106328-a17a-447e-90b9-c547613468da", "metadata": {}, "outputs": [], "source": [ "agent_framework = DealAgentFramework()\n", "agent_framework.init_agents_as_needed()\n", "\n", "with gr.Blocks(title=\"The Price is Right\", fill_width=True) as ui:\n", "\n", " initial_deal = Deal(product_description=\"Example description\", price=100.0, url=\"https://cnn.com\")\n", " initial_opportunity = Opportunity(deal=initial_deal, estimate=200.0, discount=100.0)\n", " opportunities = gr.State([initial_opportunity])\n", "\n", " def get_table(opps):\n", " return [[opp.deal.product_description, opp.deal.price, opp.estimate, opp.discount, opp.deal.url] for opp in opps]\n", "\n", " def do_select(opportunities, selected_index: gr.SelectData):\n", " row = selected_index.index[0]\n", " opportunity = opportunities[row]\n", " agent_framework.planner.messenger.alert(opportunity)\n", "\n", " with gr.Row():\n", " gr.Markdown('
\"The Price is Right\" - Deal Hunting Agentic AI
')\n", " with gr.Row():\n", " gr.Markdown('
Deals surfaced so far:
')\n", " with gr.Row():\n", " opportunities_dataframe = gr.Dataframe(\n", " headers=[\"Description\", \"Price\", \"Estimate\", \"Discount\", \"URL\"],\n", " wrap=True,\n", " column_widths=[4, 1, 1, 1, 2],\n", " row_count=10,\n", " col_count=5,\n", " max_height=400,\n", " )\n", "\n", " ui.load(get_table, inputs=[opportunities], outputs=[opportunities_dataframe])\n", " opportunities_dataframe.select(do_select, inputs=[opportunities], outputs=[])\n", "\n", "ui.launch(inbrowser=True)" ] }, { "cell_type": "markdown", "id": "ecfed67b-ebcb-4e17-ad15-a7151f940119", "metadata": {}, "source": [ "# Time for the code\n", "\n", "And now we'll move to the price_is_right.py code, followed by price_is_right_final.py" ] }, { "cell_type": "markdown", "id": "d783af8a-08a8-4e59-886a-7ca32f16bcf5", "metadata": {}, "source": [ "# Running the final product\n", "\n", "## Just hit shift + enter in the next cell, and let the deals flow in!!\n", "\n", "Note that the Frontier Agent will use DeepSeek if there's a DEEPSEEK_API_KEY in your .env file, otherwise gpt-4o-mini." ] }, { "cell_type": "code", "execution_count": null, "id": "48506465-1c7a-433f-a665-b277a8b4665c", "metadata": {}, "outputs": [], "source": [ "!python price_is_right_final.py" ] }, { "cell_type": "markdown", "id": "242d1243-fbec-4807-988b-8f70c8c9b806", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

But wait!! There's more..

\n", " If you're not fed up of product prices yet 😂 I've built this out some more!
\n", " If you look in my repo tech2ai, in segment3/lab1 is a neural network implementation of the pricer in pure PyTorch. It does pretty well..
\n", " And in segment4/agents is this same Agent project taken further. There's a new version of the PlanningAgent called AutonomousPlanningAgent that uses multiple Tools, and a MessagingAgent that uses claude-3.7 to write texts.
\n", " You could experiment with similar ideas to build out this framework.\n", "
\n", "
" ] }, { "cell_type": "markdown", "id": "331a2044-566f-4866-be4d-7542b7dfdf3f", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

CONGRATULATIONS AND THANK YOU!!!

\n", " \n", " It's so fabulous that you've made it to the very end! My heartiest congratulations. Please stay in touch! I'm here on LinkedIn if we're not already connected and I'm on X at @edwarddonner. And my editor would be cross with me if I didn't mention one more time: it makes a HUGE difference when students rate this course on Udemy - it's one of the main ways that Udemy decides whether to show it to others.

Massive thanks again for putting up with me for 8 weeks and getting all the way to the final cell! I'm excited to hear all about your career as an LLM Engineer. If you post on LinkedIn about completing the course and tag me, then I'll weigh in to amplify your achievement.
You could not have picked a better time to be in this field.\n", "
\n", "
" ] }, { "cell_type": "code", "execution_count": null, "id": "f9dd0a27-7d46-4c9e-bbe4-a61c9c899c99", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.11" } }, "nbformat": 4, "nbformat_minor": 5 }