functai for TypeScript - v0.1.0
    Preparing search index...

    Interface AIFunction<I, O, A>

    An AI function: call it with its inputs, get the answer.

    interface AIFunction<I extends Rec = Rec, O extends Rec = Rec, A = unknown> {
        answerName: string;
        definition: Definition;
        instructions: string;
        interface: Interface;
        interfaceId: string;
        module: string;
        name: string;
        saved?: string;
        settings: Settings;
        signature: Signature;
        signatureId: string;
        tools: readonly Tool[];
        version: string;
        get demos(): Demo[];
        set demos(items: (Rec | Demo)[]): void;
        conversation(
            id?: string | null,
            options?: ConversationOptions,
        ): ChatOf<I, O, A>;
        loadState(state: Partial<State>): AIFunction<I, O, A>;
        map(inputs: Iterable<Input<I>>, options?: MapOptions): Promise<A[]>;
        mapSettled(
            inputs: Iterable<Input<I>>,
            options?: MapOptions,
        ): Promise<PromiseSettledResult<A>[]>;
        predict(...args: CallArgs<I>): Promise<Prediction<O, A>>;
        probeRequest(inputs?: Rec): Rec;
        render(...args: CallArgs<I, Settings>): Promise<Request>;
        state(): State;
        stream(...args: CallArgs<I>): PredictionStream<A, Prediction<O, A>>;
        using(settings: Settings): AIFunction<I, O, A>;
        (...args: CallArgs<I>): Promise<A>;
    }

    Type Parameters

    • I extends Rec = Rec
    • O extends Rec = Rec
    • A = unknown
    • Parameters

      • ...args: CallArgs<I>

      Returns Promise<A>

    Index
    answerName: string

    The answer's output name (the last output).

    definition: Definition
    instructions: string

    The instruction the model gets; set it to replace the written one (null: the written one).

    interface: Interface

    What it takes and gives, as data (contract/programs.md): its inputs (optional ones with their default) and outputs.

    interfaceId: string

    The interface's signature: the call log's program.interface. Calls with the same one record the same data.

    module: string
    name: string
    saved?: string

    Set when the function was loaded from a saved folder: sha256: of its functai.json.

    settings: Settings
    signature: Signature

    The lmcc signature the model gets: fields and instructions.

    signatureId: string

    The call log's program.signature: the fields' names and shapes.

    tools: readonly Tool[]
    version: string

    A fingerprint of what the function sends besides its inputs (contract/calls.md, "Versions").

    • get demos(): Demo[]

      The worked examples, as {inputs, outputs} (or recorded turns). Set rows or {inputs, outputs}.

      Returns Demo[]

    • set demos(items: (Rec | Demo)[]): void

      Parameters

      • items: (Rec | Demo)[]

      Returns void

    • A conversation with this function: its calls remember each other, kept in a store (null: this process's memory; a folder; your own). The same id in the same store opens the same conversation. Called like the function: await chat(input) is one turn.

      Parameters

      Returns ChatOf<I, O, A>

    • Each item's answer, in order, concurrency calls at once. Rejects with the first failure, and stops starting new calls.

      Parameters

      Returns Promise<A[]>

    • Each item's outcome, in order, concurrency calls at once, failures included (as Promise.allSettled gives them): a long run goes on past a row that fails. With a reply cache on disk (cacheReplies: "disk"), running it again sends only what has no kept reply.

      Parameters

      Returns Promise<PromiseSettledResult<A>[]>

    • The call, with every output, the turn and the replies.

      Parameters

      • ...args: CallArgs<I>

      Returns Promise<Prediction<O, A>>

    • The request this function sends for its sample input (its version's R).

      Parameters

      • Optionalinputs: Rec

      Returns Rec

    • The exact request a call would send, without sending it (the plugins around it shape it, as they would the call).

      Parameters

      Returns Promise<Request>