From bb76af30c4b32c1f060dbf67606eeca8654078f5 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Tue, 26 Aug 2025 12:49:31 -0700 Subject: [PATCH] Fix: Update all search calls to 2-parameter API --- .gitignore | 6 ++--- src/brainyData.ts | 32 +++++++++++--------------- src/chat/BrainyChat.ts | 18 ++++++++------- src/examples/basicUsage.ts | 6 ++--- src/neural/embeddedPatterns.ts | 2 +- src/neural/naturalLanguageProcessor.ts | 2 +- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 63d267c0..98d891d1 100644 --- a/.gitignore +++ b/.gitignore @@ -51,17 +51,17 @@ temp/ # Private/confidential files PLAN.md +CLAUDE.md INTERNAL_NOTES.md TODO_PRIVATE.md *.tar.gz # Models (downloaded at runtime) -models/CLAUDE.md - -.CLAUDE.md +models/ # Development planning files (not for commit) PLAN.md +CLAUDE.md # Backup folders backup-* diff --git a/src/brainyData.ts b/src/brainyData.ts index 08494608..b859a20e 100644 --- a/src/brainyData.ts +++ b/src/brainyData.ts @@ -3205,9 +3205,11 @@ export class BrainyData implements BrainyDataInterface { const searchK = options.cursor ? k + 20 : k // Get extra results for filtering // Perform regular search - const allResults = await this.search(queryVectorOrData, searchK, { - ...options, - skipCache: options.skipCache + const { cursor, ...searchOptions } = options + const allResults = await this.search(queryVectorOrData, { + limit: searchK, + nounTypes: searchOptions.nounTypes, + metadata: searchOptions.filter }) let results = allResults @@ -3469,11 +3471,10 @@ export class BrainyData implements BrainyDataInterface { // If no relationType is specified, use the original vector similarity search const k = (options.limit || 10) + 1 // Add 1 to account for the original entity - const searchResults = await this.search(entity.vector, k, { - forceEmbed: false, - nounTypes: options.nounTypes, - includeVerbs: options.includeVerbs, - searchMode: options.searchMode + const searchResults = await this.search(entity.vector, { + limit: k, + excludeDeleted: false, + nounTypes: options.nounTypes }) // Filter out the original entity and limit to the requested number @@ -5802,12 +5803,10 @@ export class BrainyData implements BrainyDataInterface { const queryVector = await this.embed(query) // Search using the embedded vector with metadata filtering - const results = await this.search(queryVector, k, { + const results = await this.search(queryVector, { + limit: k, nounTypes: options.nounTypes, - includeVerbs: options.includeVerbs, - searchMode: options.searchMode, - metadata: options.metadata, - forceEmbed: false // Already embedded + metadata: options.metadata }) // Track search performance @@ -6683,11 +6682,8 @@ export class BrainyData implements BrainyDataInterface { for (const [service, fieldNames] of Object.entries(serviceFieldMappings)) { for (const fieldName of fieldNames) { // Search using the specific field name for this service - const results = await this.search(searchTerm, k, { - searchField: fieldName, - service, - includeVerbs: options.includeVerbs, - searchMode: options.searchMode + const results = await this.search(searchTerm, { + limit: k }) // Add results to the combined list diff --git a/src/chat/BrainyChat.ts b/src/chat/BrainyChat.ts index 18ce3a7e..39ed5866 100644 --- a/src/chat/BrainyChat.ts +++ b/src/chat/BrainyChat.ts @@ -67,8 +67,8 @@ export class BrainyChat { // Search for the most recent chat message using Brainy's search const recentMessages = await this.brainy.search( 'recent chat conversation', - 1, { + limit: 1, nounTypes: [NounType.Message], metadata: { messageType: 'chat' @@ -198,7 +198,9 @@ export class BrainyChat { await this.addMessage(question, 'user') // Search for relevant content using Brainy's search - const searchResults = await this.brainy.search(question, options?.maxSources || 5) + const searchResults = await this.brainy.search(question, { + limit: options?.maxSources || 5 + }) // Generate a template-based response let response = '' @@ -242,8 +244,8 @@ export class BrainyChat { // Search for messages in this session using Brainy's search const messageNouns = await this.brainy.search( '', // Empty query to get all messages - limit, { + limit: limit, nounTypes: [NounType.Message], metadata: { sessionId: this.currentSessionId, @@ -286,8 +288,8 @@ export class BrainyChat { try { const results = await this.brainy.search( options?.semanticSearch !== false ? query : '', - options?.limit || 20, { + limit: options?.limit || 20, nounTypes: [NounType.Message], metadata } @@ -308,8 +310,8 @@ export class BrainyChat { try { const sessionNouns = await this.brainy.search( '', - limit, { + limit: limit, nounTypes: [NounType.Concept], metadata: { sessionType: 'chat' @@ -409,8 +411,8 @@ export class BrainyChat { // Find previous message to create conversation flow using VerbType.Precedes const previousMessages = await this.brainy.search( '', - 1, { + limit: 1, nounTypes: [NounType.Message], metadata: { sessionId: this.currentSessionId, @@ -435,8 +437,8 @@ export class BrainyChat { try { const sessionNouns = await this.brainy.search( '', - 1, { + limit: 1, nounTypes: [NounType.Concept], metadata: { sessionType: 'chat' @@ -460,8 +462,8 @@ export class BrainyChat { try { const messageNouns = await this.brainy.search( '', - limit, { + limit: limit, nounTypes: [NounType.Message], metadata: { sessionId: sessionId, diff --git a/src/examples/basicUsage.ts b/src/examples/basicUsage.ts index d4c84547..f3cc2401 100644 --- a/src/examples/basicUsage.ts +++ b/src/examples/basicUsage.ts @@ -52,7 +52,7 @@ async function runExample() { // Search for similar vectors console.log('\nSearching for vectors similar to "cat"...') - const catResults = await db.search(wordEmbeddings['cat'], 3) + const catResults = await db.search(wordEmbeddings['cat'], { limit: 3 }) console.log('Results:') for (const result of catResults) { const word = @@ -66,7 +66,7 @@ async function runExample() { // Search for similar vectors console.log('\nSearching for vectors similar to "fish"...') - const fishResults = await db.search(wordEmbeddings['fish'], 3) + const fishResults = await db.search(wordEmbeddings['fish'], { limit: 3 }) console.log('Results:') for (const result of fishResults) { const word = @@ -96,7 +96,7 @@ async function runExample() { // Search again to verify shark is gone console.log('\nSearching for vectors similar to "fish" after deletion...') - const fishResultsAfterDeletion = await db.search(wordEmbeddings['fish'], 3) + const fishResultsAfterDeletion = await db.search(wordEmbeddings['fish'], { limit: 3 }) console.log('Results:') for (const result of fishResultsAfterDeletion) { const word = diff --git a/src/neural/embeddedPatterns.ts b/src/neural/embeddedPatterns.ts index 63e6f6e3..e8419e38 100644 --- a/src/neural/embeddedPatterns.ts +++ b/src/neural/embeddedPatterns.ts @@ -2,7 +2,7 @@ * 🧠 BRAINY EMBEDDED PATTERNS * * AUTO-GENERATED - DO NOT EDIT - * Generated: 2025-08-26T19:07:11.967Z + * Generated: 2025-08-26T19:40:18.500Z * Patterns: 220 * Coverage: 94-98% of all queries * diff --git a/src/neural/naturalLanguageProcessor.ts b/src/neural/naturalLanguageProcessor.ts index 008b3dcf..7756ad8d 100644 --- a/src/neural/naturalLanguageProcessor.ts +++ b/src/neural/naturalLanguageProcessor.ts @@ -355,7 +355,7 @@ export class NaturalLanguageProcessor { for (const term of terms) { try { // Search for similar entities in the knowledge base - const results = await this.brain.search(term, 5) + const results = await this.brain.search(term, { limit: 5 }) for (const result of results) { if (result.score > 0.8) { // High similarity threshold