chore: remove dead calculate_token_budget, fix hardcoded timestamp
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ from fastapi.responses import StreamingResponse, JSONResponse
|
||||
from contextlib import asynccontextmanager
|
||||
import httpx
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from .config import config
|
||||
from .singleton import get_qdrant_service
|
||||
@@ -96,7 +96,7 @@ async def api_tags():
|
||||
for name in config.cloud.models.keys():
|
||||
data["models"].append({
|
||||
"name": name,
|
||||
"modified_at": "2026-03-25T00:00:00Z",
|
||||
"modified_at": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
|
||||
"size": 0,
|
||||
"digest": "cloud",
|
||||
"details": {"family": "cloud"}
|
||||
|
||||
@@ -83,15 +83,6 @@ def merge_memories(memories: List[Dict]) -> Dict:
|
||||
"ids": ids
|
||||
}
|
||||
|
||||
def calculate_token_budget(total_budget: int, system_ratio: float = 0.2,
|
||||
semantic_ratio: float = 0.5, context_ratio: float = 0.3) -> Dict[int, int]:
|
||||
"""Calculate token budgets for each layer."""
|
||||
return {
|
||||
"system": int(total_budget * system_ratio),
|
||||
"semantic": int(total_budget * semantic_ratio),
|
||||
"context": int(total_budget * context_ratio)
|
||||
}
|
||||
|
||||
def load_system_prompt() -> str:
|
||||
"""Load system prompt from prompts directory."""
|
||||
import logging
|
||||
|
||||
@@ -201,37 +201,6 @@ class TestMergeMemories:
|
||||
assert len(result["ids"]) == 2
|
||||
|
||||
|
||||
class TestCalculateTokenBudget:
|
||||
"""Tests for calculate_token_budget function."""
|
||||
|
||||
def test_default_ratios_sum(self):
|
||||
"""Default ratios should sum to 1.0 (system+semantic+context)."""
|
||||
from app.utils import calculate_token_budget
|
||||
|
||||
result = calculate_token_budget(1000)
|
||||
assert result["system"] + result["semantic"] + result["context"] == 1000
|
||||
|
||||
def test_custom_ratios(self):
|
||||
"""Custom ratios should produce correct proportional budgets."""
|
||||
from app.utils import calculate_token_budget
|
||||
|
||||
result = calculate_token_budget(
|
||||
100, system_ratio=0.1, semantic_ratio=0.6, context_ratio=0.3
|
||||
)
|
||||
assert result["system"] == 10
|
||||
assert result["semantic"] == 60
|
||||
assert result["context"] == 30
|
||||
|
||||
def test_zero_budget(self):
|
||||
"""Zero total budget yields all zeros."""
|
||||
from app.utils import calculate_token_budget
|
||||
|
||||
result = calculate_token_budget(0)
|
||||
assert result["system"] == 0
|
||||
assert result["semantic"] == 0
|
||||
assert result["context"] == 0
|
||||
|
||||
|
||||
class TestBuildAugmentedMessages:
|
||||
"""Tests for build_augmented_messages function (mocked I/O)."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user