Skip to content

[FEATURE] Add Generic Content Type #889

@Unshure

Description

@Unshure

Problem Statement

Strands has a set of content blocks that it supports, but if a custom model provider wants to implement its own custom content block, there is no easy way to do this today.

Proposed Solution

Strands introduces a new GenericContentBlock that is passed through and treated normally by strands. Then model provider can have their own custom implementation for how to handle the generic content type if they wish.

Additionally, existing model providers can also have an extensibility mechanism to handle this generic case, where the user can define how the generic is transformed when using it to call the underlying model.

This could be:

  1. A new parameter to pass in during model provider init that is a function which maps generic types
def map_generic(generic: GenericContentBlock) -> Any:
    ...

model = BedrockModel(generic_mapper=map_generic)
  1. A method on a class that can be overridden by extending that class
class GenericHandlingBedrockModel(BedrockModel):
    @override
    def map_generic(generic: GenericContentBlock) -> Any:
      ...

Use Case

  • A new feature is added to a model provider, but strands hasnt updated their content block implementation to handle it yet
  • There is a temporary regression in a model provider that strands does not intend to fix, but blocks certain use cases
  • A model provider supports content types outside of the types currently in strands, and strands does not plan to support those

Alternatives Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions