@rigstate/mcp 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/tools/query-brain.ts +24 -10
package/dist/index.js
CHANGED
|
@@ -974,19 +974,30 @@ architecture rules, decisions, and constraints.`,
|
|
|
974
974
|
}
|
|
975
975
|
});
|
|
976
976
|
async function generateQueryEmbedding(query) {
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
|
|
977
|
+
const openRouterKey = process.env.OPENROUTER_API_KEY;
|
|
978
|
+
const googleKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY;
|
|
979
|
+
if (!openRouterKey && !googleKey) {
|
|
980
|
+
console.warn("Neither OPENROUTER_API_KEY nor GOOGLE_GENERATIVE_AI_API_KEY found, skipping vector search.");
|
|
980
981
|
return null;
|
|
981
982
|
}
|
|
982
983
|
try {
|
|
983
|
-
const { google } = await import("@ai-sdk/google");
|
|
984
984
|
const { embed } = await import("ai");
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
985
|
+
if (openRouterKey) {
|
|
986
|
+
const { createOpenRouter } = await import("@openrouter/ai-sdk-provider");
|
|
987
|
+
const openrouter = createOpenRouter({ apiKey: openRouterKey });
|
|
988
|
+
const { embedding } = await embed({
|
|
989
|
+
model: openrouter.embedding("google/text-embedding-004"),
|
|
990
|
+
value: query.replace(/\n/g, " ")
|
|
991
|
+
});
|
|
992
|
+
return embedding;
|
|
993
|
+
} else {
|
|
994
|
+
const { google } = await import("@ai-sdk/google");
|
|
995
|
+
const { embedding } = await embed({
|
|
996
|
+
model: google.embedding("text-embedding-004"),
|
|
997
|
+
value: query.replace(/\n/g, " ")
|
|
998
|
+
});
|
|
999
|
+
return embedding;
|
|
1000
|
+
}
|
|
990
1001
|
} catch (error) {
|
|
991
1002
|
console.error("Failed to generate embedding for search:", error);
|
|
992
1003
|
return null;
|