quackstack 1.0.10 → 1.0.11
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/commands/search.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { client } from "../lib/database.js";
|
|
3
3
|
import { localEmbeddings } from "../lib/local-embeddings.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getAIClient } from "../lib/ai-provider.js";
|
|
5
5
|
export async function search(query, projectName) {
|
|
6
6
|
const snippets = await client.codeSnippet.findMany({
|
|
7
7
|
where: { projectName },
|
|
@@ -28,6 +28,7 @@ export async function search(query, projectName) {
|
|
|
28
28
|
const context = uniqueResults
|
|
29
29
|
.map((r, i) => `[${i + 1}] ${r.filePath}${r.functionName ? ` (${r.functionName})` : ""}\n${r.content}`)
|
|
30
30
|
.join("\n\n---\n\n");
|
|
31
|
+
const aiClient = getAIClient();
|
|
31
32
|
const answer = await aiClient.generateAnswer(query, context);
|
|
32
33
|
return { answer, sources: uniqueResults };
|
|
33
34
|
}
|
package/dist/lib/ai-provider.js
CHANGED
|
@@ -180,4 +180,10 @@ export class AIClient {
|
|
|
180
180
|
return this.provider;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
let aiClientInstance = null;
|
|
184
|
+
export function getAIClient() {
|
|
185
|
+
if (!aiClientInstance) {
|
|
186
|
+
aiClientInstance = new AIClient();
|
|
187
|
+
}
|
|
188
|
+
return aiClientInstance;
|
|
189
|
+
}
|