Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
qbc2016 committed Mar 13, 2024
1 parent f9628a9 commit f5cc618
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/agentscope/models/openai_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def __call__(
**kwargs,
)

if response.status_code != 200:
raise RuntimeError(response.json())

# step4: record the api invocation if needed
self._save_model_invocation(
arguments={
Expand Down Expand Up @@ -309,6 +312,9 @@ def __call__(
)
raise e

if response.status_code != 200:
raise RuntimeError(response.json())

# step3: record the model api invocation if needed
self._save_model_invocation(
arguments={
Expand Down Expand Up @@ -393,6 +399,9 @@ def __call__(
**kwargs,
)

if response.status_code != 200:
raise RuntimeError(response.json())

# step3: record the model api invocation if needed
self._save_model_invocation(
arguments={
Expand Down
1 change: 1 addition & 0 deletions tests/record_api_invocation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_record_model_invocation_with_init(
"""Test record model invocation with calling init function."""
# prepare mock response
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.model_dump.return_value = self.dummy_response
mock_response.usage.model_dump.return_value = {}

Expand Down

0 comments on commit f5cc618

Please sign in to comment.