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

Function upsert

tests/test-key-value-store-simple.py:107–124  ·  view source on GitHub ↗
(name, txn_id, key: str, value: str)

Source from the content-addressed store, hash-verified

105 raise Exception(f"Failed to abort transaction: {response.text}")
106
107def upsert(name, txn_id, key: str, value: str):
108 url = f"{client.base_url}/collections/{name}/transactions/{txn_id}/upsert"
109 data = {"vectors": [
110 {
111 "id": key,
112 "bytes": list(value.encode("utf-8"))
113 }
114 ]}
115
116 response = requests.post(
117 url,
118 headers=client._get_headers(),
119 data=json.dumps(data),
120 verify=client.verify_ssl,
121 )
122
123 if response.status_code not in [200, 204]:
124 raise Exception(f"Failed to upsert vectors: {response.text}")
125
126
127def lookup(name, key):

Callers 1

mainFunction · 0.70

Calls 1

_get_headersMethod · 0.45

Tested by

no test coverage detected