-
Notifications
You must be signed in to change notification settings - Fork 605
Description
Problem Statement
Strands SDK currently follows the Bedrock Converse API format which is not compatible with the OpenAI Message format.
Some noticeable differences are:
- The roles accepted. Bedrock only accepts
userandassistantwhereas OpenAI supports additional roles such astool - The message format is different. For example the Bedrock API formats a text block with JSON
"messages": [ { "role": "user", "content": [ { "text": "Hello, how are you?" } ] },. Whereas the OpenAI format is just the text set to thecontentfield:"messages": [ { "role": "system", "content": "You are a helpful assistant." },]
This can cause issues when a developer wants to migrate their existing OpenAI conversations to work natively with Strands SDK.
Proposed Solution
We can add the following two methods to the SessionManager base class:
serialize() and deserialize(). All the SessionManagers that inherit the session manager bases class will have these methods automatically. By default - these methods will just return the current message. deserialize() will be called for each message when the session manager loads messages from it's history. serialize() will be called on each message prior to storing the message.
Customers can then implement these methods in their session managers to convert their message format to the Bedrock API format so that Strands can work with the messages as normal and they can continue to store the messages in the format of their choosing.
For example, a customer bringing messages from OpenAI can simply have the following:
class MySpecialSessionManager(S3SessionManager):
@override
def deserialize(msg: Message):
return convert_from_open_ai(msg)
@override
def serialize(msg: Message):
return convert_to_open_ai(msg)This will allow us to support customers bringing over existing messages that are in formats other than the Bedrock API format and allow for seamless use with Strands SDK.
Use Case
Customers migrating conversations to Strands that they have stored in the OpenAI message format
Alternatives Solutions
We build a Convertor layer into the SDK so the SDK will be message format agnostic.
Additional Context
No response