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


Quelle  test-helpers.agent-results.ts

  Sprache: JAVA
 

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

type AgentDeltaEvent = {
  runId: string;
  stream: "assistant";
  data: { delta: string };
};

function extractCliStreamJsonText(text: string): string | null {
  const lines = text
    .split(/\r?\n/)
    .map((line) => line.trim())
    .filter((line) => line.length > 0);
  if (lines.length === 0) {
    return null;
  }

  let assistantText: string | null = null;
  let resultText: string | null = null;

  for (const line of lines) {
    let parsed: unknown;
    try {
      parsed = JSON.parse(line);
    } catch {
      continue;
    }
    if (!parsed || typeof parsed !== "object") {
      continue;
    }
    const record = parsed as Record<string, unknown>;
    if (record.type === "assistant") {
      const message =
        record.message && typeof record.message === "object"
          ? (record.message as Record<string, unknown>)
          : null;
      const content = Array.isArray(message?.content) ? message.content : [];
      const textParts = content
        .map((entry) =>
          entry && typeof entry === "object" ? (entry as Record<string, unknown>).text : undefined,
        )
        .filter((entry): entry is string => typeof entry === "string" && entry.trim().length > 0);
      if (textParts.length > 0) {
        assistantText = textParts.join("\n").trim();
      }
      continue;
    }
    if (record.type === "result" && typeof record.result === "string" && record.result.trim()) {
      resultText = record.result.trim();
    }
  }

  return resultText ?? assistantText;
}

export function extractPayloadText(result: unknown): string {
  const record = result as Record<string, unknown>;
  const payloads = Array.isArray(record.payloads) ? record.payloads : [];
  const texts = payloads
    .map((p) => (p && typeof p === "object" ? (p as Record<string, unknown>).text : undefined))
    .filter((t): t is string => typeof t === "string" && t.trim().length > 0);
  const joined = texts.join("\n").trim();
  if (!joined) {
    return joined;
  }
  return extractCliStreamJsonText(joined) ?? joined;
}

export function buildAssistantDeltaResult(params: {
  opts: unknown;
  emit: (event: AgentDeltaEvent) => void;
  deltas: string[];
  text: string;
}): { payloads: Array<{ text: string }> } {
  const runId = (params.opts as { runId?: string } | undefined)?.runId ?? "";
  for (const delta of params.deltas) {
    params.emit({ runId, stream: "assistant", data: { delta } });
  }
  return { payloads: [{ text: params.text }] };
}

¤ Dauer der Verarbeitung: 0.19 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