Skip to content

[Bug] The Bedrock documentation source can only accept bytes. #1066

@HawkClaws

Description

@HawkClaws

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.13.0

Python Version

3.11.13

Operating System

Windows 11

Installation Method

pip

Steps to Reproduce

Passing non-bytes to source

model = BedrockModel()

content = [
    {"text": "猫の嗅覚は優れてる?"},
    {
        "document": {
            "format": "txt",
            "name": "neko",
            "source": {
                "text": neko_source
            },
            "citations": {"enabled": True}
        }
    }
]
messages = [
    {
        "role":"user",
        "content":content
    }
]


model.stream(messages=messages)

Expected Behavior

Allow passing other types besides bytes

Actual Behavior

The sample passes text, which is supported in Bedrock and is valid format. However, it causes an error.

Additional Context

No response

Possible Solution

result["source"] = {"bytes": document["source"]["bytes"]}

Just
result["source"] = {"bytes": document["source"]["bytes"]}
to
result["source"] = document["source"]

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions