V10.538 對齊 ai_calls ollama_other provider
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
This commit is contained in:
@@ -32,6 +32,7 @@ from services.ai_call_logger import (
|
||||
_calc_cost,
|
||||
_CallState,
|
||||
_is_logging_enabled,
|
||||
_normalize_provider,
|
||||
_reset_kill_switch,
|
||||
log_ai_call,
|
||||
logged_ai_call,
|
||||
@@ -185,6 +186,22 @@ def test_context_manager_can_update_actual_provider_after_retry(reset_state):
|
||||
assert rec['provider'] == 'ollama_secondary'
|
||||
|
||||
|
||||
def test_provider_normalization_keeps_ai_calls_check_safe(reset_state):
|
||||
assert _normalize_provider('') == 'ollama_other'
|
||||
assert _normalize_provider('unknown') == 'ollama_other'
|
||||
assert _normalize_provider('ollama_other') == 'ollama_other'
|
||||
assert _normalize_provider('gemini-2.5-flash') == 'gemini'
|
||||
assert _normalize_provider('anthropic') == 'claude'
|
||||
assert _normalize_provider('nvidia/nemotron') == 'nim'
|
||||
|
||||
captured = reset_state
|
||||
with log_ai_call('hermes_analyst', 'unknown', 'hermes3:latest'):
|
||||
pass
|
||||
|
||||
assert _wait_for_async(captured, 1)
|
||||
assert captured[0]['provider'] == 'ollama_other'
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# decorator 測試
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -65,6 +65,15 @@ def test_host_health_probe_label_check_accepts_runtime_labels():
|
||||
assert f"'{label}'" in migration
|
||||
|
||||
|
||||
def test_ai_calls_provider_check_accepts_ollama_other_telemetry_bucket():
|
||||
migration = (ROOT / "migrations" / "043_allow_ollama_other_ai_calls_provider.sql").read_text(encoding="utf-8")
|
||||
|
||||
assert "DROP CONSTRAINT IF EXISTS chk_ai_calls_provider" in migration
|
||||
assert "ADD CONSTRAINT chk_ai_calls_provider" in migration
|
||||
assert "'ollama_other'" in migration
|
||||
assert "NOT VALID" in migration
|
||||
|
||||
|
||||
def test_rag_embedding_signature_migration_covers_query_and_learning_tables():
|
||||
migration = (ROOT / "migrations" / "034_add_embedding_signature_to_rag_tables.sql").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class TestGetProviderTag:
|
||||
assert get_provider_tag('http://192.168.0.188:11434') == 'ollama_other'
|
||||
|
||||
@pytest.mark.parametrize('host,expected', [
|
||||
# 對齊 ai_calls 表 CHECK constraint 白名單
|
||||
# 對齊 ai_calls 表 CHECK constraint 白名單(migration 043 補 ollama_other)
|
||||
('http://34.143.170.20:11434', 'gcp_ollama'),
|
||||
('http://192.168.0.110:11435', 'gcp_ollama'),
|
||||
('http://34.21.145.224:11434', 'ollama_secondary'),
|
||||
|
||||
Reference in New Issue
Block a user