ref: e6f8cc2410632b4c05c9fd438034fafc19b95798
dir: /oai.h/
typedef struct OResult OResult;
typedef struct ORequest ORequest;
typedef struct OPrompt OPrompt;
extern int oaidebug;
struct OPrompt {
char *role;
char *content;
JSON *jcontent;
OPrompt *next;
};
struct ORequest {
char *model;
OPrompt *prompts;
};
struct OResult {
char *role;
char *message;
};
/*
* initoai returns 1 on success. If baseurl or apikey is nil, it'll try to fetch the data
* from the environment variables $oaiurl and $oaikey. Key is optional.
*/
int initoai(char *baseurl, char *apikey);
/*
* makerequest to make the request.
*/
OResult makerequest(ORequest);
/*
* create a new prompt object.
*/
OPrompt* makeprompt(char *role);
/*
* append a prompt to the existing request. You can set the role and the content.
* The content is built from the fmt and the variadic arguments.
*/
int addstrprompt(ORequest*, char *role, char *fmt, ...);
int addprompt(ORequest*, OPrompt*);
/*
* append various contents to prompt.
*/
int addtextmessage(OPrompt*, char *text);
int addfilemessage(OPrompt*, uchar *data, long ndata, char *filename, char *fileid);