-
Notifications
You must be signed in to change notification settings - Fork 133
Bedrock Converse Streaming Support #1565
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?
Conversation
✅MegaLinter analysis: Success
See detailed reports in MegaLinter artifacts |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1565 +/- ##
=======================================
Coverage 81.81% 81.82%
=======================================
Files 207 207
Lines 23953 23988 +35
Branches 3799 3808 +9
=======================================
+ Hits 19597 19628 +31
- Misses 3087 3090 +3
- Partials 1269 1270 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
71d4d32 to
d992b41
Compare
472ec94 to
c9ff7cb
Compare
| "error.message": error_attributes.get("error.message"), | ||
| "error.code": error_attributes.get("error.code"), | ||
| } | ||
| notice_error_attributes.update({"completion_id": str(uuid.uuid4())}) |
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.
| notice_error_attributes.update({"completion_id": str(uuid.uuid4())}) | |
| notice_error_attributes["completion_id"] = str(uuid.uuid4())}) |
Since this is just one pair being added to the dict, would direct access be more performant?
| if "messageStop" in event: | ||
| bedrock_attrs["response.choices.finish_reason"] = (event.get("messageStop") or {}).get("stopReason", "") | ||
|
|
||
| # TODO: Is this also subject to the content_block_stop behavior from Langchain? |
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.
Flagging this for discussion
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.
Unrelated to your changes but I noticed around line 762 the following code is missing a () after global_settings:
settings = transaction.settings or global_settings
Could you add that in while you're in here?
|
|
||
|
|
||
| def extract_bedrock_converse_attrs(kwargs, response, response_headers, model, span_id, trace_id): | ||
| input_message_list = [] |
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.
| input_message_list = [] | |
| input_message_list = [] | |
| output_message_list = None | |
| # If a system message is supplied, it is under its own key in kwargs rather than with the other input messages | |
| if "system" in kwargs.keys(): | |
| input_message_list.extend({"role": "system", "content": result["text"]} for result in kwargs.get("system", [])) | |
| # kwargs["messages"] can hold multiple requests and responses to maintain conversation history | |
| # We grab the last message (the newest request) in the list each time, so we don't duplicate recorded data | |
| _input_messages = kwargs.get("messages", []) | |
| _input_messages = _input_messages and (_input_messages[-1] or {}) | |
| _input_messages = _input_messages.get("content", []) | |
| input_message_list.extend( | |
| [{"role": "user", "content": result["text"]} for result in _input_messages if "text" in result] | |
| ) |
These changes were on the strands/ converse branch to prevent KeyErrors so we may want to port them into this branch.

Overview
BedrockRuntime.converse_streaminbotocoreandboto3.