From 74e940c45d298849da97d29058934d0b735f6194 Mon Sep 17 00:00:00 2001 From: Enrique Barcelli Date: Sun, 31 Aug 2025 23:47:56 +0800 Subject: [PATCH] Add funcionality to add metadata to vector stores and vectore store files --- modify_vector_store.py | 22 ++++++++++++++++++++++ update_vector_store_file.py | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 modify_vector_store.py create mode 100644 update_vector_store_file.py diff --git a/modify_vector_store.py b/modify_vector_store.py new file mode 100644 index 0000000..28fcce3 --- /dev/null +++ b/modify_vector_store.py @@ -0,0 +1,22 @@ +from config import * +import requests +import json +import sys + +def modify_vector_store(vector_store_id,metadata): + url = base_url+"vector_stores/"+vector_store_id + + payload = json.dumps({ + "metadata": json.loads(metadata) + }) + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer '+secret_key, + } + + response = requests.request("POST", url, headers=headers, data=payload) + + print(response.text) + +if __name__ == '__main__': + modify_vector_store(str(sys.argv[1]),str(sys.argv[2])) diff --git a/update_vector_store_file.py b/update_vector_store_file.py new file mode 100644 index 0000000..18a4e3a --- /dev/null +++ b/update_vector_store_file.py @@ -0,0 +1,22 @@ +from config import * +import requests +import json +import sys + +def update_vector_store_file(vector_store_id,file_id,attributes): + url = base_url+"vector_stores/"+vector_store_id+"/files/"+file_id + + payload = json.dumps({ + "attributes": json.loads(attributes) + }) + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer '+secret_key, + } + + response = requests.request("POST", url, headers=headers, data=payload) + + print(response.text) + +if __name__ == '__main__': + update_vector_store_file(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))