feat: complete public wiki and embedded previews
This commit is contained in:
1 parent
007ed5a7de
commit
1736227723
18 files changed
+926
-48
No files matched your search
@@ -1,8 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from deerflow.config.llmwiki_config import LocalWikiIndexConfig
|
||||
from deerflow.config.llmwiki_config import LocalWikiEmbeddingConfig, LocalWikiIndexConfig
|
||||
from deerflow.integrations.weknora.local_index.embedding import StrictWikiEmbeddingClient
|
||||
from deerflow.integrations.weknora.local_index.sync import WikiSyncService
|
||||
from deerflow.integrations.weknora.local_index.vector_cache import WikiVectorCache
|
||||
from deerflow.persistence.llmwiki_index.memory import MemoryLlmWikiIndexStore
|
||||
@@ -53,6 +57,55 @@ class FakeWeKnora:
|
||||
return dict(self.pages[slug])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_configured_dimensions_are_validated_but_not_sent_to_bge() -> None:
|
||||
requests: list[dict] = []
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
payload = json.loads(request.content)
|
||||
requests.append(payload)
|
||||
if "dimensions" in payload:
|
||||
return httpx.Response(400, json={"detail": "dimensions is not supported"})
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={"data": [{"index": 0, "embedding": [1.0, 0.0, 0.0]}]},
|
||||
)
|
||||
|
||||
config = LocalWikiEmbeddingConfig(
|
||||
model="bge-embedding-m3",
|
||||
base_url="http://embedding.test/v1",
|
||||
dimensions=3,
|
||||
max_retries=0,
|
||||
)
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = StrictWikiEmbeddingClient(config, http_client=http_client)
|
||||
vector = await client.embed_query("Wiki page")
|
||||
|
||||
assert vector == [1.0, 0.0, 0.0]
|
||||
assert requests == [{"model": "bge-embedding-m3", "input": ["Wiki page"]}]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_omitted_dimensions_are_discovered_from_first_response() -> None:
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={"data": [{"index": 0, "embedding": [0.0, 1.0]}]},
|
||||
)
|
||||
|
||||
config = LocalWikiEmbeddingConfig(
|
||||
model="bge-embedding-m3",
|
||||
base_url="http://embedding.test/v1",
|
||||
dimensions=None,
|
||||
max_retries=0,
|
||||
)
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
client = StrictWikiEmbeddingClient(config, http_client=http_client)
|
||||
await client.embed_query("dimension probe")
|
||||
|
||||
assert client.dimensions == 2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sync_is_incremental_and_full_scan_deletes_missing_pages() -> None:
|
||||
config = LocalWikiIndexConfig(chunk_min_chars=10, min_similarity=0)
|
||||
|
||||
Reference in new issue
Block a user