{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Installing hub:\u001b[35m/\u001b[0m\u001b[35m/guardrails/\u001b[0m\u001b[95mregex_match...\u001b[0m\n", "✅Successfully installed guardrails/regex_match!\n", "\n", "\n" ] } ], "source": [ "! guardrails hub install hub://guardrails/regex_match --quiet" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "chat_history = \"\"\"\n", "nelson and murdock: i need a pickup 797 9th Avenue, manila envelope, June 3 10:00am with dropoff 10:30am Courthouse, 61 Center Street C/O frank james\n", "operator: quote - $23.00\n", "neslon and murdock: perfect, we accept the quote\n", "operator: 797 9th ave, 10:00am pickup comfirmed\n", "abc flowers: i need a pickup of a flowers from abc flowers at 21 3rd street at 11:00am on june 2 with a dropoff at 75th Ave at 5:30pm same day\n", "operator: 21 3rd street flowers quote - $14.50\n", "abc flowers: accepted\n", "polk and wardell: i need a pickup of a bagels from Bakers Co at 331 5th street at 11:00am on june 3 with a dropoff at 75th Ave at 5:30pm same day\n", "operator: 331 5th street bagels quote - $34.50\n", "polk and wardell: accepted\n", "\"\"\"\n", "\n", "prompt = \"\"\"\n", "From the chat exchanges below extract a schedule of deliveries.\n", "Chats:\n", "${chat_history}\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[\n", " {\n", " 'type': 'function',\n", " 'function': {\n", " 'name': 'gd_response_tool',\n", " 'description': 'A tool for generating responses to guardrails. It must be called last in every \n", "response.',\n", " 'parameters': {\n", " '$defs': {\n", " 'Delivery': {\n", " 'properties': {\n", " 'custome_name': {\n", " 'description': 'customer name',\n", " 'title': 'Custome Name',\n", " 'type': 'string',\n", " 'validators': [{'rail_alias': 'guardrails/regex_match'}]\n", " },\n", " 'pickup_time': {\n", " 'description': 'date and time of pickup',\n", " 'title': 'Pickup Time',\n", " 'type': 'string'\n", " },\n", " 'pickup_location': {\n", " 'description': 'address of pickup',\n", " 'title': 'Pickup Location',\n", " 'type': 'string'\n", " },\n", " 'dropoff_time': {\n", " 'description': 'date and time of dropoff',\n", " 'title': 'Dropoff Time',\n", " 'type': 'string'\n", " },\n", " 'dropoff_location': {\n", " 'description': 'address of dropoff',\n", " 'title': 'Dropoff Location',\n", " 'type': 'string'\n", " },\n", " 'price': {\n", " 'description': 'price of delivery with currency symbol included',\n", " 'title': 'Price',\n", " 'type': 'string'\n", " }\n", " },\n", " 'required': [\n", " 'custome_name',\n", " 'pickup_time',\n", " 'pickup_location',\n", " 'dropoff_time',\n", " 'dropoff_location',\n", " 'price'\n", " ],\n", " 'title': 'Delivery',\n", " 'type': 'object'\n", " }\n", " },\n", " 'properties': {\n", " 'deliveries': {'items': {'$ref': '#/$defs/Delivery'}, 'title': 'Deliveries', 'type': 'array'}\n", " },\n", " 'required': ['deliveries'],\n", " 'type': 'object',\n", " 'title': 'Schedule'\n", " },\n", " 'required': ['deliveries']\n", " }\n", " }\n", "]\n", "\n" ], "text/plain": [ "\u001b[1m[\u001b[0m\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'function'\u001b[0m,\n", " \u001b[32m'function'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'name'\u001b[0m: \u001b[32m'gd_response_tool'\u001b[0m,\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'A tool for generating responses to guardrails. It must be called last in every \u001b[0m\n", "\u001b[32mresponse.'\u001b[0m,\n", " \u001b[32m'parameters'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'$defs'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'Delivery'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'properties'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'custome_name'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'customer name'\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Custome Name'\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m,\n", " \u001b[32m'validators'\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m{\u001b[0m\u001b[32m'rail_alias'\u001b[0m: \u001b[32m'guardrails/regex_match'\u001b[0m\u001b[1m}\u001b[0m\u001b[1m]\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'pickup_time'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'date and time of pickup'\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Pickup Time'\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'pickup_location'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'address of pickup'\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Pickup Location'\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'dropoff_time'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'date and time of dropoff'\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Dropoff Time'\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'dropoff_location'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'address of dropoff'\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Dropoff Location'\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'price'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'price of delivery with currency symbol included'\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Price'\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'required'\u001b[0m: \u001b[1m[\u001b[0m\n", " \u001b[32m'custome_name'\u001b[0m,\n", " \u001b[32m'pickup_time'\u001b[0m,\n", " \u001b[32m'pickup_location'\u001b[0m,\n", " \u001b[32m'dropoff_time'\u001b[0m,\n", " \u001b[32m'dropoff_location'\u001b[0m,\n", " \u001b[32m'price'\u001b[0m\n", " \u001b[1m]\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Delivery'\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'object'\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'properties'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'deliveries'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'items'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'$ref'\u001b[0m: \u001b[32m'#/$defs/Delivery'\u001b[0m\u001b[1m}\u001b[0m, \u001b[32m'title'\u001b[0m: \u001b[32m'Deliveries'\u001b[0m, \u001b[32m'type'\u001b[0m: \u001b[32m'array'\u001b[0m\u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'required'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'deliveries'\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'object'\u001b[0m,\n", " \u001b[32m'title'\u001b[0m: \u001b[32m'Schedule'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'required'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'deliveries'\u001b[0m\u001b[1m]\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m\n", "\u001b[1m]\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from rich import print\n", "from guardrails import Guard\n", "from guardrails.hub import RegexMatch\n", "from pydantic import BaseModel, Field\n", "from typing import List\n", "\n", "NAME_REGEX = \"^[A-Z][a-z]+\\\\s[A-Z][a-z]+$\"\n", "\n", "\n", "class Delivery(BaseModel):\n", " custome_name: str = Field(\n", " validators=[RegexMatch(regex=NAME_REGEX, on_fail=\"noop\")],\n", " description=\"customer name\",\n", " )\n", " pickup_time: str = Field(description=\"date and time of pickup\")\n", " pickup_location: str = Field(description=\"address of pickup\")\n", " dropoff_time: str = Field(description=\"date and time of dropoff\")\n", " dropoff_location: str = Field(description=\"address of dropoff\")\n", " price: str = Field(description=\"price of delivery with currency symbol included\")\n", "\n", "\n", "class Schedule(BaseModel):\n", " deliveries: List[Delivery]\n", "\n", "\n", "pydantic_guard = Guard.for_pydantic(Schedule)\n", "\n", "# Generate the function calling tool and add it to the list\n", "pydantic_guard_tools = pydantic_guard.json_function_calling_tool([])\n", "\n", "print(pydantic_guard_tools)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[\n", " {\n", " 'type': 'function',\n", " 'function': {\n", " 'name': 'gd_response_tool',\n", " 'description': 'A tool for generating responses to guardrails. It must be called last in every \n", "response.',\n", " 'parameters': {\n", " 'properties': {\n", " 'deliveries': {\n", " 'items': {\n", " 'properties': {\n", " 'customer_name': {'type': 'string', 'description': 'customer name'},\n", " 'pickup_time': {'type': 'string', 'description': 'date and time of pickup'},\n", " 'pickup_location': {'type': 'string', 'description': 'address of pickup'},\n", " 'dropoff_time': {'type': 'string', 'description': 'date and time of dropoff'},\n", " 'dropoff_location': {'type': 'string', 'description': 'address of dropoff'},\n", " 'price': {\n", " 'type': 'string',\n", " 'description': 'price of delivery with currency symbol included'\n", " }\n", " },\n", " 'required': [\n", " 'customer_name',\n", " 'pickup_time',\n", " 'pickup_location',\n", " 'dropoff_time',\n", " 'dropoff_location',\n", " 'price'\n", " ],\n", " 'type': 'object'\n", " },\n", " 'type': 'array'\n", " }\n", " },\n", " 'required': ['deliveries'],\n", " 'type': 'object'\n", " },\n", " 'required': ['deliveries']\n", " }\n", " }\n", "]\n", "\n" ], "text/plain": [ "\u001b[1m[\u001b[0m\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'function'\u001b[0m,\n", " \u001b[32m'function'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'name'\u001b[0m: \u001b[32m'gd_response_tool'\u001b[0m,\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'A tool for generating responses to guardrails. It must be called last in every \u001b[0m\n", "\u001b[32mresponse.'\u001b[0m,\n", " \u001b[32m'parameters'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'properties'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'deliveries'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'items'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'properties'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'customer_name'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m, \u001b[32m'description'\u001b[0m: \u001b[32m'customer name'\u001b[0m\u001b[1m}\u001b[0m,\n", " \u001b[32m'pickup_time'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m, \u001b[32m'description'\u001b[0m: \u001b[32m'date and time of pickup'\u001b[0m\u001b[1m}\u001b[0m,\n", " \u001b[32m'pickup_location'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m, \u001b[32m'description'\u001b[0m: \u001b[32m'address of pickup'\u001b[0m\u001b[1m}\u001b[0m,\n", " \u001b[32m'dropoff_time'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m, \u001b[32m'description'\u001b[0m: \u001b[32m'date and time of dropoff'\u001b[0m\u001b[1m}\u001b[0m,\n", " \u001b[32m'dropoff_location'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m, \u001b[32m'description'\u001b[0m: \u001b[32m'address of dropoff'\u001b[0m\u001b[1m}\u001b[0m,\n", " \u001b[32m'price'\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'string'\u001b[0m,\n", " \u001b[32m'description'\u001b[0m: \u001b[32m'price of delivery with currency symbol included'\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'required'\u001b[0m: \u001b[1m[\u001b[0m\n", " \u001b[32m'customer_name'\u001b[0m,\n", " \u001b[32m'pickup_time'\u001b[0m,\n", " \u001b[32m'pickup_location'\u001b[0m,\n", " \u001b[32m'dropoff_time'\u001b[0m,\n", " \u001b[32m'dropoff_location'\u001b[0m,\n", " \u001b[32m'price'\u001b[0m\n", " \u001b[1m]\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'object'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'array'\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'required'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'deliveries'\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[32m'type'\u001b[0m: \u001b[32m'object'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[32m'required'\u001b[0m: \u001b[1m[\u001b[0m\u001b[32m'deliveries'\u001b[0m\u001b[1m]\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m\n", "\u001b[1m]\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "rail = \"\"\"\n", "
ValidationOutcome(\n", " call_id='13988399296',\n", " raw_llm_output='{\"deliveries\":[{\"custome_name\":\"nelson and murdock\",\"pickup_time\":\"June 3 \n", "10:00am\",\"pickup_location\":\"797 9th Avenue\",\"dropoff_time\":\"June 3 10:30am\",\"dropoff_location\":\"Courthouse, 61 \n", "Center Street C/O frank james\",\"price\":\"$23.00\"},{\"custome_name\":\"abc flowers\",\"pickup_time\":\"June 2 \n", "11:00am\",\"pickup_location\":\"21 3rd street\",\"dropoff_time\":\"June 2 5:30pm\",\"dropoff_location\":\"75th \n", "Ave\",\"price\":\"$14.50\"},{\"custome_name\":\"polk and wardell\",\"pickup_time\":\"June 3 11:00am\",\"pickup_location\":\"331 5th\n", "street\",\"dropoff_time\":\"June 3 5:30pm\",\"dropoff_location\":\"75th Ave\",\"price\":\"$34.50\"}]}',\n", " validation_summaries=[\n", " ValidationSummary(\n", " validator_name='RegexMatch',\n", " validator_status='fail',\n", " property_path='$.deliveries.0.custome_name',\n", " failure_reason='Result must match ^[A-Z][a-z]+\\\\s[A-Z][a-z]+$',\n", " error_spans=None\n", " ),\n", " ValidationSummary(\n", " validator_name='RegexMatch',\n", " validator_status='fail',\n", " property_path='$.deliveries.1.custome_name',\n", " failure_reason='Result must match ^[A-Z][a-z]+\\\\s[A-Z][a-z]+$',\n", " error_spans=None\n", " ),\n", " ValidationSummary(\n", " validator_name='RegexMatch',\n", " validator_status='fail',\n", " property_path='$.deliveries.2.custome_name',\n", " failure_reason='Result must match ^[A-Z][a-z]+\\\\s[A-Z][a-z]+$',\n", " error_spans=None\n", " )\n", " ],\n", " validated_output={\n", " 'deliveries': [\n", " {\n", " 'custome_name': 'nelson and murdock',\n", " 'pickup_time': 'June 3 10:00am',\n", " 'pickup_location': '797 9th Avenue',\n", " 'dropoff_time': 'June 3 10:30am',\n", " 'dropoff_location': 'Courthouse, 61 Center Street C/O frank james',\n", " 'price': '$23.00'\n", " },\n", " {\n", " 'custome_name': 'abc flowers',\n", " 'pickup_time': 'June 2 11:00am',\n", " 'pickup_location': '21 3rd street',\n", " 'dropoff_time': 'June 2 5:30pm',\n", " 'dropoff_location': '75th Ave',\n", " 'price': '$14.50'\n", " },\n", " {\n", " 'custome_name': 'polk and wardell',\n", " 'pickup_time': 'June 3 11:00am',\n", " 'pickup_location': '331 5th street',\n", " 'dropoff_time': 'June 3 5:30pm',\n", " 'dropoff_location': '75th Ave',\n", " 'price': '$34.50'\n", " }\n", " ]\n", " },\n", " reask=None,\n", " validation_passed=False,\n", " error=None\n", ")\n", "\n" ], "text/plain": [ "\u001b[1;35mValidationOutcome\u001b[0m\u001b[1m(\u001b[0m\n", " \u001b[33mcall_id\u001b[0m=\u001b[32m'13988399296'\u001b[0m,\n", " \u001b[33mraw_llm_output\u001b[0m=\u001b[32m'\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"deliveries\":\u001b[0m\u001b[32m[\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"custome_name\":\"nelson and murdock\",\"pickup_time\":\"June 3 \u001b[0m\n", "\u001b[32m10:00am\",\"pickup_location\":\"797 9th Avenue\",\"dropoff_time\":\"June 3 10:30am\",\"dropoff_location\":\"Courthouse, 61 \u001b[0m\n", "\u001b[32mCenter Street C/O frank james\",\"price\":\"$23.00\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m,\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"custome_name\":\"abc flowers\",\"pickup_time\":\"June 2 \u001b[0m\n", "\u001b[32m11:00am\",\"pickup_location\":\"21 3rd street\",\"dropoff_time\":\"June 2 5:30pm\",\"dropoff_location\":\"75th \u001b[0m\n", "\u001b[32mAve\",\"price\":\"$14.50\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m,\u001b[0m\u001b[32m{\u001b[0m\u001b[32m\"custome_name\":\"polk and wardell\",\"pickup_time\":\"June 3 11:00am\",\"pickup_location\":\"331 5th\u001b[0m\n", "\u001b[32mstreet\",\"dropoff_time\":\"June 3 5:30pm\",\"dropoff_location\":\"75th Ave\",\"price\":\"$34.50\"\u001b[0m\u001b[32m}\u001b[0m\u001b[32m]\u001b[0m\u001b[32m}\u001b[0m\u001b[32m'\u001b[0m,\n", " \u001b[33mvalidation_summaries\u001b[0m=\u001b[1m[\u001b[0m\n", " \u001b[1;35mValidationSummary\u001b[0m\u001b[1m(\u001b[0m\n", " \u001b[33mvalidator_name\u001b[0m=\u001b[32m'RegexMatch'\u001b[0m,\n", " \u001b[33mvalidator_status\u001b[0m=\u001b[32m'fail'\u001b[0m,\n", " \u001b[33mproperty_path\u001b[0m=\u001b[32m'$.deliveries.0.custome_name'\u001b[0m,\n", " \u001b[33mfailure_reason\u001b[0m=\u001b[32m'Result must match ^\u001b[0m\u001b[32m[\u001b[0m\u001b[32mA-Z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32ma-z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m+\\\\s\u001b[0m\u001b[32m[\u001b[0m\u001b[32mA-Z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32ma-z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m+$'\u001b[0m,\n", " \u001b[33merror_spans\u001b[0m=\u001b[3;35mNone\u001b[0m\n", " \u001b[1m)\u001b[0m,\n", " \u001b[1;35mValidationSummary\u001b[0m\u001b[1m(\u001b[0m\n", " \u001b[33mvalidator_name\u001b[0m=\u001b[32m'RegexMatch'\u001b[0m,\n", " \u001b[33mvalidator_status\u001b[0m=\u001b[32m'fail'\u001b[0m,\n", " \u001b[33mproperty_path\u001b[0m=\u001b[32m'$.deliveries.1.custome_name'\u001b[0m,\n", " \u001b[33mfailure_reason\u001b[0m=\u001b[32m'Result must match ^\u001b[0m\u001b[32m[\u001b[0m\u001b[32mA-Z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32ma-z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m+\\\\s\u001b[0m\u001b[32m[\u001b[0m\u001b[32mA-Z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32ma-z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m+$'\u001b[0m,\n", " \u001b[33merror_spans\u001b[0m=\u001b[3;35mNone\u001b[0m\n", " \u001b[1m)\u001b[0m,\n", " \u001b[1;35mValidationSummary\u001b[0m\u001b[1m(\u001b[0m\n", " \u001b[33mvalidator_name\u001b[0m=\u001b[32m'RegexMatch'\u001b[0m,\n", " \u001b[33mvalidator_status\u001b[0m=\u001b[32m'fail'\u001b[0m,\n", " \u001b[33mproperty_path\u001b[0m=\u001b[32m'$.deliveries.2.custome_name'\u001b[0m,\n", " \u001b[33mfailure_reason\u001b[0m=\u001b[32m'Result must match ^\u001b[0m\u001b[32m[\u001b[0m\u001b[32mA-Z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32ma-z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m+\\\\s\u001b[0m\u001b[32m[\u001b[0m\u001b[32mA-Z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m[\u001b[0m\u001b[32ma-z\u001b[0m\u001b[32m]\u001b[0m\u001b[32m+$'\u001b[0m,\n", " \u001b[33merror_spans\u001b[0m=\u001b[3;35mNone\u001b[0m\n", " \u001b[1m)\u001b[0m\n", " \u001b[1m]\u001b[0m,\n", " \u001b[33mvalidated_output\u001b[0m=\u001b[1m{\u001b[0m\n", " \u001b[32m'deliveries'\u001b[0m: \u001b[1m[\u001b[0m\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'custome_name'\u001b[0m: \u001b[32m'nelson and murdock'\u001b[0m,\n", " \u001b[32m'pickup_time'\u001b[0m: \u001b[32m'June 3 10:00am'\u001b[0m,\n", " \u001b[32m'pickup_location'\u001b[0m: \u001b[32m'797 9th Avenue'\u001b[0m,\n", " \u001b[32m'dropoff_time'\u001b[0m: \u001b[32m'June 3 10:30am'\u001b[0m,\n", " \u001b[32m'dropoff_location'\u001b[0m: \u001b[32m'Courthouse, 61 Center Street C/O frank james'\u001b[0m,\n", " \u001b[32m'price'\u001b[0m: \u001b[32m'$23.00'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'custome_name'\u001b[0m: \u001b[32m'abc flowers'\u001b[0m,\n", " \u001b[32m'pickup_time'\u001b[0m: \u001b[32m'June 2 11:00am'\u001b[0m,\n", " \u001b[32m'pickup_location'\u001b[0m: \u001b[32m'21 3rd street'\u001b[0m,\n", " \u001b[32m'dropoff_time'\u001b[0m: \u001b[32m'June 2 5:30pm'\u001b[0m,\n", " \u001b[32m'dropoff_location'\u001b[0m: \u001b[32m'75th Ave'\u001b[0m,\n", " \u001b[32m'price'\u001b[0m: \u001b[32m'$14.50'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'custome_name'\u001b[0m: \u001b[32m'polk and wardell'\u001b[0m,\n", " \u001b[32m'pickup_time'\u001b[0m: \u001b[32m'June 3 11:00am'\u001b[0m,\n", " \u001b[32m'pickup_location'\u001b[0m: \u001b[32m'331 5th street'\u001b[0m,\n", " \u001b[32m'dropoff_time'\u001b[0m: \u001b[32m'June 3 5:30pm'\u001b[0m,\n", " \u001b[32m'dropoff_location'\u001b[0m: \u001b[32m'75th Ave'\u001b[0m,\n", " \u001b[32m'price'\u001b[0m: \u001b[32m'$34.50'\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m]\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[33mreask\u001b[0m=\u001b[3;35mNone\u001b[0m,\n", " \u001b[33mvalidation_passed\u001b[0m=\u001b[3;91mFalse\u001b[0m,\n", " \u001b[33merror\u001b[0m=\u001b[3;35mNone\u001b[0m\n", "\u001b[1m)\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Add your OPENAI_API_KEY as an environment variable if it's not already set\n", "# import os\n", "# os.environ[\"OPENAI_API_KEY\"] = \"YOUR_API_KEY\"\n", "\n", "response = pydantic_guard(\n", " model=\"gpt-4o\",\n", " messages=[{\"role\": \"user\", \"content\": prompt}],\n", " prompt_params={\"chat_history\": chat_history},\n", " tools=pydantic_guard_tools,\n", " tool_choice=\"required\",\n", ")\n", "\n", "print(response)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Logs\n",
"└── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n",
" │ ╭─────────────────────────────────────────────── Messages ────────────────────────────────────────────────╮ │\n",
" │ │ ┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │ │\n",
" │ │ ┃ Role ┃ Content ┃ │ │\n",
" │ │ ┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ │\n",
" │ │ │ user │ │ │ │\n",
" │ │ │ │ From the chat exchanges below extract a schedule of deliveries. │ │ │\n",
" │ │ │ │ Chats: │ │ │\n",
" │ │ │ │ │ │ │\n",
" │ │ │ │ nelson and murdock: i need a pickup 797 9th Avenue, manila envelope, June 3 10:00am with │ │ │\n",
" │ │ │ │ dropoff 10:30am Courthouse, 61 Center Street C/O frank james │ │ │\n",
" │ │ │ │ operator: quote - $23.00 │ │ │\n",
" │ │ │ │ neslon and murdock: perfect, we accept the quote │ │ │\n",
" │ │ │ │ operator: 797 9th ave, 10:00am pickup comfirmed │ │ │\n",
" │ │ │ │ abc flowers: i need a pickup of a flowers from abc flowers at 21 3rd street at 11:00am on │ │ │\n",
" │ │ │ │ june 2 with a dropoff at 75th Ave at 5:30pm same day │ │ │\n",
" │ │ │ │ operator: 21 3rd street flowers quote - $14.50 │ │ │\n",
" │ │ │ │ abc flowers: accepted │ │ │\n",
" │ │ │ │ polk and wardell: i need a pickup of a bagels from Bakers Co at 331 5th street at 11:00am on │ │ │\n",
" │ │ │ │ june 3 with a dropoff at 75th Ave at 5:30pm same day │ │ │\n",
" │ │ │ │ operator: 331 5th street bagels quote - $34.50 │ │ │\n",
" │ │ │ │ polk and wardell: accepted │ │ │\n",
" │ │ │ │ │ │ │\n",
" │ │ │ │ │ │ │\n",
" │ │ └──────┴──────────────────────────────────────────────────────────────────────────────────────────────┘ │ │\n",
" │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n",
" │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n",
" │ │ {\"deliveries\":[{\"custome_name\":\"nelson and murdock\",\"pickup_time\":\"June 3 │ │\n",
" │ │ 10:00am\",\"pickup_location\":\"797 9th Avenue\",\"dropoff_time\":\"June 3 │ │\n",
" │ │ 10:30am\",\"dropoff_location\":\"Courthouse, 61 Center Street C/O frank │ │\n",
" │ │ james\",\"price\":\"$23.00\"},{\"custome_name\":\"abc flowers\",\"pickup_time\":\"June 2 │ │\n",
" │ │ 11:00am\",\"pickup_location\":\"21 3rd street\",\"dropoff_time\":\"June 2 5:30pm\",\"dropoff_location\":\"75th │ │\n",
" │ │ Ave\",\"price\":\"$14.50\"},{\"custome_name\":\"polk and wardell\",\"pickup_time\":\"June 3 │ │\n",
" │ │ 11:00am\",\"pickup_location\":\"331 5th street\",\"dropoff_time\":\"June 3 5:30pm\",\"dropoff_location\":\"75th │ │\n",
" │ │ Ave\",\"price\":\"$34.50\"}]} │ │\n",
" │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n",
" │ ╭─────────────────────────────────────────── Validated Output ────────────────────────────────────────────╮ │\n",
" │ │ { │ │\n",
" │ │ 'deliveries': [ │ │\n",
" │ │ { │ │\n",
" │ │ 'custome_name': 'nelson and murdock', │ │\n",
" │ │ 'pickup_time': 'June 3 10:00am', │ │\n",
" │ │ 'pickup_location': '797 9th Avenue', │ │\n",
" │ │ 'dropoff_time': 'June 3 10:30am', │ │\n",
" │ │ 'dropoff_location': 'Courthouse, 61 Center Street C/O frank james', │ │\n",
" │ │ 'price': '$23.00' │ │\n",
" │ │ }, │ │\n",
" │ │ { │ │\n",
" │ │ 'custome_name': 'abc flowers', │ │\n",
" │ │ 'pickup_time': 'June 2 11:00am', │ │\n",
" │ │ 'pickup_location': '21 3rd street', │ │\n",
" │ │ 'dropoff_time': 'June 2 5:30pm', │ │\n",
" │ │ 'dropoff_location': '75th Ave', │ │\n",
" │ │ 'price': '$14.50' │ │\n",
" │ │ }, │ │\n",
" │ │ { │ │\n",
" │ │ 'custome_name': 'polk and wardell', │ │\n",
" │ │ 'pickup_time': 'June 3 11:00am', │ │\n",
" │ │ 'pickup_location': '331 5th street', │ │\n",
" │ │ 'dropoff_time': 'June 3 5:30pm', │ │\n",
" │ │ 'dropoff_location': '75th Ave', │ │\n",
" │ │ 'price': '$34.50' │ │\n",
" │ │ } │ │\n",
" │ │ ] │ │\n",
" │ │ } │ │\n",
" │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n",
" ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
"\n"
],
"text/plain": [
"Logs\n",
"└── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n",
" │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m──────────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Messages \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent \u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235muser\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mFrom the chat exchanges below extract a schedule of deliveries. \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mChats: \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mnelson and murdock: i need a pickup 797 9th Avenue, manila envelope, June 3 10:00am with \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mdropoff 10:30am Courthouse, 61 Center Street C/O frank james \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235moperator: quote - $23.00 \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mneslon and murdock: perfect, we accept the quote \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235moperator: 797 9th ave, 10:00am pickup comfirmed \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mabc flowers: i need a pickup of a flowers from abc flowers at 21 3rd street at 11:00am on \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mjune 2 with a dropoff at 75th Ave at 5:30pm same day \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235moperator: 21 3rd street flowers quote - $14.50 \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mabc flowers: accepted \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mpolk and wardell: i need a pickup of a bagels from Bakers Co at 331 5th street at 11:00am on\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mjune 3 with a dropoff at 75th Ave at 5:30pm same day \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235moperator: 331 5th street bagels quote - $34.50 \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mpolk and wardell: accepted \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴──────────────────────────────────────────────────────────────────────────────────────────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
" │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\"deliveries\":[{\"custome_name\":\"nelson and murdock\",\"pickup_time\":\"June 3 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m10:00am\",\"pickup_location\":\"797 9th Avenue\",\"dropoff_time\":\"June 3 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m10:30am\",\"dropoff_location\":\"Courthouse, 61 Center Street C/O frank \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mjames\",\"price\":\"$23.00\"},{\"custome_name\":\"abc flowers\",\"pickup_time\":\"June 2 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m11:00am\",\"pickup_location\":\"21 3rd street\",\"dropoff_time\":\"June 2 5:30pm\",\"dropoff_location\":\"75th \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mAve\",\"price\":\"$14.50\"},{\"custome_name\":\"polk and wardell\",\"pickup_time\":\"June 3 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m11:00am\",\"pickup_location\":\"331 5th street\",\"dropoff_time\":\"June 3 5:30pm\",\"dropoff_location\":\"75th \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mAve\",\"price\":\"$34.50\"}]}\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
" │ \u001b[48;2;245;245;220m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m╭─\u001b[0m\u001b[48;2;240;255;240m──────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m Validated Output \u001b[0m\u001b[48;2;240;255;240m───────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m─╮\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m{\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'deliveries': [\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'custome_name': 'nelson and murdock',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'pickup_time': 'June 3 10:00am',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'pickup_location': '797 9th Avenue',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'dropoff_time': 'June 3 10:30am',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'dropoff_location': 'Courthouse, 61 Center Street C/O frank james',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'price': '$23.00'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'custome_name': 'abc flowers',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'pickup_time': 'June 2 11:00am',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'pickup_location': '21 3rd street',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'dropoff_time': 'June 2 5:30pm',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'dropoff_location': '75th Ave',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'price': '$14.50'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'custome_name': 'polk and wardell',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'pickup_time': 'June 3 11:00am',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'pickup_location': '331 5th street',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'dropoff_time': 'June 3 5:30pm',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'dropoff_location': '75th Ave',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'price': '$34.50'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m }\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m ]\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m}\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
" │ \u001b[48;2;240;255;240m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
" ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pydantic_guard.history.last.tree"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "litellm",
"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.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}