feat: omit None fields on Content, add optional id to function call/response, and add Part helpers (#11) #16
Reference in New Issue
Block a user
Delete Branch "feat/content-none-and-part-helpers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #11
Summary
#[serde(skip_serializing_if = "Option::is_none")]toContent::roleandContent::partssoNonefields are omitted from JSON rather than serialized asnull.Content::system_prompt(prompt)convenience constructor for system instruction contents without a role.id: Option<String>(withskip_serializing_if = "Option::is_none") toFunctionCallDataandFunctionResponseData.Part:Part::with_thought_signature(sig)to attachthought_signature.Part::with_id(id)to setidon function call or response data.Part::function_call_with_id(id, name, args)andPart::function_response_with_id(id, name, response)constructors.FunctionResponsePart::inline_data(mime_type, data)constructor.Part::add_function_response_part(part)andPart::add_function_response_inline_data(mime_type, data)for multimodal function responses.Testing
src/types/common.rs:content_omits_unset_role_and_parts: verifiesNonerole/parts are omitted from JSON and roundtrip cleanly.function_call_id_handling: verifiesidserialization and deserialization onFunctionCallData.function_response_id_handling: verifiesidserialization and deserialization onFunctionResponseData.part_builder_helpers: verifies fluent builder methods forthought_signatureandFunctionResponsePartmedia blocks.cargo test(32 passed) andcargo clippypass cleanly.