Skip to content

Commit

Permalink
Add support for GenericMessageContent to AmazonBedrockPromptDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Dec 20, 2024
1 parent 78c7e06 commit 787cbae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for `BranchTask` in `StructureVisualizer`.
- `EvalEngine` for evaluating the performance of an LLM's output against a given input.
- `BaseFileLoader.save()` method for saving an Artifact to a destination.
- Support for `GenericMessageContent` in `AmazonBedrockPromptDriver`.

### Changed

Expand Down
3 changes: 3 additions & 0 deletions griptape/drivers/prompt/amazon_bedrock_prompt_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
BaseDeltaMessageContent,
BaseMessageContent,
DeltaMessage,
GenericMessageContent,
ImageMessageContent,
Message,
TextDeltaMessageContent,
Expand Down Expand Up @@ -187,6 +188,8 @@ def __to_bedrock_message_content(self, content: BaseMessageContent) -> dict:
"status": "error" if isinstance(artifact, ErrorArtifact) else "success",
},
}
elif isinstance(content, GenericMessageContent):
return content.artifact.value
else:
raise ValueError(f"Unsupported content type: {type(content)}")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from griptape.artifacts import ActionArtifact, ErrorArtifact, ImageArtifact, ListArtifact, TextArtifact
from griptape.artifacts import ActionArtifact, ErrorArtifact, GenericArtifact, ImageArtifact, ListArtifact, TextArtifact
from griptape.common import ActionCallDeltaMessageContent, PromptStack, TextDeltaMessageContent, ToolAction
from griptape.drivers import AmazonBedrockPromptDriver
from tests.mocks.mock_tool.tool import MockTool
Expand Down Expand Up @@ -299,6 +299,7 @@ def prompt_stack(self, request):
]
)
)
prompt_stack.add_user_message(GenericArtifact("video-file"))

return prompt_stack

Expand Down Expand Up @@ -354,6 +355,7 @@ def messages(self):
],
"role": "user",
},
{"content": ["video-file"], "role": "user"},
]

@pytest.mark.parametrize("use_native_tools", [True, False])
Expand Down

0 comments on commit 787cbae

Please sign in to comment.