2025-08-26 12:32:21 -07:00
|
|
|
/**
|
2025-09-11 16:23:32 -07:00
|
|
|
* Triple Intelligence Types
|
|
|
|
|
* Defines the query and result types for Triple Intelligence
|
2025-08-26 12:32:21 -07:00
|
|
|
*
|
2025-09-11 16:23:32 -07:00
|
|
|
* The actual implementation is in TripleIntelligenceSystem
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { Vector, SearchResult } from '../coreTypes.js'
|
|
|
|
|
|
|
|
|
|
export interface TripleQuery {
|
|
|
|
|
// Vector/Semantic search
|
|
|
|
|
like?: string | Vector | any
|
|
|
|
|
similar?: string | Vector | any
|
|
|
|
|
|
|
|
|
|
// Graph/Relationship search
|
|
|
|
|
connected?: {
|
|
|
|
|
to?: string | string[]
|
|
|
|
|
from?: string | string[]
|
|
|
|
|
type?: string | string[]
|
|
|
|
|
depth?: number
|
|
|
|
|
maxDepth?: number // Maximum traversal depth
|
|
|
|
|
direction?: 'in' | 'out' | 'both'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Field/Attribute search
|
|
|
|
|
where?: Record<string, any>
|
|
|
|
|
|
|
|
|
|
// Pagination options (NEW for 2.0)
|
|
|
|
|
limit?: number
|
2025-09-11 16:23:32 -07:00
|
|
|
offset?: number
|
2025-08-26 12:32:21 -07:00
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
// Advanced options (NEW for 2.0)
|
|
|
|
|
explain?: boolean // Include explanation of how results were found
|
|
|
|
|
boost?: {
|
|
|
|
|
vector?: number // Weight for vector similarity (default 1.0)
|
|
|
|
|
graph?: number // Weight for graph connections (default 1.0)
|
|
|
|
|
field?: number // Weight for field matches (default 1.0)
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
export interface TripleResult {
|
|
|
|
|
id: string
|
|
|
|
|
score: number
|
|
|
|
|
entity?: any
|
2025-08-26 12:32:21 -07:00
|
|
|
explanation?: {
|
2025-09-11 16:23:32 -07:00
|
|
|
vectorScore?: number
|
|
|
|
|
graphScore?: number
|
|
|
|
|
fieldScore?: number
|
|
|
|
|
path?: string[]
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface QueryPlan {
|
2025-09-11 16:23:32 -07:00
|
|
|
strategy: 'parallel' | 'progressive'
|
|
|
|
|
steps: Array<{
|
|
|
|
|
type: 'vector' | 'graph' | 'field'
|
|
|
|
|
cost: number
|
|
|
|
|
expected: number
|
|
|
|
|
}>
|
2025-08-26 12:32:21 -07:00
|
|
|
canParallelize: boolean
|
|
|
|
|
estimatedCost: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-11 16:23:32 -07:00
|
|
|
* @deprecated Use brain.getTripleIntelligence() directly to get TripleIntelligenceSystem
|
2025-08-26 12:32:21 -07:00
|
|
|
*/
|
2025-09-11 16:23:32 -07:00
|
|
|
export type TripleIntelligenceEngine = any
|