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

    Class Turn

    One turn of a conversation, as its records said when it was read: id (also call: the id of its call in the call log), parent, inputs, outputs, result (the answer), state (running, waiting, interrupted, done, failed, stopped, abandoned), model, error, waiting (the approvals it waits for), unfinished (tools that may have run when it stopped), usage. refresh() reads it again.

    Index
    • get conversation(): string

      The id of the conversation it belongs to.

      Returns string

    • get error(): Rec | null

      How a failed turn failed ({ type, code, message }); null otherwise.

      Returns Rec | null

    • get id(): string

      The turn's id, which is also the id of its call in the call log (call).

      Returns string

    • get madeBy(): Rec | null

      A merge: the program that made it (its rating goes there).

      Returns Rec | null

    • get model(): string | null

      The model that answered (or, before the end, the one it was asked to use).

      Returns string | null

    • get outputs(): Rec

      Every output by name (result, reasoning, …), once it is done; {} before.

      Returns Rec

    • get parent(): string | null

      The id of the turn it continues (null for a conversation's first turn).

      Returns string | null

    • get requestId(): string | null

      The requestId it was sent with: the same id sent again is this turn, not a new one.

      Returns string | null

    • get result(): unknown

      The answer (as the program's code returned it); null until done.

      Returns unknown

    • get state(): string

      Where it is: running, waiting (for a person's answer), interrupted (its process stopped), done, failed, stopped, abandoned.

      Returns string

    • get unfinished(): Rec[]

      Tools that started and have no result: the process stopped while they ran, so they may have run. Before the turn goes on, say what each returned (resume({ results: { [invocation]: output } })) or run it again (resume({ rerun: [invocation] })): a tool is never run again on its own.

      Returns Rec[]

    • get usage(): Record<string, number>

      Tokens, summed over every model call inside it.

      Returns Record<string, number>

    • End a turn that waits or was interrupted, without going on: abandoned.

      Returns Promise<void>

    • Say yes to an approval it waits for (turn.waiting[0], its invocation number, or nothing for the only one). When nothing else waits, the turn goes on here (resume: false: later, turn.resume()); resolves to its answer.

      Parameters

      • Optionalapproval: number | Approval | null
      • opts: { by?: string | null; resume?: boolean } = {}

      Returns Promise<unknown>

    • The calls inside it, as its kept log says: { call, parent, function, invocation, ended } each, in the order they started.

      Returns Promise<Rec[]>

    • Say no: the model is told the person did not allow it (and why).

      Parameters

      • Optionalapproval: number | Approval | null
      • Optionalreason: string | null
      • opts: { by?: string | null; resume?: boolean } = {}

      Returns Promise<unknown>

    • Its events from its store (the kept form, or a view made from it: view: "outside"), after the event named by after: those kept so far, then each as it is kept, until its last. What another process, a page after a reload, reads.

      Parameters

      • opts: {
            after?: Position | null;
            signal?: AbortSignal;
            timeout?: number;
            view?: "kept" | "outside";
        } = {}

      Returns AsyncGenerator<Rec>

    • The ids of the calls of program inside it (to rate one: rate((await turn.find(fn))[0], "right")).

      Parameters

      • program: string | { name: string }

      Returns Promise<string[]>

    • Go on with a turn that waits (every approval answered) or was interrupted (its process stopped), in this process: its program runs again with the same inputs and earlier turns, each model reply and each tool result it kept are reused, and it goes on from where it stopped. Resolves to its answer (or rejects with Waiting again).

      Parameters

      • opts: {
            rerun?: readonly (string | number)[];
            results?: Readonly<Record<string | number, unknown>>;
        } = {}

      Returns Promise<unknown>

    • Stop it wherever it runs: it ends stopped within a second.

      Returns Promise<void>

    • The calls inside it, as an indented tree.

      Returns Promise<string>

    • Wait until it is no longer running; resolves to it as it is then.

      Parameters

      • opts: { timeout?: number } = {}

      Returns Promise<Turn>