Fix: Update all search calls to 2-parameter API
This commit is contained in:
parent
292a9f9c42
commit
bb76af30c4
6 changed files with 32 additions and 34 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -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-*
|
||||
|
|
|
|||
|
|
@ -3205,9 +3205,11 @@ export class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|||
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<T = any> implements BrainyDataInterface<T> {
|
|||
|
||||
// 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<T = any> implements BrainyDataInterface<T> {
|
|||
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<T = any> implements BrainyDataInterface<T> {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue