mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
Introduce a new manual test file `test/manual/test-spec-retriever.ts` that demonstrates how to use the `spec_retriever` agent tool with a query. The script loads embeddings, connects to the LanceDB storage, creates the tool, executes it, and prints the result. This provides a runnable example for developers.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* Manual test script for spec_retriever agent tool
|
|
* Usage: bun run test/manual/test-spec-retriever.ts "your search query"
|
|
*/
|
|
|
|
import * as lancedbSdk from "@lancedb/lancedb";
|
|
import { OllamaEmbeddings } from "@langchain/ollama";
|
|
import { createSpecRetrieverTool } from "../../agent_tools";
|
|
import { EMBEDDING_MODEL, STORAGE_DIR } from "../../constants";
|
|
|
|
async function main() {
|
|
const query = process.argv[2] || "array.[[DefineOwnProperty]]";
|
|
|
|
console.log(`Testing spec_retriever with query: "${query}"`);
|
|
console.log("Loading database and embeddings...\n");
|
|
|
|
const embeddings = new OllamaEmbeddings({
|
|
model: EMBEDDING_MODEL,
|
|
});
|
|
|
|
const db = await lancedbSdk.connect(STORAGE_DIR);
|
|
const table = await db.openTable("spec_vectors");
|
|
|
|
console.log("Creating tool...\n");
|
|
const specRetrieverTool = createSpecRetrieverTool(table, embeddings);
|
|
|
|
console.log("Executing tool...\n");
|
|
const result = await specRetrieverTool.func({ query });
|
|
|
|
console.log("=== TOOL OUTPUT ===");
|
|
console.log(result);
|
|
console.log("\n=== END OUTPUT ===");
|
|
}
|
|
|
|
main().catch(console.error);
|