Neutrome SDK reference
    Preparing search index...

    Class ProgramView

    Decoded, structured read model of a Program.

    A view walks the instruction list once in the constructor and exposes the result as plain arrays, which is cheaper and far more readable than calling several find* and extract* helpers over the same program. Use the free functions for one-off lookups and a view when a consumer needs most of the program at once — every provider emitter in this package is built on one.

    const view = new ProgramView(response);
    for (const message of view.getNonSystemMessages()) {
    console.log(message.role, message.text);
    }
    Index
    errors: ErrorBlock[] = []

    Every error block appended to the program.

    messages: ProgramMessage[] = []

    Every message span, decoded in program order.

    program: Program

    The program this view was built from. Never mutated.

    stops: string[] = []

    Configured stop sequences.

    streamEvents: ProgramStreamEvent[] = []

    Streaming events in arrival order; empty for non-stream programs.

    streaming: boolean

    Whether the program requested streaming.

    tools: ProgramTool[] = []

    Every tool definition declared by the program.

    usage: unknown

    Decoded provider usage payload, or undefined when absent.

    • Reads the first float value carried by opcode.

      Parameters

      • opcode: Opcode

        Opcode to look up.

      Returns number | undefined

      The value, or undefined when the program carries no such instruction.

    • Reads the first integer value carried by opcode.

      Parameters

      • opcode: Opcode

        Opcode to look up.

      Returns number | undefined

      The value, or undefined when the program carries no such instruction.

    • Reads and decodes the first JSON value carried by opcode.

      Parameters

      • opcode: Opcode

        Opcode to look up.

      Returns unknown

      The decoded value, or undefined when the program carries no such instruction.

    • Lists conversational messages, dropping system and developer turns.

      Returns ProgramMessage[]

      Messages in program order.

    • Reads the first string value carried by opcode.

      Parameters

      • opcode: Opcode

        Opcode to look up.

      Returns string | undefined

      The value, or undefined when the program carries no such instruction.

    • Joins the text of every system and developer message with blank lines.

      Returns string

      The combined system prompt, or an empty string when there is none.