mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-03 19:19:08 -04:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ca75c81bc0 | |||
| 691c5bcaf1 | |||
| 9ab998c5d5 |
@@ -0,0 +1,46 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ""
|
||||
labels: bug
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Code to reproduce the behavior:
|
||||
|
||||
```ts
|
||||
// paste the code here
|
||||
```
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
|
||||
- OS: [e.g. macOS, Linux]
|
||||
- JS Runtime / Framework / Bundler (select all applicable)
|
||||
- [ ] Node.js
|
||||
- [ ] Deno
|
||||
- [ ] Bun
|
||||
- [ ] Next.js
|
||||
- [ ] ESBuild
|
||||
- [ ] Rollup
|
||||
- [ ] Webpack
|
||||
- [ ] Turbopack
|
||||
- [ ] Vite
|
||||
- [ ] Waku
|
||||
- [ ] Edge Runtime
|
||||
- [ ] AWS Lambda
|
||||
- [ ] Cloudflare Worker
|
||||
- [ ] Others (please elaborate on this)
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -1,5 +1,12 @@
|
||||
# docs
|
||||
|
||||
## 0.0.101
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.0.100
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docs",
|
||||
"version": "0.0.100",
|
||||
"version": "0.0.101",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"docusaurus": "docusaurus",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/autotool
|
||||
|
||||
## 4.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 4.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/autotool-01-node-example
|
||||
|
||||
## 0.0.41
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
- @llamaindex/autotool@4.0.9
|
||||
|
||||
## 0.0.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
"scripts": {
|
||||
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
|
||||
},
|
||||
"version": "0.0.40"
|
||||
"version": "0.0.41"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/autotool-02-next-example
|
||||
|
||||
## 0.1.85
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
- @llamaindex/autotool@4.0.9
|
||||
|
||||
## 0.1.84
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/autotool-02-next-example",
|
||||
"private": true,
|
||||
"version": "0.1.84",
|
||||
"version": "0.1.85",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/autotool",
|
||||
"type": "module",
|
||||
"version": "4.0.8",
|
||||
"version": "4.0.9",
|
||||
"description": "auto transpile your JS function to LLM Agent compatible",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/cloud
|
||||
|
||||
## 1.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 1.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/cloud",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/community
|
||||
|
||||
## 0.0.55
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 0.0.54
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/community",
|
||||
"description": "Community package for LlamaIndexTS",
|
||||
"version": "0.0.54",
|
||||
"version": "0.0.55",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/core
|
||||
|
||||
## 0.3.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 691c5bc: fix: export embeddings utils
|
||||
|
||||
## 0.3.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/core",
|
||||
"type": "module",
|
||||
"version": "0.3.5",
|
||||
"version": "0.3.6",
|
||||
"description": "LlamaIndex Core Module",
|
||||
"exports": {
|
||||
"./agent": {
|
||||
|
||||
@@ -2,4 +2,10 @@ export { BaseEmbedding, batchEmbeddings } from "./base";
|
||||
export type { BaseEmbeddingOptions, EmbeddingInfo } from "./base";
|
||||
export { MultiModalEmbedding } from "./muti-model";
|
||||
export { truncateMaxTokens } from "./tokenizer";
|
||||
export { DEFAULT_SIMILARITY_TOP_K, SimilarityType, similarity } from "./utils";
|
||||
export {
|
||||
DEFAULT_SIMILARITY_TOP_K,
|
||||
SimilarityType,
|
||||
getTopKEmbeddings,
|
||||
getTopKMMREmbeddings,
|
||||
similarity,
|
||||
} from "./utils";
|
||||
|
||||
@@ -62,3 +62,121 @@ export function similarity(
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top K embeddings from a list of embeddings ordered by similarity to the query.
|
||||
* @param queryEmbedding
|
||||
* @param embeddings list of embeddings to consider
|
||||
* @param similarityTopK max number of embeddings to return, default 2
|
||||
* @param embeddingIds ids of embeddings in the embeddings list
|
||||
* @param similarityCutoff minimum similarity score
|
||||
* @returns
|
||||
*/
|
||||
// eslint-disable-next-line max-params
|
||||
export function getTopKEmbeddings(
|
||||
queryEmbedding: number[],
|
||||
embeddings: number[][],
|
||||
similarityTopK: number = 2,
|
||||
embeddingIds: any[] | null = null,
|
||||
similarityCutoff: number | null = null,
|
||||
): [number[], any[]] {
|
||||
if (embeddingIds == null) {
|
||||
embeddingIds = Array(embeddings.length).map((_, i) => i);
|
||||
}
|
||||
|
||||
if (embeddingIds.length !== embeddings.length) {
|
||||
throw new Error(
|
||||
"getTopKEmbeddings: embeddings and embeddingIds length mismatch",
|
||||
);
|
||||
}
|
||||
|
||||
const similarities: { similarity: number; id: number }[] = [];
|
||||
|
||||
for (let i = 0; i < embeddings.length; i++) {
|
||||
const sim = similarity(queryEmbedding, embeddings[i]!);
|
||||
if (similarityCutoff == null || sim > similarityCutoff) {
|
||||
similarities.push({ similarity: sim, id: embeddingIds[i] });
|
||||
}
|
||||
}
|
||||
|
||||
similarities.sort((a, b) => b.similarity - a.similarity); // Reverse sort
|
||||
|
||||
const resultSimilarities: number[] = [];
|
||||
const resultIds: any[] = [];
|
||||
|
||||
for (let i = 0; i < similarityTopK; i++) {
|
||||
if (i >= similarities.length) {
|
||||
break;
|
||||
}
|
||||
resultSimilarities.push(similarities[i]!.similarity);
|
||||
resultIds.push(similarities[i]!.id);
|
||||
}
|
||||
|
||||
return [resultSimilarities, resultIds];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
export function getTopKMMREmbeddings(
|
||||
queryEmbedding: number[],
|
||||
embeddings: number[][],
|
||||
similarityFn: ((...args: any[]) => number) | null = null,
|
||||
similarityTopK: number | null = null,
|
||||
embeddingIds: any[] | null = null,
|
||||
_similarityCutoff: number | null = null,
|
||||
mmrThreshold: number | null = null,
|
||||
): [number[], any[]] {
|
||||
const threshold = mmrThreshold || 0.5;
|
||||
similarityFn = similarityFn || similarity;
|
||||
|
||||
if (embeddingIds === null || embeddingIds.length === 0) {
|
||||
embeddingIds = Array.from({ length: embeddings.length }, (_, i) => i);
|
||||
}
|
||||
const fullEmbedMap = new Map(embeddingIds.map((value, i) => [value, i]));
|
||||
const embedMap = new Map(fullEmbedMap);
|
||||
const embedSimilarity: Map<any, number> = new Map();
|
||||
let score: number = Number.NEGATIVE_INFINITY;
|
||||
let highScoreId: any | null = null;
|
||||
|
||||
for (let i = 0; i < embeddings.length; i++) {
|
||||
const emb = embeddings[i];
|
||||
const similarity = similarityFn(queryEmbedding, emb);
|
||||
embedSimilarity.set(embeddingIds[i], similarity);
|
||||
if (similarity * threshold > score) {
|
||||
highScoreId = embeddingIds[i];
|
||||
score = similarity * threshold;
|
||||
}
|
||||
}
|
||||
|
||||
const results: [number, any][] = [];
|
||||
|
||||
const embeddingLength = embeddings.length;
|
||||
const similarityTopKCount = similarityTopK || embeddingLength;
|
||||
|
||||
while (results.length < Math.min(similarityTopKCount, embeddingLength)) {
|
||||
results.push([score, highScoreId]);
|
||||
embedMap.delete(highScoreId);
|
||||
const recentEmbeddingId = highScoreId;
|
||||
score = Number.NEGATIVE_INFINITY;
|
||||
for (const embedId of Array.from(embedMap.keys())) {
|
||||
const overlapWithRecent = similarityFn(
|
||||
embeddings[embedMap.get(embedId)!],
|
||||
embeddings[fullEmbedMap.get(recentEmbeddingId)!],
|
||||
);
|
||||
if (
|
||||
threshold * embedSimilarity.get(embedId)! -
|
||||
(1 - threshold) * overlapWithRecent >
|
||||
score
|
||||
) {
|
||||
score =
|
||||
threshold * embedSimilarity.get(embedId)! -
|
||||
(1 - threshold) * overlapWithRecent;
|
||||
highScoreId = embedId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const resultSimilarities = results.map(([s, _]) => s);
|
||||
const resultIds = results.map(([_, n]) => n);
|
||||
|
||||
return [resultSimilarities, resultIds];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/experimental
|
||||
|
||||
## 0.0.110
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.0.109
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/experimental",
|
||||
"description": "Experimental package for LlamaIndexTS",
|
||||
"version": "0.0.109",
|
||||
"version": "0.0.110",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# llamaindex
|
||||
|
||||
## 0.7.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 691c5bc: fix: export embeddings utils
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
- @llamaindex/cloud@1.0.7
|
||||
- @llamaindex/anthropic@0.0.7
|
||||
- @llamaindex/clip@0.0.7
|
||||
- @llamaindex/deepinfra@0.0.7
|
||||
- @llamaindex/huggingface@0.0.7
|
||||
- @llamaindex/ollama@0.0.14
|
||||
- @llamaindex/openai@0.1.23
|
||||
- @llamaindex/portkey-ai@0.0.7
|
||||
- @llamaindex/replicate@0.0.7
|
||||
- @llamaindex/groq@0.0.22
|
||||
|
||||
## 0.7.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/cloudflare-worker-agent-test
|
||||
|
||||
## 0.0.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.0.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/cloudflare-worker-agent-test",
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.94",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/llama-parse-browser-test
|
||||
|
||||
## 0.0.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @llamaindex/cloud@1.0.7
|
||||
|
||||
## 0.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/llama-parse-browser-test",
|
||||
"private": true,
|
||||
"version": "0.0.17",
|
||||
"version": "0.0.18",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/next-agent-test
|
||||
|
||||
## 0.1.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.1.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-agent-test",
|
||||
"version": "0.1.93",
|
||||
"version": "0.1.94",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# test-edge-runtime
|
||||
|
||||
## 0.1.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.1.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/nextjs-edge-runtime-test",
|
||||
"version": "0.1.92",
|
||||
"version": "0.1.93",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/next-node-runtime
|
||||
|
||||
## 0.0.75
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.0.74
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-node-runtime-test",
|
||||
"version": "0.0.74",
|
||||
"version": "0.0.75",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/waku-query-engine-test
|
||||
|
||||
## 0.0.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- llamaindex@0.7.9
|
||||
|
||||
## 0.0.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/waku-query-engine-test",
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.94",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "llamaindex",
|
||||
"version": "0.7.8",
|
||||
"version": "0.7.9",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
@@ -40,7 +40,7 @@
|
||||
"@llamaindex/ollama": "workspace:*",
|
||||
"@llamaindex/openai": "workspace:*",
|
||||
"@llamaindex/portkey-ai": "workspace:*",
|
||||
"@llamaindex/replicate": "workspace:^0.0.6",
|
||||
"@llamaindex/replicate": "workspace:^0.0.7",
|
||||
"@mistralai/mistralai": "^1.0.4",
|
||||
"@mixedbread-ai/sdk": "^2.2.11",
|
||||
"@pinecone-database/pinecone": "^3.0.2",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { similarity } from "@llamaindex/core/embeddings";
|
||||
import type { ImageType } from "@llamaindex/core/schema";
|
||||
import { fs } from "@llamaindex/env";
|
||||
import { filetypemime } from "magic-bytes.js";
|
||||
@@ -17,124 +16,6 @@ export const isIterable = (obj: unknown): obj is Iterable<unknown> => {
|
||||
return obj != null && typeof obj === "object" && Symbol.iterator in obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the top K embeddings from a list of embeddings ordered by similarity to the query.
|
||||
* @param queryEmbedding
|
||||
* @param embeddings list of embeddings to consider
|
||||
* @param similarityTopK max number of embeddings to return, default 2
|
||||
* @param embeddingIds ids of embeddings in the embeddings list
|
||||
* @param similarityCutoff minimum similarity score
|
||||
* @returns
|
||||
*/
|
||||
// eslint-disable-next-line max-params
|
||||
export function getTopKEmbeddings(
|
||||
queryEmbedding: number[],
|
||||
embeddings: number[][],
|
||||
similarityTopK: number = 2,
|
||||
embeddingIds: any[] | null = null,
|
||||
similarityCutoff: number | null = null,
|
||||
): [number[], any[]] {
|
||||
if (embeddingIds == null) {
|
||||
embeddingIds = Array(embeddings.length).map((_, i) => i);
|
||||
}
|
||||
|
||||
if (embeddingIds.length !== embeddings.length) {
|
||||
throw new Error(
|
||||
"getTopKEmbeddings: embeddings and embeddingIds length mismatch",
|
||||
);
|
||||
}
|
||||
|
||||
const similarities: { similarity: number; id: number }[] = [];
|
||||
|
||||
for (let i = 0; i < embeddings.length; i++) {
|
||||
const sim = similarity(queryEmbedding, embeddings[i]!);
|
||||
if (similarityCutoff == null || sim > similarityCutoff) {
|
||||
similarities.push({ similarity: sim, id: embeddingIds[i] });
|
||||
}
|
||||
}
|
||||
|
||||
similarities.sort((a, b) => b.similarity - a.similarity); // Reverse sort
|
||||
|
||||
const resultSimilarities: number[] = [];
|
||||
const resultIds: any[] = [];
|
||||
|
||||
for (let i = 0; i < similarityTopK; i++) {
|
||||
if (i >= similarities.length) {
|
||||
break;
|
||||
}
|
||||
resultSimilarities.push(similarities[i]!.similarity);
|
||||
resultIds.push(similarities[i]!.id);
|
||||
}
|
||||
|
||||
return [resultSimilarities, resultIds];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
export function getTopKMMREmbeddings(
|
||||
queryEmbedding: number[],
|
||||
embeddings: number[][],
|
||||
similarityFn: ((...args: any[]) => number) | null = null,
|
||||
similarityTopK: number | null = null,
|
||||
embeddingIds: any[] | null = null,
|
||||
_similarityCutoff: number | null = null,
|
||||
mmrThreshold: number | null = null,
|
||||
): [number[], any[]] {
|
||||
const threshold = mmrThreshold || 0.5;
|
||||
similarityFn = similarityFn || similarity;
|
||||
|
||||
if (embeddingIds === null || embeddingIds.length === 0) {
|
||||
embeddingIds = Array.from({ length: embeddings.length }, (_, i) => i);
|
||||
}
|
||||
const fullEmbedMap = new Map(embeddingIds.map((value, i) => [value, i]));
|
||||
const embedMap = new Map(fullEmbedMap);
|
||||
const embedSimilarity: Map<any, number> = new Map();
|
||||
let score: number = Number.NEGATIVE_INFINITY;
|
||||
let highScoreId: any | null = null;
|
||||
|
||||
for (let i = 0; i < embeddings.length; i++) {
|
||||
const emb = embeddings[i];
|
||||
const similarity = similarityFn(queryEmbedding, emb);
|
||||
embedSimilarity.set(embeddingIds[i], similarity);
|
||||
if (similarity * threshold > score) {
|
||||
highScoreId = embeddingIds[i];
|
||||
score = similarity * threshold;
|
||||
}
|
||||
}
|
||||
|
||||
const results: [number, any][] = [];
|
||||
|
||||
const embeddingLength = embeddings.length;
|
||||
const similarityTopKCount = similarityTopK || embeddingLength;
|
||||
|
||||
while (results.length < Math.min(similarityTopKCount, embeddingLength)) {
|
||||
results.push([score, highScoreId]);
|
||||
embedMap.delete(highScoreId);
|
||||
const recentEmbeddingId = highScoreId;
|
||||
score = Number.NEGATIVE_INFINITY;
|
||||
for (const embedId of Array.from(embedMap.keys())) {
|
||||
const overlapWithRecent = similarityFn(
|
||||
embeddings[embedMap.get(embedId)!],
|
||||
embeddings[fullEmbedMap.get(recentEmbeddingId)!],
|
||||
);
|
||||
if (
|
||||
threshold * embedSimilarity.get(embedId)! -
|
||||
(1 - threshold) * overlapWithRecent >
|
||||
score
|
||||
) {
|
||||
score =
|
||||
threshold * embedSimilarity.get(embedId)! -
|
||||
(1 - threshold) * overlapWithRecent;
|
||||
highScoreId = embedId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const resultSimilarities = results.map(([s, _]) => s);
|
||||
const resultIds = results.map(([_, n]) => n);
|
||||
|
||||
return [resultSimilarities, resultIds];
|
||||
}
|
||||
|
||||
async function blobToDataUrl(input: Blob) {
|
||||
const buffer = Buffer.from(await input.arrayBuffer());
|
||||
const mimes = filetypemime(buffer);
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import type { BaseEmbedding } from "@llamaindex/core/embeddings";
|
||||
import {
|
||||
getTopKEmbeddings,
|
||||
getTopKMMREmbeddings,
|
||||
} from "@llamaindex/core/embeddings";
|
||||
import { DEFAULT_PERSIST_DIR } from "@llamaindex/core/global";
|
||||
import type { BaseNode } from "@llamaindex/core/schema";
|
||||
import { fs, path } from "@llamaindex/env";
|
||||
import { getTopKEmbeddings, getTopKMMREmbeddings } from "../internal/utils.js";
|
||||
import { exists } from "../storage/FileSystem.js";
|
||||
import {
|
||||
BaseVectorStore,
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/anthropic
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/anthropic",
|
||||
"description": "Anthropic Adapter for LlamaIndex",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/clip
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
- @llamaindex/openai@0.1.23
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/clip",
|
||||
"description": "Clip Embedding Adapter for LlamaIndex",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/deepinfra
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
- @llamaindex/openai@0.1.23
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepinfra",
|
||||
"description": "Deepinfra Adapter for LlamaIndex",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/groq
|
||||
|
||||
## 0.0.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @llamaindex/openai@0.1.23
|
||||
|
||||
## 0.0.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/groq",
|
||||
"description": "Groq Adapter for LlamaIndex",
|
||||
"version": "0.0.21",
|
||||
"version": "0.0.22",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/huggingface
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
- @llamaindex/openai@0.1.23
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/huggingface",
|
||||
"description": "Huggingface Adapter for LlamaIndex",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/ollama
|
||||
|
||||
## 0.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 0.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/ollama",
|
||||
"description": "Ollama Adapter for LlamaIndex",
|
||||
"version": "0.0.13",
|
||||
"version": "0.0.14",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/openai
|
||||
|
||||
## 0.1.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 0.1.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/openai",
|
||||
"description": "OpenAI Adapter for LlamaIndex",
|
||||
"version": "0.1.22",
|
||||
"version": "0.1.23",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/portkey-ai
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/portkey-ai",
|
||||
"description": "Portkey Adapter for LlamaIndex",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/replicate
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [691c5bc]
|
||||
- @llamaindex/core@0.3.6
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/replicate",
|
||||
"description": "Replicate Adapter for LlamaIndex",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
Generated
+1
-1
@@ -647,7 +647,7 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../providers/portkey-ai
|
||||
'@llamaindex/replicate':
|
||||
specifier: workspace:^0.0.6
|
||||
specifier: workspace:^0.0.7
|
||||
version: link:../providers/replicate
|
||||
'@mistralai/mistralai':
|
||||
specifier: ^1.0.4
|
||||
|
||||
Reference in New Issue
Block a user