From 827b47d2d5f3a2f5a12b1138ae57a813b10ff66e Mon Sep 17 00:00:00 2001
From: Takahiro Kikumoto <kikumoto.takahiro@hamee.co.jp>
Date: Tue, 18 Mar 2025 12:01:14 +0900
Subject: [PATCH] Fix system message handling and payload cleanup in AWS
 Bedrock Claude Pipeline

- Corrected the system message extraction to use the "content" field.
- Removed unnecessary deletion of the "system" field from the payload in stream_response method.
---
 examples/pipelines/providers/aws_bedrock_claude_pipeline.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/examples/pipelines/providers/aws_bedrock_claude_pipeline.py b/examples/pipelines/providers/aws_bedrock_claude_pipeline.py
index 4990927..9d03426 100644
--- a/examples/pipelines/providers/aws_bedrock_claude_pipeline.py
+++ b/examples/pipelines/providers/aws_bedrock_claude_pipeline.py
@@ -139,7 +139,7 @@ class Pipeline:
 
             payload = {"modelId": model_id,
                        "messages": processed_messages,
-                       "system": [{'text': system_message if system_message else 'you are an intelligent ai assistant'}],
+                       "system": [{'text': system_message["content"] if system_message else 'you are an intelligent ai assistant'}],
                        "inferenceConfig": {"temperature": body.get("temperature", 0.5)},
                        "additionalModelRequestFields": {"top_k": body.get("top_k", 200), "top_p": body.get("top_p", 0.9)}
                        }
@@ -166,8 +166,6 @@ class Pipeline:
         }
 
     def stream_response(self, model_id: str, payload: dict) -> Generator:
-        if "system" in payload:
-            del payload["system"]
         if "additionalModelRequestFields" in payload:
             del payload["additionalModelRequestFields"]
         streaming_response = self.bedrock_runtime.converse_stream(**payload)