@laskarks/mcp-rag-node 1.0.5 → 1.0.6
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/package.json +1 -1
- package/src/ai.ts +8 -1
- package/src/index.ts +1 -5
package/package.json
CHANGED
package/src/ai.ts
CHANGED
|
@@ -142,7 +142,14 @@ class AI {
|
|
|
142
142
|
topK: 3,
|
|
143
143
|
includeMetadata: true,
|
|
144
144
|
});
|
|
145
|
-
|
|
145
|
+
|
|
146
|
+
// Get text from metadata
|
|
147
|
+
const relevantChunks = results.matches.map((match) => ({
|
|
148
|
+
text: match.metadata?.text as string,
|
|
149
|
+
score: match.score,
|
|
150
|
+
}));
|
|
151
|
+
const context = relevantChunks.map((c) => c.text).join("\n\n");
|
|
152
|
+
return context;
|
|
146
153
|
} else {
|
|
147
154
|
return response?.data[0] || "Unexpected error";
|
|
148
155
|
}
|
package/src/index.ts
CHANGED
|
@@ -77,12 +77,8 @@ async function main() {
|
|
|
77
77
|
},
|
|
78
78
|
async ({ keyword }: { keyword: string }) => {
|
|
79
79
|
const response = await CallAI.search_documents(keyword);
|
|
80
|
-
const text =
|
|
81
|
-
typeof response === "object" && response !== null
|
|
82
|
-
? JSON.stringify(response, null, 2)
|
|
83
|
-
: String(response);
|
|
84
80
|
return {
|
|
85
|
-
content: [{ type: "text", text }],
|
|
81
|
+
content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
|
|
86
82
|
};
|
|
87
83
|
},
|
|
88
84
|
);
|