GizStack
View .mdOpen in ChatGPTOpen in Claude

gizdb/ml/pgml

The SQL surface of PostgresML 2.10 in GizDB: CREATE EXTENSION pgml, and the native routines that its functions are. The algorithms are the SDK's (gizai/ml); this module only moves values between SQL and them.

gizlang
import * as Pgml from "gizdb/ml/pgml";

Types

ServerPgml

gizlang
type ServerPgml = { models: string; }

A server's PostgresML (Server.Options.pgml, a PgmlLink): each loop makes its own over the models in MODELS (embed.giz modelsFolder) and the model API the environment names.

  • models: string

Functions

pgmlInstall

gizlang
function pgmlInstall(self: mut Conn, e: mut Engine, ifNotExists: bool, backing: mut StatementBacking): bool throws DbError

CREATE EXTENSION pgml: PostgresML's schema, run as SQL, and the extension's catalog entry.

Effects: fail, read, write, console, io, alloc.

pgmlCall

gizlang
function pgmlCall(self: mut Conn, held: Ref<PgmlState>, e: mut Engine, name: string, a: Vec<Value>, backing: mut StatementBacking): Rows throws DbError

The native routine name of language native in schema pgml, called with a: its rows (one row of one value for a scalar function).

Effects: fail, read, write, console, io, alloc.

nativeRow

gizlang
function nativeRow(self: Conn, e: Engine, name: string): string

The routine body of a prediction that a query computes for each row (predict, predict_proba, predict_joint, decompose), or "": Conn.rowCalls reads its models once for the statement.

Effects: fail, read, write, console, io, alloc.

pgml

gizlang
function pgml(models: Option<Models>, api: Option<OpenAi.ModelApi>): Pgml

PostgresML for a Conn (Conn.pgml): its operations over one state, with the models of models and the model API api. A server gives the same one to each of its sessions, so they share the loaded models.

Effects: fail, write, alloc.

Methods

ServerPgml.make

gizlang
function ServerPgml.make(self: ServerPgml): Pgml

The SQL operations of a serving loop, with this server's model folder and the environment's model API.

Effects: fail, read, write, console, io, alloc.