File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
tests/integration_tests/clients/bedrock Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class AI21BedrockClient:
1515
1616 def __init__ (
1717 self ,
18- model_id : str ,
18+ model_id : Optional [ str ] = None ,
1919 session : Optional [boto3 .Session ] = None ,
2020 region : Optional [str ] = None ,
2121 env_config : _AI21EnvConfig = AI21EnvConfig ,
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ def create(
4343
4444 model_id = kwargs .get ("model_id" , self ._model_id )
4545
46+ if model_id is None :
47+ raise ValueError ("model_id should be provided in either the constructor or the 'create' method call" )
48+
4649 raw_response = self ._invoke (model_id = model_id , body = body )
4750
4851 return CompletionsResponse .from_dict (raw_response )
Original file line number Diff line number Diff line change @@ -68,3 +68,12 @@ def test_completion__when_no_penalties__should_return_response(
6868 assert len ([completion .data .text for completion in response .completions ]) == 1
6969 for completion in response .completions :
7070 assert isinstance (completion .data .text , str )
71+
72+
73+ @pytest .mark .skipif (should_skip_bedrock_integration_tests (), reason = "No keys supplied for AWS. Skipping." )
74+ def test_completion__when_no_model_id__should_raise_exception ():
75+ with pytest .raises (ValueError ) as e :
76+ client = AI21BedrockClient ()
77+ client .completion .create (prompt = _PROMPT )
78+
79+ assert e .value .args [0 ] == "model_id should be provided in either the constructor or the 'create' method call"
You can’t perform that action at this time.
0 commit comments