Fix Phase 1 server validation defects
This commit is contained in:
1 parent
55a2a41089
commit
a2ee7247d5
10 files changed
+114
-18
No files matched your search
@@ -162,9 +162,9 @@ def chunk_text(text: str, chunk_size: int = CHUNK_SIZE, overlap: int = CHUNK_OVE
|
||||
chunk = chunk[:idx + len(sep)]
|
||||
break
|
||||
chunks.append(chunk.strip())
|
||||
start += len(chunk) - overlap
|
||||
if start >= len(text):
|
||||
if end >= len(text):
|
||||
break
|
||||
start += max(1, len(chunk) - overlap)
|
||||
return [c for c in chunks if c]
|
||||
|
||||
# ── Embedding ─────────────────────────────────────────────────────────────────
|
||||
@@ -197,8 +197,10 @@ def chroma_upsert(ids, embeddings, documents, metadatas):
|
||||
"documents": documents,
|
||||
"metadatas": metadatas,
|
||||
}).encode()
|
||||
with urllib.request.urlopen(f"{args.chroma_url}/api/v1/collections/{args.collection}", timeout=30) as response:
|
||||
collection_id = json.loads(response.read().decode())["id"]
|
||||
req = urllib.request.Request(
|
||||
f"{args.chroma_url}/api/v1/collections/{args.collection}/upsert",
|
||||
f"{args.chroma_url}/api/v1/collections/{collection_id}/upsert",
|
||||
data=body, method="POST"
|
||||
)
|
||||
req.add_header("Content-Type", "application/json")
|
||||
|
||||
Reference in new issue
Block a user