Skip to content

Commit db5e37a

Browse files
committed
add DEFAULT_CACHE_SIZE constant
1 parent 39662df commit db5e37a

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/humanloop/client.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from humanloop.otel.processor import HumanloopSpanProcessor
2525
from humanloop.prompt_utils import populate_template
2626
from humanloop.prompts.client import PromptsClient
27-
from humanloop.sync.sync_client import SyncClient
27+
from humanloop.sync.sync_client import SyncClient, DEFAULT_CACHE_SIZE
2828

2929

3030
class ExtendedEvalsClient(EvaluationsClient):
@@ -101,6 +101,7 @@ def __init__(
101101
opentelemetry_tracer: Optional[Tracer] = None,
102102
use_local_files: bool = False,
103103
files_directory: str = "humanloop",
104+
cache_size: int = DEFAULT_CACHE_SIZE,
104105
):
105106
"""
106107
Extends the base client with custom evaluation utilities and
@@ -110,6 +111,21 @@ def __init__(
110111
You can provide a TracerProvider and a Tracer to integrate
111112
with your existing telemetry system. If not provided,
112113
an internal TracerProvider will be used.
114+
115+
Parameters
116+
----------
117+
base_url: Optional base URL for the API
118+
environment: The environment to use (default: DEFAULT)
119+
api_key: Your Humanloop API key (default: from HUMANLOOP_API_KEY env var)
120+
timeout: Optional timeout for API requests
121+
follow_redirects: Whether to follow redirects
122+
httpx_client: Optional custom httpx client
123+
opentelemetry_tracer_provider: Optional tracer provider for telemetry
124+
opentelemetry_tracer: Optional tracer for telemetry
125+
use_local_files: Whether to use local files for prompts and agents
126+
files_directory: Directory for local files (default: "humanloop")
127+
cache_size: Maximum number of files to cache when use_local_files is True (default: DEFAULT_CACHE_SIZE).
128+
This parameter has no effect if use_local_files is False.
113129
"""
114130
super().__init__(
115131
base_url=base_url,
@@ -121,7 +137,11 @@ def __init__(
121137
)
122138

123139
self.use_local_files = use_local_files
124-
self._sync_client = SyncClient(client=self, base_dir=files_directory)
140+
self._sync_client = SyncClient(
141+
client=self,
142+
base_dir=files_directory,
143+
cache_size=cache_size
144+
)
125145
eval_client = ExtendedEvalsClient(client_wrapper=self._client_wrapper)
126146
eval_client.client = self
127147
self.evaluations = eval_client

src/humanloop/sync/sync_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
if not logger.hasHandlers():
2222
logger.addHandler(console_handler)
2323

24+
# Default cache size for file content caching
25+
DEFAULT_CACHE_SIZE = 100
26+
2427
class SyncClient:
2528
"""Client for managing synchronization between local filesystem and Humanloop.
2629
@@ -37,14 +40,14 @@ def __init__(
3740
self,
3841
client: "BaseHumanloop",
3942
base_dir: str = "humanloop",
40-
cache_size: int = 100
43+
cache_size: int = DEFAULT_CACHE_SIZE
4144
):
4245
"""
4346
Parameters
4447
----------
4548
client: Humanloop client instance
4649
base_dir: Base directory for synced files (default: "humanloop")
47-
cache_size: Maximum number of files to cache (default: 100)
50+
cache_size: Maximum number of files to cache (default: DEFAULT_CACHE_SIZE)
4851
"""
4952
self.client = client
5053
self.base_dir = Path(base_dir)

0 commit comments

Comments
 (0)