mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 13:31:25 +00:00
fix: telegram draft chunking defaults (#667) (thanks @rubyrunsstuff)
This commit is contained in:
54
src/auto-reply/reply/block-streaming.test.ts
Normal file
54
src/auto-reply/reply/block-streaming.test.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import { resolveTelegramDraftStreamingChunking } from "./block-streaming.js";
|
||||
|
||||
describe("resolveTelegramDraftStreamingChunking", () => {
|
||||
it("uses smaller defaults than block streaming", () => {
|
||||
const chunking = resolveTelegramDraftStreamingChunking(
|
||||
undefined,
|
||||
"default",
|
||||
);
|
||||
expect(chunking).toEqual({
|
||||
minChars: 200,
|
||||
maxChars: 800,
|
||||
breakPreference: "paragraph",
|
||||
});
|
||||
});
|
||||
|
||||
it("clamps to telegram.textChunkLimit", () => {
|
||||
const cfg: ClawdbotConfig = {
|
||||
telegram: { allowFrom: ["*"], textChunkLimit: 150 },
|
||||
};
|
||||
const chunking = resolveTelegramDraftStreamingChunking(cfg, "default");
|
||||
expect(chunking).toEqual({
|
||||
minChars: 150,
|
||||
maxChars: 150,
|
||||
breakPreference: "paragraph",
|
||||
});
|
||||
});
|
||||
|
||||
it("supports per-account overrides", () => {
|
||||
const cfg: ClawdbotConfig = {
|
||||
telegram: {
|
||||
allowFrom: ["*"],
|
||||
accounts: {
|
||||
default: {
|
||||
allowFrom: ["*"],
|
||||
draftChunk: {
|
||||
minChars: 10,
|
||||
maxChars: 20,
|
||||
breakPreference: "sentence",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const chunking = resolveTelegramDraftStreamingChunking(cfg, "default");
|
||||
expect(chunking).toEqual({
|
||||
minChars: 10,
|
||||
maxChars: 20,
|
||||
breakPreference: "sentence",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user