Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  test-helpers.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import type { StreamFn } from "@mariozechner/pi-agent-core";
import type { Context, Model } from "@mariozechner/pi-ai";
import { expect } from "vitest";

export type XaiToolPayloadFunction = {
  function?: Record<string, unknown>;
};

export type XaiTestPayload = Record<string, unknown> & {
  tools?: Array<{ type?: string; function?: Record<string, unknown> }>;
  input?: unknown[];
};

export function createXaiToolStreamPayload(): XaiTestPayload {
  return {
    reasoning: { effort: "high" },
    tools: [
      {
        type: "function",
        function: {
          name: "write",
          parameters: { type: "object", properties: {} },
          strict: true,
        },
      },
    ],
  };
}

export function createXaiPayloadCaptureStream() {
  let capturedModelId = "";
  let capturedPayload: XaiTestPayload | undefined;

  const streamFn: StreamFn = (model, _context, options) => {
    capturedModelId = model.id;
    const payload = createXaiToolStreamPayload();
    options?.onPayload?.(payload as never, model as never);
    capturedPayload = payload;
    return {
      result: async () => ({}) as never,
      async *[Symbol.asyncIterator]() {},
    } as unknown as ReturnType<StreamFn>;
  };

  return {
    streamFn,
    getCapturedModelId: () => capturedModelId,
    getCapturedPayload: () => capturedPayload,
  };
}

export function runXaiGrok4ResponseStream(streamFn: StreamFn | null | undefined) {
  void streamFn?.(
    {
      api: "openai-responses",
      provider: "xai",
      id: "grok-4",
    } as Model<"openai-responses">,
    { messages: [] } as Context,
    {},
  );
}

export function expectXaiFastToolStreamShaping(
  capture: ReturnType<typeof createXaiPayloadCaptureStream>,
) {
  const capturedPayload = capture.getCapturedPayload();
  expect(capture.getCapturedModelId()).toBe("grok-4-fast");
  expect(capturedPayload).toMatchObject({ tool_stream: true });
  expect(capturedPayload).not.toHaveProperty("reasoning");
  const payloadTools = capturedPayload?.tools as XaiToolPayloadFunction[] | undefined;
  expect(payloadTools?.[0]?.function).not.toHaveProperty("strict");
}

¤ Dauer der Verarbeitung: 0.24 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge