Skip to content

Commit 821c969

Browse files
committed
refactor: remove unused remove_additional_properties function and simplify JSON schema handling in LlmGenerationClient
1 parent 0d0109e commit 821c969

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

rust/cocoindex/src/llm/gemini.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,6 @@ impl AiStudioClient {
4949
}
5050
}
5151

52-
// Recursively remove all `additionalProperties` fields from a JSON value
53-
fn remove_additional_properties(value: &mut Value) {
54-
match value {
55-
Value::Object(map) => {
56-
map.remove("additionalProperties");
57-
for v in map.values_mut() {
58-
remove_additional_properties(v);
59-
}
60-
}
61-
Value::Array(arr) => {
62-
for v in arr {
63-
remove_additional_properties(v);
64-
}
65-
}
66-
_ => {}
67-
}
68-
}
69-
7052
impl AiStudioClient {
7153
fn get_api_url(&self, model: &str, api_name: &str) -> String {
7254
format!(
@@ -149,8 +131,7 @@ impl LlmGenerationClient for AiStudioClient {
149131

150132
// If structured output is requested, add schema and responseMimeType
151133
if let Some(OutputFormat::JsonSchema { schema, .. }) = &request.output_format {
152-
let mut schema_json = serde_json::to_value(schema)?;
153-
remove_additional_properties(&mut schema_json);
134+
let schema_json = serde_json::to_value(schema)?;
154135
payload["generationConfig"] = serde_json::json!({
155136
"responseMimeType": "application/json",
156137
"responseSchema": schema_json
@@ -181,6 +162,7 @@ impl LlmGenerationClient for AiStudioClient {
181162
supports_format: false,
182163
extract_descriptions: false,
183164
top_level_must_be_object: true,
165+
supports_additional_properties: false,
184166
}
185167
}
186168
}
@@ -379,6 +361,7 @@ impl LlmGenerationClient for VertexAiClient {
379361
supports_format: false,
380362
extract_descriptions: false,
381363
top_level_must_be_object: true,
364+
supports_additional_properties: false,
382365
}
383366
}
384367
}

0 commit comments

Comments
 (0)