• Format a list of prompt messages

    Parameters

    • format: "MUSTACHE" | "F_STRING" | "NONE"

      The format of the prompt message variables, e.g. MUSTACHE, F_STRING, NONE

    • promptMessages: {
          content:
              | string
              | (
                  | { text: string; type: "text" }
                  | {
                      tool_call: { arguments: string; name: string; type: "function" };
                      tool_call_id: string;
                      type: "tool_call";
                  }
                  | {
                      tool_call_id: string;
                      tool_result: | null
                      | string
                      | number
                      | boolean
                      | Record<string, unknown>
                      | unknown[];
                      type: "tool_result";
                  }
              )[];
          role: | "user"
          | "assistant"
          | "model"
          | "ai"
          | "tool"
          | "system"
          | "developer";
      }[]

      The prompt messages to format

      • content:
            | string
            | (
                | { text: string; type: "text" }
                | {
                    tool_call: { arguments: string; name: string; type: "function" };
                    tool_call_id: string;
                    type: "tool_call";
                }
                | {
                    tool_call_id: string;
                    tool_result: | null
                    | string
                    | number
                    | boolean
                    | Record<string, unknown>
                    | unknown[];
                    type: "tool_result";
                }
            )[]

        Content

      • role: "user" | "assistant" | "model" | "ai" | "tool" | "system" | "developer"

        Role

    • variables: Variables = {}

      The variables to use in the formatting

    Returns {
        content:
            | string
            | (
                | { text: string; type: "text" }
                | {
                    tool_call: { arguments: string; name: string; type: "function" };
                    tool_call_id: string;
                    type: "tool_call";
                }
                | {
                    tool_call_id: string;
                    tool_result: | null
                    | string
                    | number
                    | boolean
                    | Record<string, unknown>
                    | unknown[];
                    type: "tool_result";
                }
            )[];
        role: | "user"
        | "assistant"
        | "model"
        | "ai"
        | "tool"
        | "system"
        | "developer";
    }[]

    The formatted prompt messages

    • content:
          | string
          | (
              | { text: string; type: "text" }
              | {
                  tool_call: { arguments: string; name: string; type: "function" };
                  tool_call_id: string;
                  type: "tool_call";
              }
              | {
                  tool_call_id: string;
                  tool_result: | null
                  | string
                  | number
                  | boolean
                  | Record<string, unknown>
                  | unknown[];
                  type: "tool_result";
              }
          )[]
    • role: "user" | "assistant" | "model" | "ai" | "tool" | "system" | "developer"

      Role