sync update from LAN repo (source master-nj @ 067eb808)
This commit is contained in:
1 parent
1244fb1f2f
commit
1d5dd8fc90
182 files changed
+18973
-769
No files matched your search
@@ -8,7 +8,7 @@ import pytest
|
||||
from fastapi import FastAPI, UploadFile
|
||||
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
|
||||
|
||||
from app.gateway.routers import wiki_packages
|
||||
from app.gateway.routers import assistant_knowledge, wiki_packages
|
||||
from deerflow.assistant_knowledge.archive import PackageArchive
|
||||
from deerflow.assistant_knowledge.package_io import write_package
|
||||
from deerflow.config.llmwiki_config import LocalWikiEmbeddingConfig
|
||||
@@ -22,6 +22,26 @@ from deerflow.persistence.base import Base
|
||||
from deerflow.persistence.llmwiki_index.memory import MemoryLlmWikiIndexStore
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_existing_wiki_vectors_can_be_exported_without_runtime_encoder(monkeypatch):
|
||||
request = SimpleNamespace(
|
||||
app=SimpleNamespace(
|
||||
state=SimpleNamespace(llmwiki_sync_service=None),
|
||||
),
|
||||
)
|
||||
|
||||
async def has_vectors(_request, mapping_id):
|
||||
assert mapping_id == "mapping-1"
|
||||
return True
|
||||
|
||||
monkeypatch.setattr(assistant_knowledge, "_has_local_wiki_vectors_for_export", has_vectors)
|
||||
|
||||
await assistant_knowledge._ensure_local_wiki_vectors_for_export(
|
||||
request,
|
||||
{"id": "mapping-1", "weknora_id": "remote-1"},
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_metadata_vectors_and_links_survive_roundtrip_without_encoding(tmp_path, monkeypatch):
|
||||
engine = create_async_engine("sqlite+aiosqlite:///:memory:")
|
||||
@@ -375,8 +395,10 @@ async def test_admin_can_upload_and_activate_offline_encoder(monkeypatch, tmp_pa
|
||||
class Embedding:
|
||||
def __init__(self):
|
||||
self.model_path = ""
|
||||
self.reset_calls = 0
|
||||
|
||||
async def reset_local_encoder(self, *, model_path=None):
|
||||
self.reset_calls += 1
|
||||
if model_path is not None:
|
||||
self.model_path = model_path
|
||||
|
||||
@@ -395,6 +417,17 @@ async def test_admin_can_upload_and_activate_offline_encoder(monkeypatch, tmp_pa
|
||||
monkeypatch.setattr(llmwiki_index, "load_system_settings", SystemSettings)
|
||||
monkeypatch.setattr(llmwiki_index, "save_system_settings", lambda value: saved.append(value) or value)
|
||||
embedding = Embedding()
|
||||
|
||||
async def rebuild(_app, *, force=False):
|
||||
assert force is True
|
||||
embedding.model_path = saved[-1].local_wiki_encoder.model_path
|
||||
|
||||
monkeypatch.setattr(llmwiki_index, "rebuild_local_wiki_index_runtime", rebuild)
|
||||
monkeypatch.setattr(
|
||||
llmwiki_index,
|
||||
"local_encoder_runtime_status",
|
||||
lambda _app: embedding.local_encoder_status(),
|
||||
)
|
||||
app = FastAPI()
|
||||
app.state.config = SimpleNamespace(
|
||||
llmwiki=SimpleNamespace(
|
||||
@@ -414,11 +447,15 @@ async def test_admin_can_upload_and_activate_offline_encoder(monkeypatch, tmp_pa
|
||||
paths=["onnx/model.onnx", "config.json"],
|
||||
)
|
||||
|
||||
active = tmp_path / "models" / "bge-m3"
|
||||
revision = saved[-1].local_wiki_encoder.model_revision
|
||||
active = tmp_path / "models" / "bge-m3-revisions" / revision
|
||||
assert (active / "onnx" / "model.onnx").read_bytes() == b"onnx"
|
||||
assert result["uploaded_files"] == 2
|
||||
assert saved[-1].local_wiki_encoder.model_path == str(active.resolve())
|
||||
assert saved[-1].local_wiki_encoder.mode == "local"
|
||||
assert revision
|
||||
assert embedding.model_path == str(active.resolve())
|
||||
assert embedding.reset_calls == 0
|
||||
|
||||
|
||||
def test_encoder_upload_rejects_parent_traversal():
|
||||
|
||||
Reference in new issue
Block a user