-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor message creation methods and rename generation method #17
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
base: main
Are you sure you want to change the base?
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).
|
|
||
| # Add a user message to the chat | ||
| x.user("Hi there!") | ||
| x.add("Hi there!", role: "user") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
There was a problem hiding this comment.
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.
raghubetina
left a comment
There was a problem hiding this 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
There was a problem hiding this 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
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 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.