Skip to content

Commit

Permalink
wip: fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsbatista committed Aug 13, 2024
1 parent 5221171 commit f858cb2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ def run(
# rename the meta key to be inline with OpenAI meta output keys
for response in replies:
if response.meta is not None:
if 'usage' not in response.meta:
if "usage" not in response.meta:
if "prompt_token_count" in response.meta:
response.meta["prompt_tokens"] = response.meta.pop("prompt_token_count")
if 'generation_token_count' in response.meta:
if "generation_token_count" in response.meta:
response.meta["completion_tokens"] = response.meta.pop("generation_token_count")
elif "usage" in response.meta:
if "input_tokens" in response.meta['usage']:
response.meta["usage"]['prompt_tokens'] = response.meta['usage'].pop("input_tokens")
if "output_token" in response.meta['usage']:
response.meta["usage"]['completion_tokens'] = response.meta['usage'].pop("output_token")
if "input_tokens" in response.meta["usage"]:
response.meta["usage"]["prompt_tokens"] = response.meta["usage"].pop("input_tokens")
if "output_token" in response.meta["usage"]:
response.meta["usage"]["completion_tokens"] = response.meta["usage"].pop("output_token")
else:
print("DEBUG", response.meta)

Expand Down
12 changes: 6 additions & 6 deletions integrations/amazon_bedrock/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ def test_default_inference_params(self, model_name, chat_messages):
assert "paris" in first_reply.content.lower(), "First reply does not contain 'paris'"
assert first_reply.meta, "First reply has no metadata"

if first_reply.meta and 'usage' in first_reply.meta:
assert 'prompt_tokens' in first_reply.meta['usage']
assert 'completion_tokens' in first_reply.meta['usage']
if first_reply.meta and "usage" in first_reply.meta:
assert "prompt_tokens" in first_reply.meta["usage"]
assert "completion_tokens" in first_reply.meta["usage"]

if first_reply.meta and 'usage' not in first_reply.meta:
assert 'prompt_tokens' in first_reply.meta
assert 'completion_tokens' in first_reply.meta
if first_reply.meta and "usage" not in first_reply.meta:
assert "prompt_tokens" in first_reply.meta
assert "completion_tokens" in first_reply.meta

@pytest.mark.parametrize("model_name", MODELS_TO_TEST)
@pytest.mark.integration
Expand Down

0 comments on commit f858cb2

Please sign in to comment.