Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions aixplain/modules/model/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ def __getitem__(self, key: Text) -> Any:
return self.run_time
raise KeyError(f"Key '{key}' not found in ModelResponse.")

def get(self, key: Text) -> Any:
return self[key]
def get(self, key: Text, default: Optional[Any] = None) -> Any:
try:
return self[key]
except KeyError:
return default

def __repr__(self) -> str:
fields = []
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_success_poll():
hyp_response = test_model.poll(poll_url=poll_url)
assert isinstance(hyp_response, ModelResponse)
assert hyp_response["completed"] == ref_response["completed"]
assert hyp_response["status"] == ResponseStatus.SUCCESS
assert hyp_response.get("status") == ResponseStatus.SUCCESS


def test_failed_poll():
Expand Down