All ages population.csv (1.76 KB)
DOWLOAD-DESKTOP-NOTEBOOK.nb (317 KB)
GPT-ADA-API.wl (7.1 KB)
6 Likes
– you have earned Featured Contributor Badge ![]()
Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!
3 Likes
Hi everyone,
Note that you are always creating a new assistant if you follow this procedure. Over time you will accumulate assistants. In principle, one could change the functions so that they always take one personal assistant.
Another option is to introduce two more house cleaning functions. The first one lists all assistants and their IDs:
listAssistants[myAPIKey_]:=Module[{apiEndpoint,myRequest,response},(*Construct the API endpoint URL for listing assistants*)apiEndpoint="https://api.openai.com/v1/assistants";
(*Create the HTTP request for listing assistants*)myRequest=HTTPRequest[apiEndpoint,<|"Headers"->{"Authorization"->"Bearer "<>myAPIKey,"Content-Type"->"application/json","OpenAI-Beta"->"assistants=v1"}|>];
(*Execute the request and get the response*)response=URLExecute[myRequest];
Replace[response,l_List:>Association[l],{0,Infinity}]]
and the second one allows you to delete them:
deleteAssistant[myAPIKey_,assistantID_]:=Module[{apiEndpoint,myRequest,response},(*Construct the API endpoint URL for deleting an assistant*)apiEndpoint="https://api.openai.com/v1/assistants/"<>assistantID;
(*Create the HTTP request for deleting an assistant*)myRequest=HTTPRequest[apiEndpoint,<|"Method"->"DELETE","Headers"->{"Authorization"->"Bearer "<>myAPIKey,"Content-Type"->"application/json","OpenAI-Beta"->"assistants=v1"}|>];
(*Execute the request and get the response*)response=URLExecute[myRequest];
Replace[response,l_List:>Association[l],{0,Infinity}]]
Cheers,
Marco
1 Like