fix: Add ASSISTANT role to ResponseInputItem message input#667
Open
caioSalchesttes wants to merge 1 commit intoopenai:mainfrom
Open
fix: Add ASSISTANT role to ResponseInputItem message input#667caioSalchesttes wants to merge 1 commit intoopenai:mainfrom
caioSalchesttes wants to merge 1 commit intoopenai:mainfrom
Conversation
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.
Add ASSISTANT role to ResponseInputItem and ResponseInputMessageItem
Summary
This PR adds support for the
assistantrole in bothResponseInputItem.Message.RoleandResponseInputMessageItem.Roleenums, enabling server-side conversation state management.Related Issues
This issue is also mentioned in #585.
Changes
ASSISTANTconstant toRolecompanion objects in both filesASSISTANTtoKnownandValueenumsvalue()andknown()methods to handleASSISTANTcaseassistantas a valid role optionMotivation
When managing conversation state on the server side (the service calling the API), adding assistant messages to the conversation history allows:
Client-side state control: The server can maintain and control the full conversation history, including assistant responses, without relying solely on OpenAI's provided history.
Flexible history management: By including
assistantrole messages in the input, applications can:API compatibility: This change aligns the SDK with the OpenAI API's support for
assistantrole in message inputs, enabling full utilization of the API's capabilities.Testing
Files Changed
openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.ktopenai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputMessageItem.kt