Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

test(embedding): pin the Gemini endpoint rule for both model families

Bingxi Zhao (Frank)fb04addbfa70
diff --git a/tests/services/test_model_catalog.py b/tests/services/test_model_catalog.py
index 6b0e2970b..a471fe44e 100644
--- a/tests/services/test_model_catalog.py
+++ b/tests/services/test_model_catalog.py
@@ -119,9 +119,8 @@ def test_load_recovers_invalid_catalog_with_defaults(tmp_path: Path):
assert set(saved["services"]) == expected_services
-def test_load_sets_gemini_native_endpoint_from_active_embedding_model(tmp_path: Path):
- catalog_path = tmp_path / "model_catalog.json"
- catalog_path.write_text(
+def _gemini_embedding_catalog(path: Path, model: str) -> Path:
+ path.write_text(
json.dumps(
{
"services": {
@@ -138,8 +137,8 @@ def test_load_sets_gemini_native_endpoint_from_active_embedding_model(tmp_path:
"models": [
{
"id": "gemini-model",
- "name": "Gemini 001",
- "model": "gemini-embedding-001",
+ "name": model,
+ "model": model,
}
],
}
@@ -150,11 +149,32 @@ def test_load_sets_gemini_native_endpoint_from_active_embedding_model(tmp_path:
),
encoding="utf-8",
)
+ return path
+
+
+def test_load_sets_gemini_native_endpoint_from_active_embedding_model(tmp_path: Path):
+ catalog_path = _gemini_embedding_catalog(tmp_path / "model_catalog.json", "gemini-embedding-2")
+
+ catalog = ModelCatalogService(path=catalog_path).load()
+
+ profile = catalog["services"]["embedding"]["profiles"][0]
+ assert profile["base_url"].endswith("/models/gemini-embedding-2:batchEmbedContents")
+
+
+def test_load_keeps_older_gemini_embedding_models_on_the_openai_path(tmp_path: Path):
+ """The native route sends a taskType and L2-normalizes, so moving an
+ existing gemini-embedding-001 profile there would change its document
+ vectors and invalidate the index built from them."""
+ catalog_path = _gemini_embedding_catalog(
+ tmp_path / "model_catalog.json", "gemini-embedding-001"
+ )
catalog = ModelCatalogService(path=catalog_path).load()
profile = catalog["services"]["embedding"]["profiles"][0]
- assert profile["base_url"].endswith("/models/gemini-embedding-001:batchEmbedContents")
+ assert profile["base_url"] == (
+ "https://generativelanguage.googleapis.com/v1beta/openai/embeddings"
+ )
def test_load_persists_normalized_active_ids(tmp_path: Path):