mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-20 14:12:59 +03:00
chore(dead-code): remove unused prompt cache control helper (#5466)
This commit is contained in:
@@ -1 +1 @@
|
||||
export { analyzePrefix, shouldInjectCacheControl, generatePromptCacheKey } from "./prefixAnalyzer";
|
||||
export { analyzePrefix, generatePromptCacheKey } from "./prefixAnalyzer";
|
||||
|
||||
@@ -72,10 +72,6 @@ export function analyzePrefix(messages: Message[]): PrefixAnalysis {
|
||||
};
|
||||
}
|
||||
|
||||
export function shouldInjectCacheControl(analysis: PrefixAnalysis, minTokens = 1024): boolean {
|
||||
return analysis.prefixTokens >= minTokens && analysis.confidence >= 0.7;
|
||||
}
|
||||
|
||||
export function generatePromptCacheKey(messages: Message[]): string {
|
||||
const analysis = analyzePrefix(messages);
|
||||
if (analysis.prefixHash) {
|
||||
|
||||
30
tests/unit/prompt-cache-prefix-analyzer.test.ts
Normal file
30
tests/unit/prompt-cache-prefix-analyzer.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { describe, it } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { analyzePrefix, generatePromptCacheKey } from "../../src/lib/promptCache";
|
||||
|
||||
describe("prompt cache prefix analyzer", () => {
|
||||
it("captures stable system prefixes and derives a cache key", () => {
|
||||
const messages = [
|
||||
{ role: "system", content: "You are helpful." },
|
||||
{ role: "user", content: "Hello" },
|
||||
];
|
||||
|
||||
const analysis = analyzePrefix(messages);
|
||||
|
||||
assert.equal(analysis.prefixEndIdx, 0);
|
||||
assert.equal(analysis.prefixType, "system_only");
|
||||
assert.equal(analysis.confidence, 0.9);
|
||||
assert.ok(analysis.prefixTokens > 0);
|
||||
assert.match(generatePromptCacheKey(messages), /^omni-[a-f0-9]{32}$/);
|
||||
});
|
||||
|
||||
it("keeps the legacy empty-content key when there is no prefix", () => {
|
||||
const messages = [{ role: "user", content: "Hello" }];
|
||||
|
||||
const analysis = analyzePrefix(messages);
|
||||
|
||||
assert.equal(analysis.prefixEndIdx, -1);
|
||||
assert.equal(generatePromptCacheKey(messages), "omni-e3b0c44298fc1c149afbf4c8996fb924");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user