Refactor message creation methods and rename generation method#17
Open
raghubetina wants to merge 1 commit into
Open
Refactor message creation methods and rename generation method#17raghubetina wants to merge 1 commit into
raghubetina wants to merge 1 commit into
Conversation
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).
raghubetina
commented
May 21, 2025
|
|
||
| # Add a user message to the chat | ||
| x.user("Hi there!") | ||
| x.add("Hi there!", role: "user") |
Contributor
Author
There was a problem hiding this comment.
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"
raghubetina
commented
May 21, 2025
|
|
||
| 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 |
Contributor
Author
There was a problem hiding this comment.
This gem is brand new and no one is using it yet so we can go ahead and drop these methods now.
raghubetina
commented
May 21, 2025
Contributor
Author
raghubetina
left a comment
There was a problem hiding this comment.
Nice start. Added a couple of requests
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to c01b07f in 1 minute and 51 seconds. Click for details.
- Reviewed
518lines of code in3files - Skipped
0files when reviewing. - Skipped posting
7draft 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%<= threshold50%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%<= threshold50%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%<= threshold50%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%<= threshold50%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 by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
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.
This commit introduces the following changes:
addmethod to consolidatesystem,user, andassistantmessage creation. Theaddmethod takescontentand an optionalrole(defaults to "user") and supports image attachments for user messages.assistant!method togenerate!for clarity.system,user,assistant, andassistant!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::Chatby addingaddmethod, renamingassistant!togenerate!, and deprecating old methods with warnings.addmethod inchat.rbto consolidatesystem,user, andassistantmessage creation, supportingcontent,role, and image attachments.assistant!togenerate!inchat.rb.system,user,assistant, andassistant!methods inchat.rb, issuing deprecation warnings and redirecting to new methods.README.mdto reflect newaddandgenerate!methods.basic_functionality_spec.rbto test newaddandgenerate!methods and deprecation warnings.This description was created by
for c01b07f. You can customize this summary. It will automatically update as commits are pushed.