MCPcopy Create free account
hub / github.com/cosdata/cosdata / bulk_upsert

Function bulk_upsert

tests/test-key-value-store.py:72–78  ·  view source on GitHub ↗

Upsert multiple key-value pairs in a single request

(name, txn_id, items: list[tuple[str, str]])

Source from the content-addressed store, hash-verified

70 raise Exception(f"Failed to upsert vectors: {response.text}")
71
72def bulk_upsert(name, txn_id, items: list[tuple[str, str]]):
73 """Upsert multiple key-value pairs in a single request"""
74 url = f"{client.base_url}/collections/{name}/transactions/{txn_id}/upsert"
75 data = {"vectors": [{"id": k, "bytes": list(v.encode("utf-8"))} for k, v in items]}
76 response = requests.post(url, headers=client._get_headers(), data=json.dumps(data), verify=client.verify_ssl)
77 if response.status_code not in [200, 204]:
78 raise Exception(f"Failed to bulk upsert: {response.text}")
79
80def lookup(name, key):
81 url = f"{client.base_url}/collections/{name}/search/key-value"

Callers 1

test_bulk_upsertFunction · 0.85

Calls 1

_get_headersMethod · 0.45

Tested by

no test coverage detected