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

Function create_vector_in_transaction

tests/rps-test.py:116–128  ·  view source on GitHub ↗
(collection_name, transaction_id, vector)

Source from the content-addressed store, hash-verified

114
115
116def create_vector_in_transaction(collection_name, transaction_id, vector):
117 url = f"{base_url}/collections/{collection_name}/transactions/{transaction_id}/vectors"
118 data = {"id": vector["id"], "dense_values": vector["values"], "metadata": {}}
119 print(f"Request URL: {url}")
120 print(f"Request Data: {json.dumps(data)}")
121 response = requests.post(
122 url, headers=generate_headers(), data=json.dumps(data), verify=False
123 )
124 print(f"Response Status: {response.status_code}")
125 print(f"Response Text: {response.text}")
126 if response.status_code not in [200, 204]:
127 raise Exception(f"Failed to create vector: {response.status_code}")
128 return response.json() if response.text else None
129
130
131def upsert_in_transaction(collection_name, transaction_id, vectors):

Callers

nothing calls this directly

Calls 1

generate_headersFunction · 0.70

Tested by

no test coverage detected