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

    Class PredictionStream<A, P>

    A stream of an AI function's call: its prediction has every output, the turn and the replies.

    Type Parameters

    • A = unknown
    • P = unknown

    Hierarchy (View Summary)

    Index
    passive: boolean

    Read for its result only: the calls it watches are not streamed from the provider.

    prediction: Promise<P>

    The whole prediction, when it ends.

    result: Promise<A>

    The call's value (the same as calling the program); rejects with its error.

    writer: 1

    The writer whose process gives these events: this one, the first.

    • get callId(): string | null

      The id of the call the stream was opened on (null until it starts).

      Returns string | null

    • get signal(): AbortSignal

      Aborted when the stream is closed.

      Returns AbortSignal

    • get text(): string

      The answer so far: its text since the call's latest request (streaming.md, law 3). Provisional: result has the typed value.

      Returns string

    • get tree(): string | null

      The log's id (its outermost call's), once the call started.

      Returns string | null

    • get waiting(): Approval[]

      The tool calls this stream's call waits for a person to approve (approve rules, a plugin's ask).

      Returns Approval[]

    • The answer's text, piece by piece (a retry's discarded text included: result is the truth).

      Returns AsyncGenerator<string>

    • Say yes to a tool call the call waits for (s.waiting[0], its invocation number, or nothing for the only one): the tool runs and the call goes on.

      Parameters

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

      Returns void

    • Stop the call: no new request starts, and it ends with Cancelled.

      Returns void

    • Say no: the model is told the person did not allow it (and why), and may try something else.

      Parameters

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

      Returns void

    • Every event, in order, as it happens: the call's and those of the calls inside it (a stream opened inside a tree shows the tree's numbers, its first after null). form: "kept" gives what the log may keep; view a view made from the form; after resumes after an event of that form (EventUnknown when the form has none).

      Parameters

      Returns AsyncGenerator<StreamEvent>

    • Attaches callbacks for the resolution and/or rejection of the Promise.

      Type Parameters

      • T1 = A
      • T2 = never

      Parameters

      • Optionalok: ((value: A) => T1 | PromiseLike<T1>) | null
      • Optionalfail: ((reason: unknown) => T2 | PromiseLike<T2>) | null

      Returns Promise<T1 | T2>

      A Promise for the completion of which ever callback is executed.