Conversation
- Replaced plain `String` content in `ChatMessage` with a new `ChatMessageContentValue` enum that can hold either simple text or typed content (text + image URL). - Added `TypedChatMessageContent` and `URLObject` structs to represent image payloads. - Updated every construction site (system, user, tool messages) to wrap text in `ChatMessageContentValue::Text`. - Adjusted chunk-accumulation logic so only text variants can be appended. - Added serde round-trip tests for both text and image-url forms. - Bumped `nah_chat` crate to 0.6.0 and fixed a clippy warning (`choices_arr.get(0)` → `choices_arr.first()`).
- Add `tokio` dev-dependency so examples can run. - Create `examples/calorie.rs` that streams a vision request: it sends an image URL plus a prompt asking for calorie estimation and prints the response. - Extend `TypedChatMessageContent` with convenience constructors `text_content` and `image_url_content`. - Change `ChatMessageContentValue::TypedContent` to `TypedContentList`, now holding a vector, and update `Display` to concatenate all parts. - Add `ChatMessage::user_text_message` helper for quick text-only user messages.
- Wraps the single image_url content block in an array to match the new TypedContentList format - Adjusts the assertion to compare against a vec![...] instead of a lone TypedChatMessageContent
- Introduced `chat_completion()` that returns a single `ChatMessage` instead of a stream. - Removed streaming logic from `examples/calorie.rs` and switched to the new method. - Dropped unused `futures_util` imports from the example.
Rewrote non streaming response parser to use mutable `Value` manipulation (`remove`, `as_array_mut`, `as_object_mut`) instead of chained immutable accessors, avoiding unnecessary clones. Nit change: - Replaced commented-out `///` doc line with proper `//!` crate-level doc. - Removed unused `use reqwest;` import in error module. - Simplified `Error::cause` implementation by replacing `and_then` with `map`. - Adopted field-init shorthand (`base_url`, `auth_token`) in `ChatClient::init`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes to
nah_chat:ChatMessageContentValue, andTypedChatMessageContentto support image contents.chat_completionAPI.