Skip to content

Commit e2fc2a3

Browse files
committed
refactor(overload): improve client method overloading and error handling
1 parent 7dd6c5b commit e2fc2a3

File tree

6 files changed

+201
-251
lines changed

6 files changed

+201
-251
lines changed

src/humanloop/client.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
)
1919

2020
from humanloop.base_client import AsyncBaseHumanloop, BaseHumanloop
21-
from humanloop.overload import overload_call, overload_log, overload_with_local_files
21+
from humanloop.overload import overload_client
2222
from humanloop.decorators.flow import flow as flow_decorator_factory
2323
from humanloop.decorators.prompt import prompt_decorator_factory
2424
from humanloop.decorators.tool import tool_decorator_factory as tool_decorator_factory
@@ -150,20 +150,14 @@ def __init__(
150150

151151
# Overload the .log method of the clients to be aware of Evaluation Context
152152
# and the @flow decorator providing the trace_id
153-
self.prompts = overload_log(client=self.prompts)
154-
self.prompts = overload_call(client=self.prompts)
155-
self.prompts = overload_with_local_files( # type: ignore [assignment]
156-
client=self.prompts,
157-
sync_client=self._sync_client,
158-
use_local_files=self.use_local_files,
153+
self.prompts = overload_client(
154+
client=self.prompts, sync_client=self._sync_client, use_local_files=self.use_local_files
159155
)
160-
self.agents = overload_with_local_files( # type: ignore [assignment]
161-
client=self.agents,
162-
sync_client=self._sync_client,
163-
use_local_files=self.use_local_files,
156+
self.agents = overload_client(
157+
client=self.agents, sync_client=self._sync_client, use_local_files=self.use_local_files
164158
)
165-
self.flows = overload_log(client=self.flows)
166-
self.tools = overload_log(client=self.tools)
159+
self.flows = overload_client(client=self.flows)
160+
self.tools = overload_client(client=self.tools)
167161

168162
if opentelemetry_tracer_provider is not None:
169163
self._tracer_provider = opentelemetry_tracer_provider

src/humanloop/decorators/flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> Optional[R]:
6767
"messages": func_args.get("messages"),
6868
"trace_parent_id": trace_id,
6969
}
70-
this_flow_log: FlowLogResponse = client.flows._log( # type: ignore [attr-defined]
70+
this_flow_log: FlowLogResponse = client.flows.log(
7171
path=decorator_context.path,
7272
flow=decorator_context.version,
7373
log_status="incomplete",

0 commit comments

Comments
 (0)