File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ # This script deletes all assistants, files, and vector stores from your OpenAI account.
2
+ # !!! Proceed with caution, as this action is irreversible. !!!
3
+
4
+ import os
5
+ from dotenv import load_dotenv
6
+ load_dotenv ()
7
+
8
+ from openai import OpenAI
9
+ client = OpenAI (api_key = os .environ ["OPENAI_API_KEY" ])
10
+
11
+ # Prompt user to confirm deletion
12
+ confirmation = input ("Are you sure you want to delete all assistants, files, and vector stores? (yes/no) " )
13
+ if confirmation != "yes" :
14
+ print ("Exiting..." )
15
+ exit ()
16
+
17
+ # Delete all assistants
18
+ all_assistants = client .beta .assistants .list (order = "desc" , limit = "100" ,)
19
+ for assistant in all_assistants :
20
+ try :
21
+ response = client .beta .assistants .delete (assistant .id )
22
+ print (response )
23
+ except Exception as e :
24
+ print (e )
25
+
26
+ # Delete all files
27
+ all_files = client .files .list ()
28
+ for file in all_files :
29
+ try :
30
+ response = client .files .delete (file .id )
31
+ print (response )
32
+ except Exception as e :
33
+ print (e )
34
+
35
+ # Delete all vector stores
36
+ all_vector_stores = client .beta .vector_stores .list ()
37
+ for vector_store in all_vector_stores :
38
+ try :
39
+ response = client .beta .vector_stores .delete (vector_store .id )
40
+ print (response )
41
+ except Exception as e :
42
+ print (e )
You can’t perform that action at this time.
0 commit comments