Remove unnecessary fields from the tool schemas (#29381)
This PR removes two fields from JSON schemas (`$schema` and `title`), which are not expected by any model provider, but were spuriously included by our JSON schema library, `schemars`. These added noise to requests and cost wasted input tokens. ### Old ```json { "$schema": "http://json-schema.org/draft-07/schema#", "title": "FetchToolInput", "type": "object", "required": [ "url" ], "properties": { "url": { "description": "The URL to fetch.", "type": "string" } } } ``` ### New: ```json { "properties": { "url": { "description": "The URL to fetch.", "type": "string" } }, "required": [ "url" ], "type": "object" } ``` - N/A
This commit is contained in:
parent
17ecf94f6f
commit
57d8397f53
3 changed files with 49 additions and 25 deletions
|
@ -931,26 +931,21 @@ impl Thread {
|
|||
|
||||
let mut request = self.to_completion_request(cx);
|
||||
if model.supports_tools() {
|
||||
request.tools = {
|
||||
let mut tools = Vec::new();
|
||||
tools.extend(
|
||||
self.tools()
|
||||
.read(cx)
|
||||
.enabled_tools(cx)
|
||||
.into_iter()
|
||||
.filter_map(|tool| {
|
||||
// Skip tools that cannot be supported
|
||||
let input_schema = tool.input_schema(model.tool_input_format()).ok()?;
|
||||
Some(LanguageModelRequestTool {
|
||||
name: tool.name(),
|
||||
description: tool.description(),
|
||||
input_schema,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
tools
|
||||
};
|
||||
request.tools = self
|
||||
.tools()
|
||||
.read(cx)
|
||||
.enabled_tools(cx)
|
||||
.into_iter()
|
||||
.filter_map(|tool| {
|
||||
// Skip tools that cannot be supported
|
||||
let input_schema = tool.input_schema(model.tool_input_format()).ok()?;
|
||||
Some(LanguageModelRequestTool {
|
||||
name: tool.name(),
|
||||
description: tool.description(),
|
||||
input_schema,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
||||
self.stream_completion(request, model, window, cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue