Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/hap/doc/   (GAP Algebra Version 4.15.1©)  Datei vom 19.6.2025 mit Größe 18 kB image not shown  

Quelle  test-helpers.ts

  Sprache: JAVA
 

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");
}

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.5 Sekunden  (vorverarbeitet am  2026-06-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.