Skip to content

Commit 2c76210

Browse files
committed
polish the schema of tool definitions
1 parent 391f881 commit 2c76210

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

docs/gen-ai/non-normative/models.ipynb

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,7 @@
117117
" description=\"List of message parts that make up the message content.\")\n",
118118
"\n",
119119
" class Config:\n",
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"
120+
" extra = \"allow\""
138121
]
139122
},
140123
{
@@ -156,6 +139,42 @@
156139
"metadata": {},
157140
"outputs": [],
158141
"source": [
142+
"class ToolType(str, Enum):\n",
143+
" FUNCTION = \"function\"\n",
144+
" CUSTOM = \"custom\"\n",
145+
"\n",
146+
"class JSONSchema(BaseModel):\n",
147+
" \"\"\"\n",
148+
" Represents a JSON schema to define the format of the tool parameters or response.\n",
149+
" \"\"\"\n",
150+
" type: str = Field(description=\"Type of the overall data.\")\n",
151+
"\n",
152+
" class Config:\n",
153+
" extra = \"allow\"\n",
154+
"\n",
155+
"class ToolDefinition(BaseModel):\n",
156+
" \"\"\"\n",
157+
" Represents a tool definition.\n",
158+
" \"\"\"\n",
159+
" type: Union[ToolType, str] = Field(description=\"Type of the tool.\")\n",
160+
" name: str = Field(description=\"Name of the tool.\")\n",
161+
" description: str = Field(description=\"Description of the tool.\")\n",
162+
" parameters: Optional[Union[JSONSchema, Any]] = Field(\n",
163+
" description=(\n",
164+
" \"Format of the tool parameters the function expects. \"\n",
165+
" \"The RECOMMENDED data type is JSON Schema. \"\n",
166+
" )\n",
167+
" )\n",
168+
" response: Optional[Union[JSONSchema, Any]] = Field(\n",
169+
" description=(\n",
170+
" \"Format of the tool response the function returns. \"\n",
171+
" \"The RECOMMENDED data type is JSON Schema. \"\n",
172+
" )\n",
173+
" )\n",
174+
"\n",
175+
" class Config:\n",
176+
" extra = \"allow\"\n",
177+
"\n",
159178
"class InputMessages(RootModel[List[ChatMessage]]):\n",
160179
" \"\"\"\n",
161180
" Represents the list of input messages sent to the model.\n",

model/gen-ai/registry.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,6 @@ groups:
316316
it's RECOMMENDED to only populate required fields of the definition objects
317317
by default. Otherwise, it's NOT RECOMMENDED to populate it by default.
318318
Instrumentations MAY provide a way to enable populating this attribute.
319-
320-
> [!Warning]
321-
> This attribute is likely to contain sensitive information including user/PII data.
322319
examples:
323320
- |
324321
[

0 commit comments

Comments
 (0)