Skip to content

Commit 53f91bc

Browse files
authored
Merge pull request #241 from xmican10/rename-api-cache-to-agents
Followup task for LEADS-246 - Renaming api cache to agent
2 parents 8bc9d6c + b4195d9 commit 53f91bc

8 files changed

Lines changed: 29 additions & 17 deletions

File tree

config/system.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ core:
66
fail_on_invalid_data: true # If False don't fail on invalid conversations (like missing context for some metrics)
77
skip_on_failure: false # If True, skip remaining turns when a turn evaluation fails (can be overridden per conversation)
88
cache_enabled: true # Global cache toggle, if True LLM as a judge, embeddings and API queries are cached
9-
cache_base_dir: .caches # Global base cache dir (queries cached separately under /llm (LLM as a judge + embeddings) and /api)
9+
cache_base_dir: .caches # Global base cache dir (queries cached separately under /llm (LLM as a judge + embeddings) and /agent for agent API calls)
1010

1111
# LLM as a judge configuration (Legacy)
1212
# Deprecated: top-level llm: (single judge) will be removed — use llm_pool + judge_panel only.

docs/configuration.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ The system configuration is driven by YAML file. The default config file is [con
88
| max_threads | `50` | Maximum number of threads, set to null for Python default. 50 is OK on a typical laptop. Check your Judge-LLM service for max requests per minute |
99
| fail_on_invalid_data | `true` | If `false` don't fail on invalid conversations (like missing `context` field for some metrics) |
1010
| skip_on_failure | `false` | If `true`, skip remaining turns and conversation metrics when a turn evaluation fails (FAIL or ERROR). Can be overridden per conversation in the input data yaml file. |
11+
| cache_enabled | `true` | Global caching toggle for embeddings, agent API, and LLM judge queries. (_Component-level cache settings are deprecated._) |
12+
| cache_base_dir | `".caches"` | Base directory for all evaluation caches (embeddings, agent, LLM judge). Component-specific subdirectories are appended automatically (`/llm` for LLM-as-a-judge and `/agent` for agent API calls). |
1113

1214
### Example
1315
```yaml
1416
core:
1517
max_threads: 50
1618
fail_on_invalid_data: true
17-
skip_on_failure: false # Set to true to stop evaluation on first failure
19+
skip_on_failure: false # Set to true to stop evaluation on first failure
20+
cache_enabled: true # Global cache toggle (affects all components)
21+
cache_base_dir: ".caches" # Base cache directory
1822
```
1923
2024
## LLM Pool
@@ -25,7 +29,7 @@ Define a centralized pool of LLM configurations for the Judge Panel feature.
2529

2630
| Setting | Description |
2731
|---------|-------------|
28-
| `llm_pool.defaults.cache_dir` | Cache directory (default: `.caches/llm_cache`) |
32+
| `llm_pool.defaults.cache_dir` | Cache directory (default: `.caches/llm_cache`) (_deprecated - use `core.cache_base_dir`_) |
2933
| `llm_pool.defaults.timeout` | Request timeout in seconds (default: `300`) |
3034
| `llm_pool.defaults.num_retries` | Retry attempts (default: `3`) |
3135
| `llm_pool.defaults.parameters.temperature` | Sampling temperature |
@@ -113,8 +117,8 @@ This section configures LLM. It is used when `judge_panel` is not configured (ev
113117
| max_tokens | `512` | Maximum tokens in response |
114118
| timeout | `300` | Request timeout in seconds |
115119
| num_retries | `3` | Maximum retry attempts |
116-
| cache_dir | `".caches/llm_cache"` | Directory with cached LLM responses |
117-
| cache_enabled | `true` | Is LLM cache enabled? |
120+
| cache_dir | `".caches/llm_cache"` | Directory with cached LLM responses (_deprecated - use `core.cache_base_dir`_) |
121+
| cache_enabled | `true` | Is LLM cache enabled? (_deprecated - use `core.cache_enabled`_) |
118122

119123
Dynamic LLM parameters are only supported through `llm_pool` config. To use dynamic parameters, migrate to `llm_pool`.
120124

@@ -128,8 +132,8 @@ Some Ragas metrics use embeddings to compute similarity between generated answer
128132
| provider | `"openai"` | Supported providers: `"openai"`, `"gemini"` or `"huggingface"`. `"huggingface"` downloads the model to the local machine and runs inference locally (requires optional dependencies). |
129133
| model | `"text-embedding-3-small"` | Model name for the provider |
130134
| provider_kwargs | `{}` | Optional arguments for the model |
131-
| cache_dir | `".caches/embedding_cache"` | Directory with cached embeddings |
132-
| cache_enabled | `true` | Is embeddings cache enabled? |
135+
| cache_dir | `".caches/embedding_cache"` | Directory with cached embeddings (_deprecated - use `core.cache_base_dir`_) |
136+
| cache_enabled | `true` | Is embeddings cache enabled? (_deprecated - use `core.cache_enabled`_) |
133137

134138
#### Remote vs Local Embedding Models
135139

@@ -201,8 +205,8 @@ Note that it can be easily integrated with other APIs with a minimal change.
201205
| model | `"gpt-4o-mini"` | Model to use for API queries (optional) |
202206
| no_tools | `null` | Whether to bypass tools (optional) |
203207
| system_prompt | `null` | Custom system prompt (optional) |
204-
| cache_dir | `".caches/api_cache"` | Directory with cached API responses |
205-
| cache_enabled | `true` | Is API cache enabled? |
208+
| cache_dir | `".caches/api_cache"` | Directory with cached API responses (_deprecated - use `core.cache_base_dir`_) |
209+
| cache_enabled | `true` | Is API cache enabled? (_deprecated - use `core.cache_enabled`_) |
206210
| mcp_headers | `null` | MCP headers configuration for authentication (see below) |
207211
| num_retries | `3` | Maximum number of retry attempts for API calls on 429 errors |
208212

src/lightspeed_evaluation/core/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
# Cache configuration
5454
DEFAULT_CACHE_BASE_DIR = ".caches"
55-
DEFAULT_API_CACHE_SUBDIR = "api"
55+
DEFAULT_AGENT_CACHE_SUBDIR = "agent"
5656
DEFAULT_LLM_CACHE_SUBDIR = "llm"
5757

5858
# API Constants

src/lightspeed_evaluation/core/models/llm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ class EmbeddingConfig(BaseModel):
171171
default=None,
172172
description="Embedding provider arguments, e.g. model_kwargs: device:cpu",
173173
)
174+
cache_dir: Optional[str] = Field(
175+
default=None,
176+
description="(Deprecated) Location of cached embedding queries",
177+
)
174178
cache_enabled: bool = Field(
175179
default=True, description="Is caching of embedding queries enabled?"
176180
)

src/lightspeed_evaluation/core/models/system.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
)
1616

