|
6 | 6 | DEFAULT_TTL_BY_TYPE, |
7 | 7 | _build_container_kwargs, |
8 | 8 | _make_memory, |
| 9 | + _resolve_distance_function, |
| 10 | + _resolve_embedding_data_type, |
| 11 | + _resolve_full_text_language, |
9 | 12 | compute_content_hash, |
10 | 13 | ) |
11 | | -from agent_memory_toolkit.exceptions import ValidationError |
| 14 | +from agent_memory_toolkit.exceptions import ConfigurationError, ValidationError |
12 | 15 |
|
13 | 16 |
|
14 | 17 | def test_build_container_kwargs_includes_required_fields_and_extras(): |
@@ -180,3 +183,50 @@ def test_make_memory_invalid_role(): |
180 | 183 | def test_make_memory_invalid_type(): |
181 | 184 | with pytest.raises(ValidationError): |
182 | 185 | _make_memory(user_id="u1", role="user", content="test", memory_type="invalid") |
| 186 | + |
| 187 | + |
| 188 | +def test_resolve_embedding_data_type_defaults(monkeypatch): |
| 189 | + monkeypatch.delenv("AI_FOUNDRY_EMBEDDING_DATA_TYPE", raising=False) |
| 190 | + assert _resolve_embedding_data_type(None) == "float32" |
| 191 | + |
| 192 | + |
| 193 | +def test_resolve_embedding_data_type_from_env(monkeypatch): |
| 194 | + monkeypatch.setenv("AI_FOUNDRY_EMBEDDING_DATA_TYPE", "int8") |
| 195 | + assert _resolve_embedding_data_type(None) == "int8" |
| 196 | + |
| 197 | + |
| 198 | +def test_resolve_embedding_data_type_explicit_overrides_env(monkeypatch): |
| 199 | + monkeypatch.setenv("AI_FOUNDRY_EMBEDDING_DATA_TYPE", "int8") |
| 200 | + assert _resolve_embedding_data_type("uint8") == "uint8" |
| 201 | + |
| 202 | + |
| 203 | +def test_resolve_embedding_data_type_invalid_raises(monkeypatch): |
| 204 | + monkeypatch.setenv("AI_FOUNDRY_EMBEDDING_DATA_TYPE", "bogus") |
| 205 | + with pytest.raises(ConfigurationError): |
| 206 | + _resolve_embedding_data_type(None) |
| 207 | + |
| 208 | + |
| 209 | +def test_resolve_distance_function_defaults(monkeypatch): |
| 210 | + monkeypatch.delenv("AI_FOUNDRY_EMBEDDING_DISTANCE_FUNCTION", raising=False) |
| 211 | + assert _resolve_distance_function(None) == "cosine" |
| 212 | + |
| 213 | + |
| 214 | +def test_resolve_distance_function_from_env(monkeypatch): |
| 215 | + monkeypatch.setenv("AI_FOUNDRY_EMBEDDING_DISTANCE_FUNCTION", "dotproduct") |
| 216 | + assert _resolve_distance_function(None) == "dotproduct" |
| 217 | + |
| 218 | + |
| 219 | +def test_resolve_distance_function_invalid_raises(monkeypatch): |
| 220 | + monkeypatch.setenv("AI_FOUNDRY_EMBEDDING_DISTANCE_FUNCTION", "manhattan") |
| 221 | + with pytest.raises(ConfigurationError): |
| 222 | + _resolve_distance_function(None) |
| 223 | + |
| 224 | + |
| 225 | +def test_resolve_full_text_language_defaults(monkeypatch): |
| 226 | + monkeypatch.delenv("COSMOS_DB_FULL_TEXT_LANGUAGE", raising=False) |
| 227 | + assert _resolve_full_text_language(None) == "en-US" |
| 228 | + |
| 229 | + |
| 230 | +def test_resolve_full_text_language_from_env(monkeypatch): |
| 231 | + monkeypatch.setenv("COSMOS_DB_FULL_TEXT_LANGUAGE", "fr-FR") |
| 232 | + assert _resolve_full_text_language(None) == "fr-FR" |
0 commit comments