Skip to content

feat(serialization): add two-decimal precision serialization for floa… #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fslongjin
Copy link

@fslongjin fslongjin commented May 7, 2025

feat(serialization): add two-decimal precision serialization for float fields

Added a new serialize_f32_two_decimals helper function to serialize Option fields with exactly two decimal places. Applied this serialization to all float fields in ChatBody (temperature, top_p, n, presence_penalty, frequency_penalty) to ensure consistent numeric formatting in API requests.

Also improved error handling in requests.rs by:

  1. Adding fallback for JSON parsing errors
  2. Enhancing error messages with status codes
  3. Making error messages more descriptive

…t fields

Added a new `serialize_f32_two_decimals` helper function to serialize Option<f32> fields with exactly two decimal places. Applied this serialization to all float fields in ChatBody (temperature, top_p, n, presence_penalty, frequency_penalty) to ensure consistent numeric formatting in API requests.

Also improved error handling in requests.rs by:
1. Adding fallback for JSON parsing errors
2. Enhancing error messages with status codes
3. Making error messages more descriptive

Signed-off-by: jinlong <jinlong@tencent.com>
@fslongjin fslongjin force-pushed the fix-request-f32-serialize branch from b20f03f to 462b58c Compare May 7, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant