Skip to content

Commit f8b075a

Browse files
authored
Fix dependency issue with RunStepFunctionToolCall (#42826)
* try to fix * run black
1 parent 09838cf commit f8b075a

File tree

1 file changed

+23
-9
lines changed
  • sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_converters

1 file changed

+23
-9
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_converters/_models.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,31 @@
33

44
from pydantic import BaseModel
55

6-
from typing import List, Optional, Union
6+
from typing import TYPE_CHECKING, Any, List, Optional, Union
77

88
# Models moved in a later version of agents SDK, so try a few different locations
9-
try:
10-
from azure.ai.projects.models import RunStepFunctionToolCall
11-
except ImportError:
12-
pass
13-
try:
14-
from azure.ai.agents.models import RunStepFunctionToolCall
15-
except ImportError:
16-
pass
9+
# Only import for type checking to avoid runtime import errors
10+
if TYPE_CHECKING:
11+
try:
12+
from azure.ai.projects.models import RunStepFunctionToolCall
13+
except ImportError:
14+
try:
15+
from azure.ai.agents.models import RunStepFunctionToolCall
16+
except ImportError:
17+
# Create a protocol for type checking when the real class isn't available
18+
from typing import Protocol
19+
20+
class RunStepFunctionToolCall(Protocol):
21+
"""Protocol defining the expected interface for RunStepFunctionToolCall."""
22+
23+
id: str
24+
type: str
25+
26+
def get(self, key: str, default: Any = None) -> Any: ...
27+
28+
else:
29+
# At runtime, we don't need the actual class since it's only used in type annotations
30+
RunStepFunctionToolCall = Any
1731

1832
# Message roles constants.
1933
_SYSTEM = "system"

0 commit comments

Comments
 (0)