(collection_name, transaction_id, vectors)
| 137 | |
| 138 | |
| 139 | def upsert_in_transaction(collection_name, transaction_id, vectors): |
| 140 | url = ( |
| 141 | f"{base_url}/collections/{collection_name}/transactions/{transaction_id}/upsert" |
| 142 | ) |
| 143 | vectors = [ |
| 144 | {"id": str(vector["id"]), "dense_values": vector["values"]} |
| 145 | for vector in vectors |
| 146 | ] |
| 147 | data = {"vectors": vectors} |
| 148 | response = requests.post( |
| 149 | url, headers=generate_headers(), data=json.dumps(data), verify=False |
| 150 | ) |
| 151 | if response.status_code not in [200, 204]: |
| 152 | raise Exception(f"Failed to create vector: {response.status_code}") |
| 153 | |
| 154 | |
| 155 | def commit_transaction(collection_name, transaction_id): |
no test coverage detected