1717
from lightspeed_evaluation.core.constants import (
18-
DEFAULT_API_CACHE_SUBDIR,
18+
DEFAULT_AGENT_CACHE_SUBDIR,
1919
DEFAULT_CACHE_BASE_DIR,
2020
DEFAULT_LLM_CACHE_SUBDIR,
2121
DEFAULT_LOG_FORMAT,
@@ -353,11 +353,13 @@ def global_cache_setup(self) -> "SystemConfig":
353353
global_cache_base_dir = self.core.cache_base_dir
354354
# Build cache paths
355355
llm_cache_path = os.path.join(global_cache_base_dir, DEFAULT_LLM_CACHE_SUBDIR)
356-
api_cache_path = os.path.join(global_cache_base_dir, DEFAULT_API_CACHE_SUBDIR)
356+
api_cache_path = os.path.join(global_cache_base_dir, DEFAULT_AGENT_CACHE_SUBDIR)
357357

358358
# If component-level caching is enabled, warn user
359359
has_api_cache_config = self.api.cache_enabled is False or self.api.cache_dir
360-
has_embedding_cache_config = self.embedding.cache_enabled is False
360+
has_embedding_cache_config = (
361+
self.embedding.cache_enabled is False or self.embedding.cache_dir
362+
)
361363
has_llm_pool_cache_config = self.llm_pool and (
362364
self.llm_pool.defaults.cache_enabled is False
363365
or self.llm_pool.defaults.cache_dir

tests/integration/system-config-query.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ embedding:
2424
provider: "openai"
2525
model: "text-embedding-3-small"
2626
provider_kwargs: {}
27+
cache_dir: ".caches/embedding_cache"
2728
cache_enabled: false
2829

2930
# Lightspeed-stack API Configuration

tests/integration/system-config-streaming.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ embedding:
2424
provider: "openai"
2525
model: "text-embedding-3-small"
2626
provider_kwargs: {}
27+
cache_dir: ".caches/embedding_cache"
2728
cache_enabled: false
2829

2930
# Lightspeed-stack API Configuration

tests/unit/core/models/test_system.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def test_global_default_cache_setup_legacy_llm_support(self) -> None:
593593
assert config.embedding.cache_enabled is True
594594

595595
assert config.api.cache_enabled is True
596-
assert config.api.cache_dir == ".caches/api"
596+
assert config.api.cache_dir == ".caches/agent"
597597

598598
def test_global_cache_setup_legacy_llm_support_override(self) -> None:
599599
"""Test cache setup with custom legacy LLM config overrides."""
@@ -611,7 +611,7 @@ def test_global_cache_setup_legacy_llm_support_override(self) -> None:
611611
assert config.embedding.cache_enabled is True
612612

613613
assert config.api.cache_enabled is True
614-
assert config.api.cache_dir == ".caches/api"
614+
assert config.api.cache_dir == ".caches/agent"
615615

616616
def test_global_default_cache_setup_with_judge_panel(self) -> None:
617617
"""Test default cache setup with judge panel configuration."""
@@ -643,7 +643,7 @@ def test_global_default_cache_setup_with_judge_panel(self) -> None:
643643
assert config.embedding.cache_enabled is True
644644

645645
assert config.api.cache_enabled is True
646-
assert config.api.cache_dir == ".caches/api"
646+
assert config.api.cache_dir == ".caches/agent"
647647

648648
def test_global_cache_setup_pool_without_panel(self) -> None:
649649
"""Test that global_cache_setup populates llm_pool.defaults when judge_panel is absent."""
@@ -690,7 +690,7 @@ def test_global_cache_turned_off_with_judge_panel(self) -> None:
690690
assert config.embedding.cache_enabled is False
691691

692692
assert config.api.cache_enabled is False
693-
assert config.api.cache_dir == ".caches_test/api"
693+
assert config.api.cache_dir == ".caches_test/agent"
694694

695695
def test_global_cache_setup_with_judge_panel_override(self) -> None:
696696
"""Test cache setup with custom judge panel config overrides."""

0 commit comments

Comments
 (0)