Compare commits

..

9 Commits

Author SHA1 Message Date
github-actions[bot] ca75c81bc0 Release 0.7.9 (#1388)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: himself65 <himself65@users.noreply.github.com>
2024-10-24 12:32:24 -07:00
Alex Yang 691c5bcaf1 fix: export embeddings utils (#1387) 2024-10-24 12:23:57 -07:00
Alex Yang 9ab998c5d5 chore: add bug report template (#1385) 2024-10-24 11:37:04 -07:00
github-actions[bot] 938b417028 Release 0.7.8 (#1384)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: himself65 <himself65@users.noreply.github.com>
2024-10-24 10:17:01 -07:00
Alex Yang fa60fc66ae fix(env): no esm shim (#1383) 2024-10-24 10:08:49 -07:00
marcusschiesser 5607ed2fec chore: update lock file 2024-10-24 16:05:41 +07:00
github-actions[bot] f57ad6150e Release 0.7.7 2024-10-24 16:05:41 +07:00
Marcus Schiesser 2486bd8f41 feat: Add files_via_content example for LlamaCloud retrieval 2024-10-24 15:55:08 +07:00
Marcus Schiesser e2a0876ddd fix: Remove chunk size limit for prompt helper (use LLM default) 2024-10-24 15:55:08 +07:00
61 changed files with 797 additions and 160 deletions
+46
View File
@@ -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.
+21
View File
@@ -1,5 +1,26 @@
# docs
## 0.0.101
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 0.0.100
### Patch Changes
- llamaindex@0.7.8
## 0.0.99
### Patch Changes
- Updated dependencies [2486bd8]
- @llamaindex/examples@0.0.10
- llamaindex@0.7.7
## 0.0.98
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.98",
"version": "0.0.101",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
+9
View File
@@ -1,5 +1,14 @@
# examples
## 0.0.10
### Patch Changes
- 2486bd8: Add files_via_content example for LlamaCloud retrieval
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
- llamaindex@0.7.7
## 0.0.9
### Patch Changes
+2 -1
View File
@@ -12,7 +12,8 @@ async function main() {
});
const queryEngine = index.asQueryEngine({
similarityTopK: 5,
// retrieve the whole content of a file instead of just chunks of the file
retrieval_mode: "files_via_content",
});
const rl = readline.createInterface({ input, output });
+3 -3
View File
@@ -1,12 +1,12 @@
{
"name": "@llamaindex/examples",
"private": true,
"version": "0.0.9",
"version": "0.0.10",
"dependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"@azure/identity": "^4.4.1",
"@datastax/astra-db-ts": "^1.4.1",
"@llamaindex/core": "^0.3.0",
"@llamaindex/core": "^0.3.4",
"@notionhq/client": "^2.2.15",
"@pinecone-database/pinecone": "^3.0.2",
"@vercel/postgres": "^0.10.0",
@@ -15,7 +15,7 @@
"commander": "^12.1.0",
"dotenv": "^16.4.5",
"js-tiktoken": "^1.0.14",
"llamaindex": "^0.7.0",
"llamaindex": "^0.7.7",
"mongodb": "^6.7.0",
"pathe": "^1.1.2",
"postgres": "^3.4.4"
+19
View File
@@ -1,5 +1,24 @@
# @llamaindex/autotool
## 4.0.9
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 4.0.8
### Patch Changes
- llamaindex@0.7.8
## 4.0.7
### Patch Changes
- llamaindex@0.7.7
## 4.0.6
### Patch Changes
@@ -1,5 +1,27 @@
# @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
- llamaindex@0.7.8
- @llamaindex/autotool@4.0.8
## 0.0.39
### Patch Changes
- llamaindex@0.7.7
- @llamaindex/autotool@4.0.7
## 0.0.38
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.38"
"version": "0.0.41"
}
@@ -1,5 +1,27 @@
# @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
- llamaindex@0.7.8
- @llamaindex/autotool@4.0.8
## 0.1.83
### Patch Changes
- llamaindex@0.7.7
- @llamaindex/autotool@4.0.7
## 0.1.82
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.82",
"version": "0.1.85",
"scripts": {
"dev": "next dev",
"build": "next build",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool",
"type": "module",
"version": "4.0.6",
"version": "4.0.9",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
+22
View File
@@ -1,5 +1,27 @@
# @llamaindex/cloud
## 1.0.7
### Patch Changes
- Updated dependencies [691c5bc]
- @llamaindex/core@0.3.6
## 1.0.6
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
## 1.0.5
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
## 1.0.4
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "1.0.4",
"version": "1.0.7",
"type": "module",
"license": "MIT",
"scripts": {
+22
View File
@@ -1,5 +1,27 @@
# @llamaindex/community
## 0.0.55
### Patch Changes
- Updated dependencies [691c5bc]
- @llamaindex/core@0.3.6
## 0.0.54
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
## 0.0.53
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
## 0.0.52
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.52",
"version": "0.0.55",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+19
View File
@@ -1,5 +1,24 @@
# @llamaindex/core
## 0.3.6
### Patch Changes
- 691c5bc: fix: export embeddings utils
## 0.3.5
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
## 0.3.4
### Patch Changes
- e2a0876: Remove chunk size limit for prompt helper (use LLM default)
## 0.3.3
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.3.3",
"version": "0.3.6",
"description": "LlamaIndex Core Module",
"exports": {
"./agent": {
+7 -1
View File
@@ -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";
+118
View File
@@ -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 -2
View File
@@ -1,7 +1,6 @@
import { type Tokenizer, tokenizers } from "@llamaindex/env";
import {
DEFAULT_CHUNK_OVERLAP_RATIO,
DEFAULT_CHUNK_SIZE,
DEFAULT_CONTEXT_WINDOW,
DEFAULT_NUM_OUTPUTS,
DEFAULT_PADDING,
@@ -171,7 +170,7 @@ export class PromptHelper {
) {
const {
chunkOverlapRatio = DEFAULT_CHUNK_OVERLAP_RATIO,
chunkSizeLimit = DEFAULT_CHUNK_SIZE,
chunkSizeLimit = undefined,
tokenizer = Settings.tokenizer,
separator = " ",
} = options ?? {};
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/env
## 0.1.16
### Patch Changes
- fa60fc6: fix(env): no esm shim
## 0.1.15
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/env",
"description": "environment wrapper, supports all JS environment including node, deno, bun, edge runtime, and cloudflare worker",
"version": "0.1.15",
"version": "0.1.16",
"type": "module",
"types": "dist/index.d.ts",
"module": "dist/index.js",
+1
View File
@@ -11,6 +11,7 @@
*
* @module
*/
/** rollup-private-do-not-use-esm-shim-polyfill */
import { ok } from "node:assert";
import { createHash, randomUUID } from "node:crypto";
import { EOL } from "node:os";
+19
View File
@@ -1,5 +1,24 @@
# @llamaindex/experimental
## 0.0.110
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 0.0.109
### Patch Changes
- llamaindex@0.7.8
## 0.0.108
### Patch Changes
- llamaindex@0.7.7
## 0.0.107
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.107",
"version": "0.0.110",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+53
View File
@@ -1,5 +1,58 @@
# 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
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/cloud@1.0.6
- @llamaindex/core@0.3.5
- @llamaindex/anthropic@0.0.6
- @llamaindex/clip@0.0.6
- @llamaindex/deepinfra@0.0.6
- @llamaindex/groq@0.0.21
- @llamaindex/huggingface@0.0.6
- @llamaindex/ollama@0.0.13
- @llamaindex/openai@0.1.22
- @llamaindex/portkey-ai@0.0.6
- @llamaindex/replicate@0.0.6
## 0.7.7
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
- @llamaindex/cloud@1.0.5
- @llamaindex/anthropic@0.0.5
- @llamaindex/clip@0.0.5
- @llamaindex/deepinfra@0.0.5
- @llamaindex/huggingface@0.0.5
- @llamaindex/ollama@0.0.12
- @llamaindex/openai@0.1.21
- @llamaindex/portkey-ai@0.0.5
- @llamaindex/replicate@0.0.5
- @llamaindex/groq@0.0.20
## 0.7.6
### Patch Changes
@@ -1,5 +1,24 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.94
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 0.0.93
### Patch Changes
- llamaindex@0.7.8
## 0.0.92
### Patch Changes
- llamaindex@0.7.7
## 0.0.91
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.91",
"version": "0.0.94",
"type": "module",
"private": true,
"scripts": {
@@ -1,5 +1,23 @@
# @llamaindex/llama-parse-browser-test
## 0.0.18
### Patch Changes
- @llamaindex/cloud@1.0.7
## 0.0.17
### Patch Changes
- @llamaindex/cloud@1.0.6
## 0.0.16
### Patch Changes
- @llamaindex/cloud@1.0.5
## 0.0.15
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.15",
"version": "0.0.18",
"type": "module",
"scripts": {
"dev": "vite",
@@ -1,5 +1,24 @@
# @llamaindex/next-agent-test
## 0.1.94
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 0.1.93
### Patch Changes
- llamaindex@0.7.8
## 0.1.92
### Patch Changes
- llamaindex@0.7.7
## 0.1.91
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.91",
"version": "0.1.94",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,24 @@
# test-edge-runtime
## 0.1.93
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 0.1.92
### Patch Changes
- llamaindex@0.7.8
## 0.1.91
### Patch Changes
- llamaindex@0.7.7
## 0.1.90
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.90",
"version": "0.1.93",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,24 @@
# @llamaindex/next-node-runtime
## 0.0.75
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 0.0.74
### Patch Changes
- llamaindex@0.7.8
## 0.0.73
### Patch Changes
- llamaindex@0.7.7
## 0.0.72
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.0.72",
"version": "0.0.75",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,24 @@
# @llamaindex/waku-query-engine-test
## 0.0.94
### Patch Changes
- Updated dependencies [691c5bc]
- llamaindex@0.7.9
## 0.0.93
### Patch Changes
- llamaindex@0.7.8
## 0.0.92
### Patch Changes
- llamaindex@0.7.7
## 0.0.91
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.91",
"version": "0.0.94",
"type": "module",
"private": true,
"scripts": {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.7.6",
"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.4",
"@llamaindex/replicate": "workspace:^0.0.7",
"@mistralai/mistralai": "^1.0.4",
"@mixedbread-ai/sdk": "^2.2.11",
"@pinecone-database/pinecone": "^3.0.2",
-119
View File
@@ -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,
+22
View File
@@ -1,5 +1,27 @@
# @llamaindex/anthropic
## 0.0.7
### Patch Changes
- Updated dependencies [691c5bc]
- @llamaindex/core@0.3.6
## 0.0.6
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
## 0.0.5
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
## 0.0.4
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/anthropic",
"description": "Anthropic Adapter for LlamaIndex",
"version": "0.0.4",
"version": "0.0.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+25
View File
@@ -1,5 +1,30 @@
# @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
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
- @llamaindex/openai@0.1.22
## 0.0.5
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
- @llamaindex/openai@0.1.21
## 0.0.4
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/clip",
"description": "Clip Embedding Adapter for LlamaIndex",
"version": "0.0.4",
"version": "0.0.7",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
+25
View File
@@ -1,5 +1,30 @@
# @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
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
- @llamaindex/openai@0.1.22
## 0.0.5
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
- @llamaindex/openai@0.1.21
## 0.0.4
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/deepinfra",
"description": "Deepinfra Adapter for LlamaIndex",
"version": "0.0.4",
"version": "0.0.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+20
View File
@@ -1,5 +1,25 @@
# @llamaindex/groq
## 0.0.22
### Patch Changes
- @llamaindex/openai@0.1.23
## 0.0.21
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/openai@0.1.22
## 0.0.20
### Patch Changes
- @llamaindex/openai@0.1.21
## 0.0.19
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/groq",
"description": "Groq Adapter for LlamaIndex",
"version": "0.0.19",
"version": "0.0.22",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,30 @@
# @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
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
- @llamaindex/openai@0.1.22
## 0.0.5
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
- @llamaindex/openai@0.1.21
## 0.0.4
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/huggingface",
"description": "Huggingface Adapter for LlamaIndex",
"version": "0.0.4",
"version": "0.0.7",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
+22
View File
@@ -1,5 +1,27 @@
# @llamaindex/ollama
## 0.0.14
### Patch Changes
- Updated dependencies [691c5bc]
- @llamaindex/core@0.3.6
## 0.0.13
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
## 0.0.12
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
## 0.0.11
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/ollama",
"description": "Ollama Adapter for LlamaIndex",
"version": "0.0.11",
"version": "0.0.14",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+22
View File
@@ -1,5 +1,27 @@
# @llamaindex/openai
## 0.1.23
### Patch Changes
- Updated dependencies [691c5bc]
- @llamaindex/core@0.3.6
## 0.1.22
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
## 0.1.21
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
## 0.1.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/openai",
"description": "OpenAI Adapter for LlamaIndex",
"version": "0.1.20",
"version": "0.1.23",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,27 @@
# @llamaindex/portkey-ai
## 0.0.7
### Patch Changes
- Updated dependencies [691c5bc]
- @llamaindex/core@0.3.6
## 0.0.6
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
## 0.0.5
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
## 0.0.4
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/portkey-ai",
"description": "Portkey Adapter for LlamaIndex",
"version": "0.0.4",
"version": "0.0.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+22
View File
@@ -1,5 +1,27 @@
# @llamaindex/replicate
## 0.0.7
### Patch Changes
- Updated dependencies [691c5bc]
- @llamaindex/core@0.3.6
## 0.0.6
### Patch Changes
- Updated dependencies [fa60fc6]
- @llamaindex/env@0.1.16
- @llamaindex/core@0.3.5
## 0.0.5
### Patch Changes
- Updated dependencies [e2a0876]
- @llamaindex/core@0.3.4
## 0.0.4
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/replicate",
"description": "Replicate Adapter for LlamaIndex",
"version": "0.0.4",
"version": "0.0.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+37 -7
View File
@@ -225,7 +225,7 @@ importers:
specifier: ^1.4.1
version: 1.4.1
'@llamaindex/core':
specifier: ^0.3.0
specifier: ^0.3.4
version: link:../packages/core
'@notionhq/client':
specifier: ^2.2.15
@@ -252,7 +252,7 @@ importers:
specifier: ^1.0.14
version: 1.0.14
llamaindex:
specifier: ^0.7.0
specifier: ^0.7.7
version: link:../packages/llamaindex
mongodb:
specifier: ^6.7.0
@@ -647,7 +647,7 @@ importers:
specifier: workspace:*
version: link:../providers/portkey-ai
'@llamaindex/replicate':
specifier: workspace:^0.0.4
specifier: workspace:^0.0.7
version: link:../providers/replicate
'@mistralai/mistralai':
specifier: ^1.0.4
@@ -15436,7 +15436,7 @@ snapshots:
dependencies:
'@aws-sdk/client-sso': 3.675.0
'@aws-sdk/core': 3.667.0
'@aws-sdk/token-providers': 3.667.0(@aws-sdk/client-sso-oidc@3.678.0(@aws-sdk/client-sts@3.678.0))
'@aws-sdk/token-providers': 3.667.0(@aws-sdk/client-sso-oidc@3.678.0(@aws-sdk/client-sts@3.650.0))
'@aws-sdk/types': 3.667.0
'@smithy/property-provider': 3.1.8
'@smithy/shared-ini-file-loader': 3.1.9
@@ -23555,7 +23555,7 @@ snapshots:
'@typescript-eslint/parser': 7.2.0(eslint@8.57.0)(typescript@5.6.2)
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0)
eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.0)
eslint-plugin-jsx-a11y: 6.9.0(eslint@8.57.0)
eslint-plugin-react: 7.35.0(eslint@8.57.0)
@@ -23603,6 +23603,25 @@ snapshots:
transitivePeerDependencies:
- supports-color
eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0))(eslint@8.57.0):
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.3.7
enhanced-resolve: 5.17.1
eslint: 8.57.0
eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
fast-glob: 3.3.2
get-tsconfig: 4.8.0
is-bun-module: 1.1.0
is-glob: 4.0.3
optionalDependencies:
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.0)
transitivePeerDependencies:
- '@typescript-eslint/parser'
- eslint-import-resolver-node
- eslint-import-resolver-webpack
- supports-color
eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0):
dependencies:
'@nolyfill/is-core-module': 1.0.39
@@ -23615,13 +23634,24 @@ snapshots:
is-bun-module: 1.1.0
is-glob: 4.0.3
optionalDependencies:
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@8.10.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0)
eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.0)
transitivePeerDependencies:
- '@typescript-eslint/parser'
- eslint-import-resolver-node
- eslint-import-resolver-webpack
- supports-color
eslint-module-utils@2.8.2(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0):
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 7.2.0(eslint@8.57.0)(typescript@5.6.2)
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0))(eslint@8.57.0)
transitivePeerDependencies:
- supports-color
eslint-module-utils@2.8.2(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0):
dependencies:
debug: 3.2.7
@@ -23643,7 +23673,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0)
eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.6.2))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3