Group Abstract Group Abstract

Message Boards Message Boards

GPT-4: Automated Data Analysis of Uploaded Files

2 Replies

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

POSTED BY: Marco Thiel
POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard