feat: allow missing name/args in FunctionCallData and add streamed argument fields (#12) #17

Merged
andreban merged 1 commits from feat/function-call-optional-fields into main 2026-10-26 19:59:47 +00:00
Owner

Fixes #12

Summary

  • Adds #[serde(default)] to FunctionCallData::name and FunctionCallData::args so missing fields deserialize gracefully rather than erroring:
    • Zero-argument function calls ({"name": "f"}) deserialize with args: Value::Null.
    • Streamed partial chunks ({"partialArgs": [], "willContinue": true}) deserialize with name: "" and args: Value::Null.
    • Maintains name: String and args: Value types to ensure non-breaking backwards compatibility for existing callers.
  • Adds partial_args: Option<Vec<Value>> and will_continue: Option<bool> to FunctionCallData to support streamed function call chunks per the Vertex AI GoogleCloudAiplatformV1FunctionCall schema.
  • Adds #[serde(rename_all = "camelCase")], #[serde(skip_serializing_if)] for empty name and null args, and derives Default, PartialEq, Eq on FunctionCallData.
  • Adds Part::with_partial_args and Part::with_will_continue builder helpers.

Testing

  • Added unit test function_call_omits_unset_name_and_args_and_parses_missing_fields in src/types/common.rs:
    • Verifies zero-argument function calls without args deserialize and omit args when serialized.
    • Verifies streamed partial chunks without name or args deserialize partialArgs / willContinue and omit unset fields when serialized.
  • cargo test (33 passed) and cargo clippy pass cleanly.
Fixes #12 ## Summary - Adds `#[serde(default)]` to `FunctionCallData::name` and `FunctionCallData::args` so missing fields deserialize gracefully rather than erroring: - Zero-argument function calls (`{"name": "f"}`) deserialize with `args: Value::Null`. - Streamed partial chunks (`{"partialArgs": [], "willContinue": true}`) deserialize with `name: ""` and `args: Value::Null`. - Maintains `name: String` and `args: Value` types to ensure non-breaking backwards compatibility for existing callers. - Adds `partial_args: Option<Vec<Value>>` and `will_continue: Option<bool>` to `FunctionCallData` to support streamed function call chunks per the Vertex AI `GoogleCloudAiplatformV1FunctionCall` schema. - Adds `#[serde(rename_all = "camelCase")]`, `#[serde(skip_serializing_if)]` for empty name and null args, and derives `Default, PartialEq, Eq` on `FunctionCallData`. - Adds `Part::with_partial_args` and `Part::with_will_continue` builder helpers. ## Testing - Added unit test `function_call_omits_unset_name_and_args_and_parses_missing_fields` in `src/types/common.rs`: - Verifies zero-argument function calls without `args` deserialize and omit `args` when serialized. - Verifies streamed partial chunks without `name` or `args` deserialize `partialArgs` / `willContinue` and omit unset fields when serialized. - `cargo test` (33 passed) and `cargo clippy` pass cleanly.
andreban added 1 commit 2026-10-26 19:58:09 +00:00
andreban merged commit a8961b12e3 into main 2026-10-26 19:59:47 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: andreban/gemini-rs#17