Skip to content

Commit 7efc3e8

Browse files
author
Lou Kratz
committed
fix: Run Bedrock calls in executor for async
1 parent 0f8cfaf commit 7efc3e8

File tree

1 file changed

+5
-3
lines changed
  • packages/phoenix-evals/src/phoenix/evals/models

1 file changed

+5
-3
lines changed

packages/phoenix-evals/src/phoenix/evals/models/bedrock.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import json
23
import logging
34
from dataclasses import dataclass, field
@@ -21,8 +22,8 @@ class BedrockModel(BaseModel):
2122
AWS API are dynamically throttled when encountering rate limit errors. Requires the `boto3`
2223
package to be installed.
2324
24-
Supports Async:
25-
`boto3` does not support async calls
25+
Supports Async: 🟡
26+
`boto3` does not support async calls, so it's wrapped in an executor.
2627
2728
Args:
2829
model_id (str): The model name to use.
@@ -109,7 +110,8 @@ def _generate(self, prompt: str, **kwargs: Dict[str, Any]) -> str:
109110
return self._parse_output(response) or ""
110111

111112
async def _async_generate(self, prompt: str, **kwargs: Dict[str, Any]) -> str:
112-
return self._generate(prompt, **kwargs)
113+
loop = asyncio.get_event_loop()
114+
return await loop.run_in_executor(None, self._generate, prompt, **kwargs)
113115

114116
def _rate_limited_completion(self, **kwargs: Any) -> Any:
115117
"""Use tenacity to retry the completion call."""

0 commit comments

Comments
 (0)