Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/extensions/telegram/src/   (Openclaw AI Version 22©)  Datei vom 26.3.2026 mit Größe 1 kB image not shown  

Quelle  auto-topic-label.test.ts

  Sprache: JAVA
 

import { describe, expect, it, vi } from "vitest";

const generateConversationLabel = vi.hoisted(() => vi.fn());

vi.mock("openclaw/plugin-sdk/reply-dispatch-runtime", () => ({
  generateConversationLabel,
}));

import {
  AUTO_TOPIC_LABEL_DEFAULT_PROMPT,
  resolveAutoTopicLabelConfig,
} from "./auto-topic-label-config.js";
import { generateTelegramTopicLabel } from "./auto-topic-label.js";

describe("resolveAutoTopicLabelConfig", () => {
  it("returns enabled with default prompt when configs are undefined", () => {
    const result = resolveAutoTopicLabelConfig(undefined, undefined);
    expect(result).toEqual({ enabled: true, prompt: AUTO_TOPIC_LABEL_DEFAULT_PROMPT });
  });

  it("prefers direct config over account config", () => {
    expect(resolveAutoTopicLabelConfig(falsetrue)).toBeNull();
    expect(
      resolveAutoTopicLabelConfig({ prompt: "DM prompt" }, { prompt: "Account prompt" }),
    ).toEqual({
      enabled: true,
      prompt: "DM prompt",
    });
  });

  it("falls back to default prompt for empty object prompt", () => {
    expect(resolveAutoTopicLabelConfig({ enabled: true, prompt: "  " }, undefined)).toEqual({
      enabled: true,
      prompt: AUTO_TOPIC_LABEL_DEFAULT_PROMPT,
    });
  });
});

describe("generateTelegramTopicLabel", () => {
  it("delegates to the generic conversation label helper with telegram max length", async () => {
    generateConversationLabel.mockResolvedValue("Billing");

    await expect(
      generateTelegramTopicLabel({
        userMessage: "Need help with invoices",
        prompt: "prompt",
        cfg: {},
        agentId: "billing",
      }),
    ).resolves.toBe("Billing");

    expect(generateConversationLabel).toHaveBeenCalledWith({
      userMessage: "Need help with invoices",
      prompt: "prompt",
      cfg: {},
      agentId: "billing",
      maxLength: 128,
    });
  });
});

Messung V0.5 in Prozent
C=94 H=96 G=94

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

*© 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.