/* The model catalog (catalog.c): Pi's catalog of models for pic's providers, * as Pi keeps it. A snapshot is built in (model_catalog.inc); fresher * per-provider lists from https://pi.dev/api/models/providers/<id> are kept as * rows of picu_catalog in ~/.pic/pic.sqlite and used when newer than the snapshot. Entries * are Pi model objects (JSON: id, name, api, baseUrl, reasoning, * contextWindow, maxTokens, compat). */ #ifndef PIC_CATALOG_H #define PIC_CATALOG_H #include <stddef.h> /* The model object for provider/id (malloc'd JSON), or NULL. */ char *pic_catalog_find(const char *provider, const char *id); /* Calls fn for each model of the catalog, provider by provider; stops when * fn returns non-zero. 0, or -1 when the store could not be read. */ int pic_catalog_each(int (*fn)(void *ctx, const char *provider, const char *json), void *ctx); /* Refreshes the stored lists from pi.dev: each built-in provider not checked * in the last 4 hours (all of them when force), with If-None-Match. Offline * or failing providers keep what is stored. PIC_MODEL_CATALOG=offline turns * fetching off. 0 when every provider was fresh or refreshed; -1 with err * naming the first failure otherwise. */ int pic_catalog_refresh(int force, char *err, size_t errcap); /* Shared by catalog.c and catalog_fetch.c. */ #define PIC_CATALOG_NPROVIDERS 13 extern const char *const pic_catalog_providers[PIC_CATALOG_NPROVIDERS]; #endif