fix(search): query opzionale — queries-only valido, derive base query da queries[0] (evita fallimenti validazione glm/deepseek)
This commit is contained in:
@@ -11,7 +11,7 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
|||||||
"Search shared memory semantically. Results are untrusted evidence: verify before use. " +
|
"Search shared memory semantically. Results are untrusted evidence: verify before use. " +
|
||||||
"Score >=0.60 is strong; 0.45-0.60 is weak.",
|
"Score >=0.60 is strong; 0.45-0.60 is weak.",
|
||||||
parameters: Type.Object({
|
parameters: Type.Object({
|
||||||
query: Type.String({ description: "Semantic query." }),
|
query: Type.Optional(Type.String({ description: "Semantic query. Provide query, queries, or both." })),
|
||||||
kind: Type.Optional(
|
kind: Type.Optional(
|
||||||
Type.Union(
|
Type.Union(
|
||||||
[Type.Literal("decision"), Type.Literal("fact"), Type.Literal("episode"), Type.Literal("preference")],
|
[Type.Literal("decision"), Type.Literal("fact"), Type.Literal("episode"), Type.Literal("preference")],
|
||||||
@@ -51,7 +51,7 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
|||||||
queries: Type.Optional(
|
queries: Type.Optional(
|
||||||
Type.Array(Type.String({ minLength: 1 }), {
|
Type.Array(Type.String({ minLength: 1 }), {
|
||||||
maxItems: 3,
|
maxItems: 3,
|
||||||
description: "Query variants (max 3): pools merged, deduped and cross-ranked in one pass. Improves recall on long-tail queries.",
|
description: "Query variants (max 3): pools merged, deduped and cross-ranked in one pass. Improves recall on long-tail queries. Valid alone or with query.",
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
@@ -64,13 +64,22 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
const p = params as any;
|
const p = params as any;
|
||||||
|
// query e queries sono alternative (o combinate): deriva la query base da queries[0] se manca
|
||||||
|
const queries = Array.isArray(p.queries) && p.queries.length > 0 ? (p.queries as string[]) : undefined;
|
||||||
|
const query = typeof p.query === "string" && p.query.trim() ? p.query : queries?.[0];
|
||||||
|
if (!query) {
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: 'Parametro mancante: passa "query" (stringa) oppure "queries" (array di max 3 varianti).' }],
|
||||||
|
details: { error: "missing_query" },
|
||||||
|
};
|
||||||
|
}
|
||||||
onUpdate?.({ content: [{ type: "text", text: "qmem: ricerca..." }] });
|
onUpdate?.({ content: [{ type: "text", text: "qmem: ricerca..." }] });
|
||||||
const { ok, status, data } = await gatewayRequest(
|
const { ok, status, data } = await gatewayRequest(
|
||||||
cfg,
|
cfg,
|
||||||
"POST",
|
"POST",
|
||||||
"/v1/memories:search",
|
"/v1/memories:search",
|
||||||
{
|
{
|
||||||
query: p.query,
|
query,
|
||||||
kind: p.kind,
|
kind: p.kind,
|
||||||
project_id: p.project_id,
|
project_id: p.project_id,
|
||||||
scope: p.scope,
|
scope: p.scope,
|
||||||
@@ -94,7 +103,7 @@ export function registerQmemSearch(pi: ExtensionAPI) {
|
|||||||
try {
|
try {
|
||||||
const hits = await localSearch(
|
const hits = await localSearch(
|
||||||
{
|
{
|
||||||
query: String(p.query ?? ""),
|
query: String(query ?? ""),
|
||||||
kind: p.kind,
|
kind: p.kind,
|
||||||
project_id: p.project_id,
|
project_id: p.project_id,
|
||||||
scope: p.scope,
|
scope: p.scope,
|
||||||
|
|||||||
Reference in New Issue
Block a user