diff --git a/router/__init__.py b/router/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/router/main.py b/router/main.py index 0c976f4f..02b63c75 100644 --- a/router/main.py +++ b/router/main.py @@ -19,7 +19,7 @@ from fastapi.staticfiles import StaticFiles from pathlib import Path from urllib.parse import urlparse -from circuit_breaker import get_breaker +from router.circuit_breaker import get_breaker from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator, RootModel from typing import Dict, Optional, Union diff --git a/scripts/benchmark_classifier.py b/scripts/benchmark_classifier.py index 2878c402..b2b7f1a7 100644 --- a/scripts/benchmark_classifier.py +++ b/scripts/benchmark_classifier.py @@ -1,14 +1,16 @@ """Benchmark gemma4-26a4b-routing classifier against labeled dataset.""" import os -import json, urllib.request, urllib.error, time, sys +import json, urllib.request, urllib.error, time import concurrent.futures import threading from collections import defaultdict, Counter from pathlib import Path # Shared chat response parser (used by verification scripts too) -sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) -from scripts.chat_helpers import parse_chat_response +try: + from scripts.chat_helpers import parse_chat_response +except ImportError: + from chat_helpers import parse_chat_response # Load dataset dataset_path = Path(__file__).resolve().parent.parent / "data" / "classified_dataset.json" diff --git a/scripts/benchmark_tokens.py b/scripts/benchmark_tokens.py index 34c9a2f0..56c79be1 100644 --- a/scripts/benchmark_tokens.py +++ b/scripts/benchmark_tokens.py @@ -5,9 +5,6 @@ # Set CONFIG_PATH and ROUTER_API_KEY for import os.environ["CONFIG_PATH"] = str(Path(__file__).resolve().parent.parent / "router" / "config.yaml") os.environ["ROUTER_API_KEY"] = "local-token" -# Add the parent directory and the router directory to the path -sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) -sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "router")) from router.main import estimate_prompt_tokens, METADATA_OVERHEAD diff --git a/scripts/classify_direct.py b/scripts/classify_direct.py index ee699daf..237609c7 100644 --- a/scripts/classify_direct.py +++ b/scripts/classify_direct.py @@ -1,11 +1,13 @@ """Direct classification of Hermes prompts using gemma4-26a4b-routing.""" import os -import json, urllib.request, time, sys +import json, urllib.request, time from pathlib import Path # Shared chat response parser (used by verification scripts too) -sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) -from scripts.chat_helpers import parse_chat_response +try: + from scripts.chat_helpers import parse_chat_response +except ImportError: + from chat_helpers import parse_chat_response PROMPT_TEMPLATE = """Classify the coding task complexity. Output ONLY the tier name. diff --git a/scripts/reclassify_all.py b/scripts/reclassify_all.py index 38675878..b74e5653 100644 --- a/scripts/reclassify_all.py +++ b/scripts/reclassify_all.py @@ -8,8 +8,10 @@ from collections import Counter # Shared chat response parser (used by verification scripts too) -sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) -from scripts.chat_helpers import parse_chat_response +try: + from scripts.chat_helpers import parse_chat_response +except ImportError: + from chat_helpers import parse_chat_response TIERS = ['agent-simple-core','agent-medium-core','agent-complex-core','agent-reasoning-core','agent-advanced-core'] diff --git a/scripts/retry_errors.py b/scripts/retry_errors.py index ed273721..c4a30754 100644 --- a/scripts/retry_errors.py +++ b/scripts/retry_errors.py @@ -4,8 +4,10 @@ from collections import Counter # Shared chat response parser (used by verification scripts too) -sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) -from scripts.chat_helpers import parse_chat_response +try: + from scripts.chat_helpers import parse_chat_response +except ImportError: + from chat_helpers import parse_chat_response PROMPT_TEMPLATE = """Classify the coding task complexity. Output ONLY the tier name. diff --git a/scripts/verification/verification_helpers.py b/scripts/verification/verification_helpers.py index e4500d61..fa9722d3 100644 --- a/scripts/verification/verification_helpers.py +++ b/scripts/verification/verification_helpers.py @@ -1,8 +1,8 @@ # Shared verification helpers for cooldown and routing tests -import sys -from pathlib import Path -sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) -from scripts.chat_helpers import parse_chat_response +try: + from scripts.chat_helpers import parse_chat_response +except ImportError: + from ..chat_helpers import parse_chat_response import os import uuid import time diff --git a/scripts/verification/verify_breaker.py b/scripts/verification/verify_breaker.py index 6ed9e7c7..37307613 100644 --- a/scripts/verification/verify_breaker.py +++ b/scripts/verification/verify_breaker.py @@ -1,10 +1,6 @@ #!/usr/bin/env python3 """Verification test for the agy circuit breaker.""" -import sys -from pathlib import Path -sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) - from router.circuit_breaker import get_breaker b = get_breaker() diff --git a/scripts/verification/verify_canonical_endpoints.py b/scripts/verification/verify_canonical_endpoints.py index 13c7d9b2..f79855c4 100644 --- a/scripts/verification/verify_canonical_endpoints.py +++ b/scripts/verification/verify_canonical_endpoints.py @@ -19,8 +19,10 @@ WORKDIR = Path(__file__).resolve().parent.parent.parent # Import shared chat response parser (also used by classifier scripts) -sys.path.insert(0, str(WORKDIR)) -from scripts.chat_helpers import parse_chat_response +try: + from scripts.chat_helpers import parse_chat_response +except ImportError: + from ..chat_helpers import parse_chat_response def load_env(dev: bool = False) -> dict: diff --git a/scripts/verification/verify_ollama_routing.py b/scripts/verification/verify_ollama_routing.py index c844e549..c379c6a7 100644 --- a/scripts/verification/verify_ollama_routing.py +++ b/scripts/verification/verify_ollama_routing.py @@ -5,8 +5,10 @@ from pathlib import Path WORKDIR = Path(__file__).resolve().parent.parent.parent -sys.path.insert(0, str(WORKDIR)) -from scripts.chat_helpers import parse_chat_response +try: + from scripts.chat_helpers import parse_chat_response +except ImportError: + from ..chat_helpers import parse_chat_response URL = "http://localhost:5000/v1/chat/completions"