mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(exa): cache disabled content options separately (#103653)
* fix(exa): partition cache by disabled content options * fix(exa): align cache keys with effective contents --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
@@ -453,6 +453,8 @@ function buildExaCacheKey(params: {
|
||||
dateBefore?: string;
|
||||
contents?: ExaContentsArgs;
|
||||
}): string {
|
||||
const contents = params.contents ?? { highlights: true };
|
||||
|
||||
return buildSearchCacheKey([
|
||||
"exa",
|
||||
params.endpoint,
|
||||
@@ -462,9 +464,7 @@ function buildExaCacheKey(params: {
|
||||
params.freshness,
|
||||
params.dateAfter,
|
||||
params.dateBefore,
|
||||
params.contents?.highlights ? JSON.stringify(params.contents.highlights) : undefined,
|
||||
params.contents?.text ? JSON.stringify(params.contents.text) : undefined,
|
||||
params.contents?.summary ? JSON.stringify(params.contents.summary) : undefined,
|
||||
JSON.stringify(contents),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,6 +153,28 @@ describe("exa web search provider", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("partitions Exa cache keys by effective content options", () => {
|
||||
const base = {
|
||||
endpoint: "https://api.exa.ai/search",
|
||||
type: "auto" as const,
|
||||
query: "openclaw",
|
||||
count: 5,
|
||||
};
|
||||
const defaultKey = testing.buildExaCacheKey(base);
|
||||
|
||||
expect(
|
||||
testing.buildExaCacheKey({ ...base, contents: { highlights: true } }),
|
||||
).toBe(defaultKey);
|
||||
|
||||
const disabledKeys = [
|
||||
testing.buildExaCacheKey({ ...base, contents: { highlights: false } }),
|
||||
testing.buildExaCacheKey({ ...base, contents: { text: false } }),
|
||||
testing.buildExaCacheKey({ ...base, contents: { summary: false } }),
|
||||
];
|
||||
expect(disabledKeys).not.toContain(defaultKey);
|
||||
expect(new Set(disabledKeys).size).toBe(disabledKeys.length);
|
||||
});
|
||||
|
||||
it("normalizes Exa result descriptions from highlights before text", () => {
|
||||
expect(
|
||||
testing.resolveExaDescription({
|
||||
|
||||
Reference in New Issue
Block a user