-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Run Bedrock calls in executor for async
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/phoenix-evals/tests/phoenix/evals/models/test_bedrock.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import asyncio | ||
|
||
import boto3 | ||
import pytest | ||
from phoenix.evals import BedrockModel | ||
|
||
|
||
def test_bedrock_model_can_be_instantiated(): | ||
session = boto3.Session(region_name="us-west-2") | ||
model = BedrockModel(session=session) | ||
assert model | ||
|
||
|
||
def test_bedrock_async_propagates_errors(): | ||
with pytest.raises(AttributeError, match="'NoneType' object has no attribute 'invoke_model'"): | ||
session = boto3.Session(region_name="us-west-2") | ||
client = session.client("bedrock-runtime") | ||
model = BedrockModel(session=session, client=client) | ||
model.client = None | ||
asyncio.run(model._async_generate("prompt")) |