Skip to content

Commit 2480035

Browse files
authored
fix(aws): Prevent stream option with response_format (#151) (#153)
* Added a check to raise a ValueError if the 'stream' option is provided alongside 'response_format', as it is not supported. * Removed redundant stream assignment from the main logic for clarity.
1 parent 8ab5178 commit 2480035

File tree

1 file changed

+5
-2
lines changed
  • src/any_llm/providers/aws

1 file changed

+5
-2
lines changed

src/any_llm/providers/aws/aws.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ def completion(
6565
self._check_aws_credentials()
6666

6767
client = boto3.client("bedrock-runtime", endpoint_url=self.config.api_base, region_name=self.region_name) # type: ignore[no-untyped-call]
68+
stream = kwargs.pop("stream", False)
6869

6970
if "response_format" in kwargs:
71+
if stream:
72+
msg = "stream is not supported for response_format"
73+
raise ValueError(msg)
74+
7075
instructor_client = instructor.from_bedrock(client)
7176
response_format = kwargs.pop("response_format")
7277

@@ -79,8 +84,6 @@ def completion(
7984

8085
return _convert_instructor_response(instructor_response, model, "aws")
8186

82-
stream = kwargs.pop("stream", False)
83-
8487
request_config = _convert_kwargs(kwargs)
8588

8689
system_message, formatted_messages = _convert_messages(messages)

0 commit comments

Comments
 (0)