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.
This commit is contained in:
Takahiro Kikumoto 2025-03-18 12:01:14 +09:00
parent f89ab37f53
commit 827b47d2d5

View File

@ -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)