Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import test from "node:test";
import assert from "node:assert/strict";
const { clampEmbeddingStringInput } = await import("../../open-sse/handlers/embeddings.ts");
const LIMIT = 20_000;
test("embeddings: over-limit string input is clamped to 20k chars", () => {
const out = clampEmbeddingStringInput("x".repeat(LIMIT + 500)) as string;
assert.equal(out.length, LIMIT);
});
test("embeddings: under-limit string input passes through untouched", () => {
const text = "hello world";
assert.equal(clampEmbeddingStringInput(text), text);
});
test("embeddings: array items are clamped individually, non-strings untouched", () => {
const out = clampEmbeddingStringInput([
"a".repeat(LIMIT + 1),
"short",
{ type: "image_url", url: "https://example.com/x.png" },
]) as unknown[];
assert.equal((out[0] as string).length, LIMIT);
assert.equal(out[1], "short");
assert.deepEqual(out[2], { type: "image_url", url: "https://example.com/x.png" });
});
test("embeddings: non-string scalar input passes through", () => {
assert.equal(clampEmbeddingStringInput(42), 42);
assert.equal(clampEmbeddingStringInput(null), null);
});