File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/data/data/com.termux/files/usr/bin/env python3
2+ import openai
3+ import os
4+ import sys
5+ from rich import print
6+
7+ print ("[red]This will delete ALL files uploaded to your OpenAI account![/]" )
8+ ans = input ("If you wish to continue, type 'YES':" )
9+ if ans != "YES" :
10+ sys .exit ()
11+
12+ print ("Cleaning up uploaded files..." )
13+
14+ homedir = os .path .expanduser ("~" ) + "/"
15+ os .makedirs (homedir + ".openai" , exist_ok = True )
16+ sys .path .insert (0 , homedir + ".openai" )
17+ from settings import OPENAI_API_KEY
18+
19+ client = openai .OpenAI (api_key = OPENAI_API_KEY )
20+
21+ # List all files
22+ files = client .files .list ()
23+
24+ # Delete each file
25+ for file in files .data :
26+ file_id = file .id
27+ print (f"Deleting file: { file_id } ({ getattr (file , 'filename' , 'no name' )} )" )
28+ client .files .delete (file_id )
29+
30+ print ("All files deleted." )
Original file line number Diff line number Diff line change 1+ #!/data/data/com.termux/files/usr/bin/env python3
2+ from openai import OpenAI
3+ import os
4+ import sys
5+ from rich import print
6+
7+ print ("[red]This will delete ALL Vector Stores![/]" )
8+ ans = input ("If you wish to continue, type 'YES':" )
9+ if ans != "YES" :
10+ sys .exit ()
11+
12+ print ("Nuking Vector Stores..." )
13+
14+ homedir = os .path .expanduser ("~" ) + "/"
15+ os .makedirs (homedir + ".openai" , exist_ok = True )
16+ sys .path .insert (0 , homedir + ".openai" )
17+ from settings import OPENAI_API_KEY
18+
19+ client = OpenAI (api_key = OPENAI_API_KEY )
20+
21+ # Walk through every page of vector stores
22+ for page in client .vector_stores .list (limit = 100 ).iter_pages ():
23+ for vs in page .data :
24+ client .vector_stores .delete (vector_store_id = vs .id )
25+ print (f"✔ Deleted { vs .id } " )
26+
27+ print ("[green]Done.[/]" )
You can’t perform that action at this time.
0 commit comments