|
| 1 | +import logging |
1 | 2 | import os |
2 | 3 | import typing |
3 | 4 | from typing import Any, List, Optional, Sequence, Tuple |
4 | | -import logging |
5 | 5 |
|
6 | 6 | import httpx |
7 | 7 | from opentelemetry.sdk.resources import Resource |
8 | 8 | from opentelemetry.sdk.trace import TracerProvider |
9 | 9 | from opentelemetry.trace import Tracer |
10 | 10 |
|
| 11 | +from humanloop.base_client import AsyncBaseHumanloop, BaseHumanloop |
11 | 12 | from humanloop.core.client_wrapper import SyncClientWrapper |
12 | | - |
| 13 | +from humanloop.decorators.flow import flow as flow_decorator_factory |
| 14 | +from humanloop.decorators.prompt import prompt_decorator_factory |
| 15 | +from humanloop.decorators.tool import tool_decorator_factory as tool_decorator_factory |
| 16 | +from humanloop.environment import HumanloopEnvironment |
13 | 17 | from humanloop.evals import run_eval |
14 | 18 | from humanloop.evals.types import ( |
15 | 19 | DatasetEvalConfig, |
16 | | - EvaluatorEvalConfig, |
17 | 20 | EvaluatorCheck, |
| 21 | + EvaluatorEvalConfig, |
18 | 22 | FileEvalConfig, |
19 | 23 | ) |
20 | | - |
21 | | -from humanloop.base_client import AsyncBaseHumanloop, BaseHumanloop |
22 | | -from humanloop.overload import overload_client |
23 | | -from humanloop.decorators.flow import flow as flow_decorator_factory |
24 | | -from humanloop.decorators.prompt import prompt_decorator_factory |
25 | | -from humanloop.decorators.tool import tool_decorator_factory as tool_decorator_factory |
26 | | -from humanloop.environment import HumanloopEnvironment |
27 | 24 | from humanloop.evaluations.client import EvaluationsClient |
28 | 25 | from humanloop.otel import instrument_provider |
29 | 26 | from humanloop.otel.exporter import HumanloopSpanExporter |
30 | 27 | from humanloop.otel.processor import HumanloopSpanProcessor |
| 28 | +from humanloop.overload import overload_client |
31 | 29 | from humanloop.prompt_utils import populate_template |
32 | 30 | from humanloop.prompts.client import PromptsClient |
33 | | -from humanloop.sync.sync_client import SyncClient, DEFAULT_CACHE_SIZE |
| 31 | +from humanloop.sync.file_syncer import DEFAULT_CACHE_SIZE, FileSyncer |
34 | 32 |
|
35 | 33 | logger = logging.getLogger("humanloop.sdk") |
36 | 34 |
|
@@ -160,19 +158,20 @@ def __init__( |
160 | 158 | ) |
161 | 159 |
|
162 | 160 | # Check if cache_size is non-default but use_local_files is False |
163 | | - self._sync_client = SyncClient(client=self, base_dir=local_files_directory, cache_size=cache_size) |
| 161 | + self._file_syncer = FileSyncer(client=self, base_dir=local_files_directory, cache_size=cache_size) |
164 | 162 | eval_client = ExtendedEvalsClient(client_wrapper=self._client_wrapper) |
165 | 163 | eval_client.client = self |
166 | 164 | self.evaluations = eval_client |
167 | 165 | self.prompts = ExtendedPromptsClient(client_wrapper=self._client_wrapper) |
168 | 166 |
|
169 | 167 | # Overload the .log method of the clients to be aware of Evaluation Context |
170 | 168 | # and the @flow decorator providing the trace_id |
| 169 | + # Additionally, call and log methods are overloaded in the prompts and agents client to support the use of local files |
171 | 170 | self.prompts = overload_client( |
172 | | - client=self.prompts, sync_client=self._sync_client, use_local_files=self.use_local_files |
| 171 | + client=self.prompts, file_syncer=self._file_syncer, use_local_files=self.use_local_files |
173 | 172 | ) |
174 | 173 | self.agents = overload_client( |
175 | | - client=self.agents, sync_client=self._sync_client, use_local_files=self.use_local_files |
| 174 | + client=self.agents, file_syncer=self._file_syncer, use_local_files=self.use_local_files |
176 | 175 | ) |
177 | 176 | self.flows = overload_client(client=self.flows) |
178 | 177 | self.tools = overload_client(client=self.tools) |
@@ -440,7 +439,7 @@ def pull(self, path: Optional[str] = None, environment: Optional[str] = None) -> |
440 | 439 | or filesystem issues) |
441 | 440 | :raises HumanloopRuntimeError: If there's an error communicating with the API |
442 | 441 | """ |
443 | | - return self._sync_client.pull(environment=environment, path=path) |
| 442 | + return self._file_syncer.pull(environment=environment, path=path) |
444 | 443 |
|
445 | 444 |
|
446 | 445 | class AsyncHumanloop(AsyncBaseHumanloop): |
|
0 commit comments