mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-11 03:39:49 +08:00
fix(antigravity): use Gemini schema field for tools
This commit is contained in:
@@ -78,6 +78,7 @@ pub fn build_antigravity_safe_v1internal_request(
|
|||||||
inner_request.remove("model");
|
inner_request.remove("model");
|
||||||
inner_request.remove("safetySettings");
|
inner_request.remove("safetySettings");
|
||||||
inner_request.remove("safety_settings");
|
inner_request.remove("safety_settings");
|
||||||
|
normalize_antigravity_function_declaration_schemas(&mut inner_request);
|
||||||
let request_id = non_empty_string_field(source, "requestId").unwrap_or(request_id);
|
let request_id = non_empty_string_field(source, "requestId").unwrap_or(request_id);
|
||||||
let user_agent =
|
let user_agent =
|
||||||
non_empty_string_field(source, "userAgent").unwrap_or(ANTIGRAVITY_REQUEST_USER_AGENT);
|
non_empty_string_field(source, "userAgent").unwrap_or(ANTIGRAVITY_REQUEST_USER_AGENT);
|
||||||
@@ -98,6 +99,7 @@ pub fn build_antigravity_safe_v1internal_request(
|
|||||||
inner_request.remove("model");
|
inner_request.remove("model");
|
||||||
inner_request.remove("safetySettings");
|
inner_request.remove("safetySettings");
|
||||||
inner_request.remove("safety_settings");
|
inner_request.remove("safety_settings");
|
||||||
|
normalize_antigravity_function_declaration_schemas(&mut inner_request);
|
||||||
|
|
||||||
AntigravityRequestEnvelopeSupport::Supported(serde_json::json!({
|
AntigravityRequestEnvelopeSupport::Supported(serde_json::json!({
|
||||||
"project": auth.project_id,
|
"project": auth.project_id,
|
||||||
@@ -109,6 +111,33 @@ pub fn build_antigravity_safe_v1internal_request(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn normalize_antigravity_function_declaration_schemas(request: &mut Map<String, Value>) {
|
||||||
|
let Some(tools) = request.get_mut("tools").and_then(Value::as_array_mut) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
for tool in tools {
|
||||||
|
let Some(tool_object) = tool.as_object_mut() else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
for key in ["functionDeclarations", "function_declarations"] {
|
||||||
|
let Some(declarations) = tool_object.get_mut(key).and_then(Value::as_array_mut) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
for declaration in declarations {
|
||||||
|
let Some(declaration_object) = declaration.as_object_mut() else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if let Some(parameters) = declaration_object.remove("parameters") {
|
||||||
|
declaration_object
|
||||||
|
.entry("parametersJsonSchema".to_string())
|
||||||
|
.or_insert(parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn existing_v1internal_request_object(source: &Map<String, Value>) -> Option<&Map<String, Value>> {
|
fn existing_v1internal_request_object(source: &Map<String, Value>) -> Option<&Map<String, Value>> {
|
||||||
source
|
source
|
||||||
.get("request")
|
.get("request")
|
||||||
@@ -183,6 +212,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tools": [
|
"tools": [
|
||||||
|
{
|
||||||
|
"googleSearch": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"functionDeclarations": [
|
"functionDeclarations": [
|
||||||
{
|
{
|
||||||
@@ -254,9 +286,17 @@ mod tests {
|
|||||||
.get("include_server_side_tool_invocations")
|
.get("include_server_side_tool_invocations")
|
||||||
.is_none());
|
.is_none());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
envelope["request"]["tools"][0]["functionDeclarations"][0]["name"],
|
envelope["request"]["tools"][1]["functionDeclarations"][0]["name"],
|
||||||
"run_command"
|
"run_command"
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
envelope["request"]["tools"][1]["functionDeclarations"][0]["parametersJsonSchema"]
|
||||||
|
["properties"]["cmd"]["type"],
|
||||||
|
"string"
|
||||||
|
);
|
||||||
|
assert!(envelope["request"]["tools"][1]["functionDeclarations"][0]
|
||||||
|
.get("parameters")
|
||||||
|
.is_none());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
envelope["request"]["labels"]["trajectory_id"],
|
envelope["request"]["labels"]["trajectory_id"],
|
||||||
"trajectory-123"
|
"trajectory-123"
|
||||||
|
|||||||
Reference in New Issue
Block a user