Skip to content

fix: return type#12

Merged
JohnRichard4096 merged 1 commit intomainfrom
fix/return-type
Feb 18, 2026
Merged

fix: return type#12
JohnRichard4096 merged 1 commit intomainfrom
fix/return-type

Conversation

@JohnRichard4096
Copy link
Copy Markdown
Member

@JohnRichard4096 JohnRichard4096 commented Feb 18, 2026

Summary by Sourcery

Adjust chat response streaming to treat both MessageContent and raw string chunks as streamable output while preserving UniResponse as the final result, and bump the package patch version.

Bug Fixes:

  • Ensure string chunks returned from chat completion are correctly handled as streamed message content rather than being ignored.

Build:

  • Bump project version from 0.4.3 to 0.4.3.1.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Feb 18, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts chat streaming type handling to treat both MessageContent and raw strings uniformly while ensuring UniResponse is captured as the final response, and bumps the package patch version.

Sequence diagram for updated chat streaming type handling

sequenceDiagram
  participant ChatManager
  participant ChatAdapter

  ChatManager->>ChatAdapter: call_completion(send_messages, config, preset)
  loop for each chunk
    ChatAdapter-->>ChatManager: chunk
    alt chunk is UniResponse
      ChatManager->>ChatManager: set response = chunk
    else chunk is MessageContent or str
      ChatManager->>ChatManager: yield_response(chunk)
    end
  end
  ChatManager->>ChatManager: if response is None raise RuntimeError
  ChatManager-->>ChatAdapter: final response consumed
Loading

Class diagram for updated chat streaming types in _process_chat

classDiagram
  class ChatManager {
    +config
    +preset
    +yield_response(content)
    +_process_chat()
  }

  class UniResponse {
  }

  class MessageContent {
  }

  class StringMessageContent {
    +StringMessageContent(value)
  }

  ChatManager ..> UniResponse : uses as final response
  ChatManager ..> MessageContent : streams instances
  ChatManager ..> StringMessageContent : previously wrapped raw strings
  MessageContent <|-- StringMessageContent : specialization
Loading

File-Level Changes

Change Details Files
Update chat streaming loop to correctly discriminate between UniResponse, MessageContent, and string chunks.
  • Remove the special-case branch that wrapped string chunks in StringMessageContent before yielding.
  • Ensure UniResponse chunks are captured as the final response object instead of being yielded directly.
  • Allow the yield branch to handle both MessageContent and string chunks via a unified isinstance check, delegating to yield_response for emission.
src/amrita_core/chatmanager.py
Bump library patch version to reflect the bugfix.
  • Increment project version from 0.4.3 to 0.4.3.1 in project metadata.
pyproject.toml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JohnRichard4096 JohnRichard4096 merged commit 6afdd32 into main Feb 18, 2026
2 checks passed
@JohnRichard4096 JohnRichard4096 deleted the fix/return-type branch February 18, 2026 07:17
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