-
Notifications
You must be signed in to change notification settings - Fork 278
Add JSON Schema Definition for gen_ai.tool.definitions #2942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add JSON Schema Definition for gen_ai.tool.definitions #2942
Conversation
Change-Id: I63f11ca8081f71b55b793ec88f35ef64bbace8e6 Co-developed-by: Cursor <[email protected]>
Change-Id: Ib6133b3019195e4fa9a54d329ff4b891a281d208 Co-developed-by: Cursor <[email protected]>
76f99f0 to
2a15973
Compare
|
This is the continued PR of #2793 |
Change-Id: Ie116f8bcb9e758b026596b797569b27496b35521 Co-developed-by: Cursor <[email protected]>
| "source": [ | ||
| "class ToolType(str, Enum):\n", | ||
| " FUNCTION = \"function\"\n", | ||
| " CUSTOM = \"custom\"\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bringing @alexmojaki 's comment here https://github.com/open-telemetry/semantic-conventions/pull/2793/files#r2369871417
Custom tools are only supported by OpenAI Chat API and are not even available in the Responses API - https://platform.openai.com/docs/api-reference/responses/create#responses-create-tools
- I'd suggest to remove this enum member
- The ToolDefinition below only works for functions and should only be used when ToolType is
function. - We need to leave a room to support non-function tool definitions (e.g. file search) and their parameters. I.e. we'd need something like
ToolDefinition = Union[ FunctionDefinition, GenericToolDefinition, # Catch-all for any other type # Add other tool definition types here as needed, # e.g. file search, code interpreter, etc ]
| " type: Union[ToolType, str] = Field(description=\"Type of the tool.\")\n", | ||
| " name: str = Field(description=\"Name of the tool.\")\n", | ||
| " description: str = Field(None, description=\"Description of the tool.\")\n", | ||
| " parameters: Any = Field(\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above - parameters and response are specific to functions and don't necessarily work for non-function tools (e.g. file search)
| format is not supported and SHOULD be recorded in structured form otherwise. | ||
|
|
||
| If instrumentations can reliably deserialize and extract the tool definitions, | ||
| it's RECOMMENDED to only populate required fields (`name`, `type`) of the definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether we need to capture 'name' & 'type' by default, considering they are important informations and have no sensitive/huge content? cc @ShipraJain01 @lmolkova
Here is a prototype from spring-ai instrumentation:
options.getToolCallbacks().stream()
.map(
toolCallback -> {
String name = toolCallback.getToolDefinition().name();
String type = "function";
if (messageCaptureOptions.captureMessageContent()) {
return ToolDefinition.create(
type, name, toolCallback.getToolDefinition().description(), toolCallback.getToolDefinition().getArguments());
} else {
return ToolDefinition.create(type, name, null, null);
}
})
.filter(Objects::nonNull)
.forEach(toolDefinitions::append);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmolkova I feel like this should just be a python script with comments and docstrings, reviewing this notebook format in github is annoying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for a python script here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a markdown file also works here, embedding the code in the markdown file and and also with the output .
python codethis is the output of above code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for a python script here.
Fixes #2721 #1835
Changes
Add JSON schema definition for gen_ai.tool.definitions.
Important
Pull requests acceptance are subject to the triage process as described in Issue and PR Triage Management.
PRs that do not follow the guidance above, may be automatically rejected and closed.
Merge requirement checklist
[chore]