-
Notifications
You must be signed in to change notification settings - Fork 21
Adds MessageBuilder class #83
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: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
@JasonTheAdams Thanks for putting this together! Looks great, except one piece that needs to be revised to make it more flexible, especially as we already do it more flexibly in PromptBuilder
.
+withImageFile(File $file) self | ||
+withAudioFile(File $file) self | ||
+withVideoFile(File $file) self | ||
+withFile($file, ?string $mimeType) self |
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.
Great catch updating these! Since you're already on it, could you revise the PromptBuilder
definition here as well, at least replacing similar outdated instances?
* @param string|null $text Optional initial text content. | ||
* @param MessageRoleEnum|null $role Optional role. | ||
*/ | ||
public function __construct(?string $text = null, ?MessageRoleEnum $role = null) |
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 should allow more than just $text
- let's make it mixed $input
, similar to PromptBuilder
.
We should add parity here for all possibilities that identify something within a Message
, at least anything that can become a single MessagePart
.
At least this should support passing a string
(text) or a MessagePart
, or a MessagePartArrayShape
. Maybe even the lower-level pieces to turn into a MessagePart
(which string
is already one of), like File
, FunctionCall
, or FunctionResponse
.
Resolves #81
This introduces the
MessageBuilder
class — Fluent API for constructing messages, very similar to thePromptBuilder
.Note that I've intentionally moved structure validation to the moment of termination because I don't think we should be checking things against the role and such until the implementor considers the builder complete.