-
Notifications
You must be signed in to change notification settings - Fork 285
feat: claude citation support with BedrockModel #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: claude citation support with BedrockModel #631
Conversation
""" | ||
# Validate citations support before starting the thread (fail fast in async context) | ||
self._validate_citations_support(messages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not have this logic client side, and rely on the API to throw a validation exception here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally get your concern, but I'm guessing provider SDK server errors will be cryptic. Happy to take it off though
@@ -24,10 +24,11 @@ | |||
from mcp.types import ImageContent as MCPImageContent | |||
from mcp.types import TextContent as MCPTextContent | |||
|
|||
from strands.types.tools import ToolResultContent, ToolResultStatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why relative to absolute import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy was complaining without it
if "citationsContent" not in state: | ||
state["citationsContent"] = [] | ||
|
||
state["citationsContent"].append(delta_content["citation"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of just appending the response to a list, I can see that the CitationSourceContentDelta
event mentions that it contains "incremental updates to the source content text during streaming responses". Does this mean we are concatenating the strings of the CitationSourceContentDelta events, or just appending the events to an array?
@@ -168,6 +175,7 @@ def handle_content_block_stop(state: dict[str, Any]) -> dict[str, Any]: | |||
current_tool_use = state["current_tool_use"] | |||
text = state["text"] | |||
reasoning_text = state["reasoningText"] | |||
citations_content = state["citationsContent"] if "citationsContent" in state else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is citationsContent
not in state?
@@ -206,6 +214,18 @@ def handle_content_block_stop(state: dict[str, Any]) -> dict[str, Any]: | |||
) | |||
state["reasoningText"] = "" | |||
|
|||
# Handle citations_content independently - not as elif since we can have both text and citations | |||
if citations_content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be made into an elif?
Co-authored-by: Nick Clegg <[email protected]>
Description
Adds support for citations when using Anthropic Claude Sonnet 3.5v2 and above
Related Issues
#570
Documentation PR
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepare
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.