Skip to content

Conversation

@raghubetina
Copy link
Contributor

@raghubetina raghubetina commented May 21, 2025

This commit introduces the following changes:

  • Adds a new add method to consolidate system, user, and assistant message creation. The add method takes content and an optional role (defaults to "user") and supports image attachments for user messages.
  • Renames the assistant! method to generate! for clarity.
  • Deprecates the old system, user, assistant, and assistant! methods. These methods now call their new counterparts and issue deprecation warnings.

The specs and README have been updated to reflect these changes. This refactoring aims to provide a more intuitive and consistent API for you, especially if you are a beginner, and aligns with the goal of having a single method for adding messages (issue #12).


Important

Refactors message creation in AI::Chat by adding add method, renaming assistant! to generate!, and deprecating old methods with warnings.

  • Behavior:
    • Adds add method in chat.rb to consolidate system, user, and assistant message creation, supporting content, role, and image attachments.
    • Renames assistant! to generate! in chat.rb.
    • Deprecates system, user, assistant, and assistant! methods in chat.rb, issuing deprecation warnings and redirecting to new methods.
  • Documentation:
    • Updates README.md to reflect new add and generate! methods.
  • Testing:
    • Updates basic_functionality_spec.rb to test new add and generate! methods and deprecation warnings.

This description was created by Ellipsis for c01b07f. You can customize this summary. It will automatically update as commits are pushed.

This commit introduces the following changes:

- Adds a new `add` method to consolidate `system`, `user`, and `assistant` message creation.
  The `add` method takes `content` and an optional `role` (defaults to "user") and supports
  image attachments for user messages.
- Renames the `assistant!` method to `generate!` for clarity.
- Deprecates the old `system`, `user`, `assistant`, and `assistant!` methods.
  These methods now call their new counterparts and issue deprecation warnings.

The specs and README have been updated to reflect these changes. This refactoring
aims to provide a more intuitive and consistent API for you, especially if you are a beginner,
and aligns with the goal of having a single method for adding messages (issue #12).

# Add a user message to the chat
x.user("Hi there!")
x.add("Hi there!", role: "user")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
x.add("Hi there!", role: "user")
x.add("Hi there!") # The default value for role: is "user"

And everywhere else in the README, drop role: "user"


Add a way to access the whole API response body (rather than just the message content). Useful for keepig track of tokens, etc.

## Deprecated Methods
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gem is brand new and no one is using it yet so we can go ahead and drop these methods now.

Copy link
Contributor Author

@raghubetina raghubetina left a comment

Choose a reason for hiding this comment

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

Nice start. Added a couple of requests

@raghubetina raghubetina marked this pull request as ready for review May 21, 2025 14:32
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to c01b07f in 1 minute and 51 seconds. Click for details.
  • Reviewed 518 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. README.md:40
  • Draft comment:
    Usage examples are updated correctly. Consider adding a note that role values may also be accepted as symbols if supported, to clarify consistency across the API.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. lib/ai/chat.rb:75
  • Draft comment:
    In the #add method, when both 'image' and 'images' parameters are provided, only the 'images' branch is executed. Consider clarifying the intended behavior or merging both inputs.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. lib/ai/chat.rb:50
  • Draft comment:
    Consider adding validation for the 'role' parameter in the add method to restrict acceptable roles (e.g., 'system', 'user', 'assistant'). This can help catch typos or unintended values early.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. lib/ai/chat.rb:36
  • Draft comment:
    Deprecation warnings use warn but do not include version or removal timeline information. Consider enhancing these messages to guide users on when and how to migrate.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
5. spec/ai/chat/basic_functionality_spec.rb:225
  • Draft comment:
    The inspect test calls the deprecated 'system' method, which triggers a deprecation warning. Consider using the new 'add' method directly to keep test output clean.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
6. README.md:58
  • Draft comment:
    Typographical suggestion: The ellipsis in the assistant response has four dots ('....'). Typically, an ellipsis is represented with three dots ('...'). If this isn’t intentional, please adjust accordingly.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% This is a very minor stylistic suggestion about documentation. The ellipsis is part of example output that's meant to show what the AI model might return. Since this is just example output and not actual code, the exact number of dots is not important. The comment doesn't affect functionality or code quality. The comment is technically correct about standard ellipsis formatting. Could this consistency in documentation help readability? While technically correct, this is far too minor an issue to warrant a PR comment. It's in example output that's meant to be illustrative, not prescriptive. Delete this comment. It's too minor and focuses on formatting in example output rather than actual code quality issues.
7. README.md:303
  • Draft comment:
    Typo found: "keepig" should be "keeping".
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_Hm6L3PvOqteWfBYQ

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

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.

2 participants