sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
@@ -13,6 +13,38 @@ from deerflow.persistence.assistant_knowledge import AssistantKnowledgeRepositor
|
||||
from deerflow.persistence.base import Base
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_new_base_exposes_an_empty_wiki_directory(monkeypatch):
|
||||
"""A valid assistant base does not need a source before its Wiki route opens."""
|
||||
|
||||
engine = create_async_engine("sqlite+aiosqlite:///:memory:")
|
||||
async with engine.begin() as connection:
|
||||
await connection.run_sync(Base.metadata.create_all)
|
||||
store = AssistantKnowledgeRepository(async_sessionmaker(engine, expire_on_commit=False))
|
||||
base = await store.create_base(created_by="admin", name="尚未上传文件的知识库")
|
||||
|
||||
async def actor(*args, **kwargs):
|
||||
return "admin"
|
||||
|
||||
app = FastAPI()
|
||||
app.include_router(router.router)
|
||||
app.state.assistant_knowledge_store = store
|
||||
monkeypatch.setattr(router, "_actor", actor)
|
||||
try:
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=app),
|
||||
base_url="http://test",
|
||||
) as client:
|
||||
response = await client.get(
|
||||
"/api/assistant-knowledge/wiki-pages",
|
||||
params={"base_id": base["id"], "include_content": "false"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"pages": [], "total": 0, "next_offset": None}
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
def test_same_topic_across_document_parts_preserves_all_knowledge():
|
||||
package = ingest.notes_package([
|
||||
{"title": "设备维护", "content_md": "每周清理过滤网", "tags": ["运维"]},
|
||||
@@ -81,9 +113,13 @@ async def test_standalone_upload_vectors_retry_and_dedup(tmp_path, monkeypatch):
|
||||
assert job["counts"]["vectors"] == 1
|
||||
assert len(extraction_calls) == 1
|
||||
results = await store.search_pages(base_ids=[base["id"]], query="额定转速", embedding_client=app.state.llmwiki_embedding)
|
||||
assert results and results[0]["retrieval_mode"] == "vector"
|
||||
assert "1200" in results[0]["matched_section"]["content"]
|
||||
assert "摘要占位" not in results[0]["matched_section"]["content"]
|
||||
assert results
|
||||
result = results[0]
|
||||
assert result["retrieval_mode"] == "keyword"
|
||||
assert result["retrieval_channels"] == ["vector", "keyword"]
|
||||
assert set(result["channel_scores"]) == {"vector", "keyword"}
|
||||
assert "1200" in result["matched_section"]["content"]
|
||||
assert "摘要占位" not in result["matched_section"]["content"]
|
||||
global_base = await store.get_base()
|
||||
assert len(await store.list_pages(base_id=global_base["id"])) == 1
|
||||
again = await client.post("/api/assistant-knowledge/imports/files", data=payload, files={"file": ("设备.md", "风扇额定转速为 1200 转。".encode())})
|
||||
|
||||
Reference in new issue
Block a user