fix: content 模式默认 file_name 改用 UUID 防并发覆盖
This commit is contained in:
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
"""FastAPI 服务层."""
|
"""FastAPI 服务层."""
|
||||||
import os
|
import os
|
||||||
|
import uuid
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ def ingest_document(
|
|||||||
file_name = path.name
|
file_name = path.name
|
||||||
else:
|
else:
|
||||||
# content 模式 (file_path/content 互斥由 Pydantic 校验保证)
|
# content 模式 (file_path/content 互斥由 Pydantic 校验保证)
|
||||||
file_name = req.file_name or "untitled.md"
|
file_name = req.file_name or f"untitled_{uuid.uuid4().hex[:8]}.md"
|
||||||
count = ingestor.ingest_content(req.content, file_name)
|
count = ingestor.ingest_content(req.content, file_name)
|
||||||
return {"status": "ok", "chunks": count, "file": file_name, "collection": ingestor.collection_name}
|
return {"status": "ok", "chunks": count, "file": file_name, "collection": ingestor.collection_name}
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
|
|||||||
Reference in New Issue
Block a user