From 6a49b6736b7e0c7fc953839fef312328b41385c5 Mon Sep 17 00:00:00 2001 From: Caleb Courier Date: Mon, 27 Oct 2025 11:42:48 -0500 Subject: [PATCH] update cohere model --- .../generate_structured_data_cohere.ipynb | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/docs/examples/generate_structured_data_cohere.ipynb b/docs/examples/generate_structured_data_cohere.ipynb index 9fae8d52f..22007ad92 100644 --- a/docs/examples/generate_structured_data_cohere.ipynb +++ b/docs/examples/generate_structured_data_cohere.ipynb @@ -93,25 +93,27 @@ "from guardrails.hub import ValidLength, TwoWords, ValidRange\n", "from typing import List\n", "\n", + "\n", "class Order(BaseModel):\n", - "\tuser_id: int = Field(description=\"The user's id.\", validators=[(\"1-indexed\", \"noop\")])\n", - "\tuser_name: str = Field(\n", - "\t\tdescription=\"The user's first name and last name\",\n", - "\t\tvalidators=[TwoWords(on_fail=\"noop\")]\n", - "\t)\n", + " user_id: int = Field(\n", + " description=\"The user's id.\", validators=[(\"1-indexed\", \"noop\")]\n", + " )\n", + " user_name: str = Field(\n", + " description=\"The user's first name and last name\",\n", + " validators=[TwoWords(on_fail=\"noop\")],\n", + " )\n", "\n", - "\tnum_orders: int = Field(\n", - "\t\tdescription=\"The number of orders the user has placed\",\n", - "\t\tvalidators=[ValidRange(0, 50, on_fail=\"noop\")]\n", - "\t)\n", - "\t\n", + " num_orders: int = Field(\n", + " description=\"The number of orders the user has placed\",\n", + " validators=[ValidRange(0, 50, on_fail=\"noop\")],\n", + " )\n", "\n", "\n", "class Orders(BaseModel):\n", - "\tuser_orders: List[Order] = Field(\n", - "\t\tdescription=\"Generate a list of users and how many orders they have placed in the past.\",\n", - "\t\tvalidators=[ValidLength(10, 10, on_fail=\"noop\")]\n", - "\t)" + " user_orders: List[Order] = Field(\n", + " description=\"Generate a list of users and how many orders they have placed in the past.\",\n", + " validators=[ValidLength(10, 10, on_fail=\"noop\")],\n", + " )" ] }, { @@ -144,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "42766922-14d0-4b5e-853a-23f05b896a09", "metadata": {}, "outputs": [ @@ -164,13 +166,14 @@ "source": [ "from rich import print\n", "import guardrails as gd\n", + "\n", "guard = gd.Guard.for_pydantic(output_class=Orders)\n", "\n", "raw_llm_response, validated_response, *rest = guard(\n", - " \tmessages=[{\"role\":\"user\", \"content\":prompt}],\n", - "\tmodel=\"command-r\",\n", - "\tmax_tokens=1024,\n", - "\ttemperature=0.3\n", + " messages=[{\"role\": \"user\", \"content\": prompt}],\n", + " model=\"command-r-08-2024\",\n", + " max_tokens=1024,\n", + " temperature=0.3,\n", ")" ] }, @@ -467,8 +470,6 @@ } ], "source": [ - "from rich import print\n", - "\n", "print(guard.history.last.tree)" ] }