**feat(similarity): add similarity calculation between vectors and text inputs**
- Introduced `calculateSimilarity` method in `types.d.ts` for comparing vectors or textual inputs: - Added support for custom options, including `forceEmbed` and a custom `distanceFunction`. - Enhanced functionality in `embed` to convert text inputs into vector representations. - Added new test cases in `vector-operations.test.ts`: - Validated similarity calculations between identical and different vectors. - Tested similarity scoring for similar and dissimilar text inputs. - Updated `README.md`: - Documented `calculateSimilarity` usage examples, including advanced options. - Clarified the integration of the similarity function into workflows. **Purpose**: Enable calculation of similarity scores for vectors and text inputs to facilitate advanced data comparison and retrieval tasks.
This commit is contained in:
parent
90cbccb1da
commit
d05d381a5d
3 changed files with 77 additions and 0 deletions
8
cli-package/types.d.ts
vendored
8
cli-package/types.d.ts
vendored
|
|
@ -15,6 +15,14 @@ declare module '@soulcraft/brainy' {
|
|||
search(query: string, limit?: number, options?: any): Promise<any[]>
|
||||
|
||||
searchText(query: string, limit?: number, options?: any): Promise<any[]>
|
||||
|
||||
embed(data: string | string[]): Promise<number[]>
|
||||
|
||||
calculateSimilarity(
|
||||
a: number[] | string | string[],
|
||||
b: number[] | string | string[],
|
||||
options?: { forceEmbed?: boolean, distanceFunction?: any }
|
||||
): Promise<number>
|
||||
|
||||
addVerb(
|
||||
sourceId: string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue