|
41 | 41 | }, |
42 | 42 | { |
43 | 43 | "cell_type": "code", |
44 | | - "execution_count": 1, |
| 44 | + "execution_count": null, |
45 | 45 | "id": "5124fe15", |
46 | 46 | "metadata": {}, |
47 | 47 | "outputs": [], |
|
117 | 117 | " description=\"List of message parts that make up the message content.\")\n", |
118 | 118 | "\n", |
119 | 119 | " class Config:\n", |
120 | | - " extra = \"allow\"" |
| 120 | + " extra = \"allow\"\n", |
| 121 | + "\n", |
| 122 | + "class ToolType(str, Enum):\n", |
| 123 | + " FUNCTION = \"function\"\n", |
| 124 | + " CUSTOM = \"custom\"\n", |
| 125 | + "\n", |
| 126 | + "class ToolDefinition(BaseModel):\n", |
| 127 | + " \"\"\"\n", |
| 128 | + " Represents a tool definition.\n", |
| 129 | + " \"\"\"\n", |
| 130 | + " type: Union[ToolType, str] = Field(description=\"Type of the tool.\")\n", |
| 131 | + " name: str = Field(description=\"Name of the tool.\")\n", |
| 132 | + " description: str = Field(description=\"Description of the tool.\")\n", |
| 133 | + " parameters: Any = Field(description=\"Format of the tool parameters. Maybe it is a JSON schema.\")\n", |
| 134 | + " response: Any = Field(description=\"Format of the tool response. Maybe it is a JSON schema.\")\n", |
| 135 | + "\n", |
| 136 | + " class Config:\n", |
| 137 | + " extra = \"allow\"\n" |
121 | 138 | ] |
122 | 139 | }, |
123 | 140 | { |
|
222 | 239 | "# Print the JSON schema for the SystemInstructions model\n", |
223 | 240 | "print(json.dumps(SystemInstructions.model_json_schema(), indent=4))" |
224 | 241 | ] |
| 242 | + }, |
| 243 | + { |
| 244 | + "cell_type": "markdown", |
| 245 | + "id": "f019c33a", |
| 246 | + "metadata": {}, |
| 247 | + "source": [ |
| 248 | + "## `gen_ai.tool.definitions` model\n", |
| 249 | + "\n", |
| 250 | + "Corresponding attribute: [`gen_ai.tool.definitions`](/docs/registry/attributes/gen-ai.md#gen-ai-tool-definitions).\n", |
| 251 | + "JSON schema: [`gen_ai-tool-definitions.json`](../gen-ai-tool-definitions.json)" |
| 252 | + ] |
| 253 | + }, |
| 254 | + { |
| 255 | + "cell_type": "code", |
| 256 | + "execution_count": null, |
| 257 | + "id": "a9e84726", |
| 258 | + "metadata": {}, |
| 259 | + "outputs": [], |
| 260 | + "source": [ |
| 261 | + "class ToolDefinitions(RootModel[List[ToolDefinition]]):\n", |
| 262 | + " \"\"\"\n", |
| 263 | + " Represents the list of tool definitions available to the GenAI agent or model.\n", |
| 264 | + " \"\"\"\n", |
| 265 | + " pass\n", |
| 266 | + "\n", |
| 267 | + "# Print the JSON schema for the ToolDefinitions model\n", |
| 268 | + "print(json.dumps(ToolDefinitions.model_json_schema(), indent=4))" |
| 269 | + ] |
225 | 270 | } |
226 | 271 | ], |
227 | 272 | "metadata": { |
|
0 commit comments