Backup automatico script del 2026-09-04 07:00
This commit is contained in:
1 parent
795a15a7b6
commit
aab8502e27
10 files changed
+1001
-5
No files matched your search
@@ -89,14 +89,23 @@ def index_all(max_pages: int = 20) -> dict:
|
||||
return {"indexed": indexed, "errors": errors, "users": users}
|
||||
|
||||
|
||||
def index_context_snippet(username: str, project_id: str, text: str, title: str) -> None:
|
||||
def index_context_snippet(
|
||||
username: str,
|
||||
project_id: str,
|
||||
text: str,
|
||||
title: str,
|
||||
snippet_id: Optional[str] = None,
|
||||
) -> None:
|
||||
chunks = _chunk_text(text)
|
||||
if not chunks:
|
||||
return
|
||||
vectors = embeddings.embed_texts(chunks)
|
||||
collection = qdrant_store.ctx_collection(username)
|
||||
doc_key = f"ctx-{username}-{project_id}"
|
||||
qdrant_store.delete_by_doc(collection, hash(doc_key) % (2**31))
|
||||
if snippet_id:
|
||||
doc_key = f"{doc_key}-{snippet_id}"
|
||||
doc_id = hash(doc_key) % (2**31)
|
||||
qdrant_store.delete_by_doc(collection, doc_id)
|
||||
ids = []
|
||||
payloads = []
|
||||
for i, chunk in enumerate(chunks):
|
||||
@@ -104,13 +113,15 @@ def index_context_snippet(username: str, project_id: str, text: str, title: str)
|
||||
ids.append(point_id)
|
||||
payloads.append(
|
||||
{
|
||||
"doc_id": hash(doc_key) % (2**31),
|
||||
"doc_id": doc_id,
|
||||
"project_id": project_id,
|
||||
"chunk_index": i,
|
||||
"title": title,
|
||||
"text": chunk,
|
||||
"owner": username,
|
||||
"visibility": "personal",
|
||||
"source": "context",
|
||||
"snippet_id": snippet_id or "latest",
|
||||
}
|
||||
)
|
||||
qdrant_store.upsert_chunks(collection, ids, vectors, payloads)
|
||||
|
||||
Reference in new issue
Block a user