Skip to content

Commit a942ed8

Browse files
author
Andrei Bratu
committed
fix typing issue introduced in sync
1 parent ec8087b commit a942ed8

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/humanloop/overload.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
import inspect
22
import logging
33
import types
4-
from typing import Any, Dict, Optional, Union, Callable
4+
from typing import Any, Callable, Dict, Optional, TypeVar, Union
55

6+
from humanloop.agents.client import AgentsClient
7+
from humanloop.client import ExtendedPromptsClient
68
from humanloop.context import (
79
get_decorator_context,
810
get_evaluation_context,
911
get_trace_id,
1012
)
13+
from humanloop.datasets.client import DatasetsClient
1114
from humanloop.error import HumanloopRuntimeError
12-
from humanloop.sync.sync_client import SyncClient
13-
from humanloop.prompts.client import PromptsClient
15+
from humanloop.evaluators.client import EvaluatorsClient
1416
from humanloop.flows.client import FlowsClient
15-
from humanloop.datasets.client import DatasetsClient
16-
from humanloop.agents.client import AgentsClient
17+
from humanloop.prompts.client import PromptsClient
18+
from humanloop.sync.sync_client import SyncClient
1719
from humanloop.tools.client import ToolsClient
18-
from humanloop.evaluators.client import EvaluatorsClient
1920
from humanloop.types import FileType
21+
from humanloop.types.agent_call_response import AgentCallResponse
2022
from humanloop.types.create_evaluator_log_response import CreateEvaluatorLogResponse
2123
from humanloop.types.create_flow_log_response import CreateFlowLogResponse
2224
from humanloop.types.create_prompt_log_response import CreatePromptLogResponse
2325
from humanloop.types.create_tool_log_response import CreateToolLogResponse
2426
from humanloop.types.prompt_call_response import PromptCallResponse
25-
from humanloop.types.agent_call_response import AgentCallResponse
2627

2728
logger = logging.getLogger("humanloop.sdk")
2829

@@ -183,11 +184,22 @@ def _overload_call(self: Any, sync_client: Optional[SyncClient], use_local_files
183184
raise HumanloopRuntimeError from e
184185

185186

187+
ClientTemplateType = TypeVar(
188+
"ClientTemplateType",
189+
bound=Union[
190+
FlowsClient,
191+
ExtendedPromptsClient,
192+
AgentsClient,
193+
ToolsClient,
194+
],
195+
)
196+
197+
186198
def overload_client(
187-
client: Any,
199+
client: ClientTemplateType,
188200
sync_client: Optional[SyncClient] = None,
189201
use_local_files: bool = False,
190-
) -> Any:
202+
) -> ClientTemplateType:
191203
"""Overloads client methods to add tracing, local file handling, and evaluation context."""
192204
# Store original log method as _log for all clients. Used in flow decorator
193205
if hasattr(client, "log") and not hasattr(client, "_log"):

0 commit comments

Comments
 (0)