Compare commits

..

4 Commits

Author SHA1 Message Date
Alex Yang ddf07752d8 Merge branch 'main' into ms/fixes-for-cl 2024-07-30 08:00:20 -07:00
Marcus Schiesser 177aac766f fix: system prompt not used in ContextChatEngine 2024-07-30 15:50:29 +02:00
Marcus Schiesser 008edcf1d2 feat: Add metadatafilter options to retriever constructors 2024-07-30 15:50:29 +02:00
Marcus Schiesser 4b3bfc395b fix: PDFReader buffer error 2024-07-30 15:50:29 +02:00
39 changed files with 178 additions and 564 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---
feat: add splitByPage mode to LlamaParseReader
+5
View File
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---
Add metadatafilter options to retriever constructors
+5
View File
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---
Fix system prompt not used in ContextChatEngine
+1 -6
View File
@@ -31,12 +31,7 @@ module.exports = {
"@typescript-eslint/ban-types": "off",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/no-base-to-string": [
"error",
{
ignoredTypeNames: ["Error", "RegExp", "URL", "URLSearchParams"],
},
],
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-duplicate-enum-values": "off",
"@typescript-eslint/no-duplicate-type-constituents": "off",
"@typescript-eslint/no-explicit-any": "off",
+1 -1
View File
@@ -164,7 +164,7 @@ Check out our NextJS playground at https://llama-playground.vercel.app/. The sou
- [Node](/packages/llamaindex/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
- [Embedding](/packages/llamaindex/src/embeddings/OpenAIEmbedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that question. Because the default service context is OpenAI, the default embedding is `OpenAIEmbedding`. If using different models, say through Ollama, use this [Embedding](/packages/llamaindex/src/embeddings/OllamaEmbedding.ts) (see all [here](/packages/llamaindex/src/embeddings)).
- [Embedding](/packages/llamaindex/src/embeddings/OpenAIEmbedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton. Because the default service context is OpenAI, the default embedding is `OpenAIEmbedding`. If using different models, say through Ollama, use this [Embedding](/packages/llamaindex/src/embeddings/OllamaEmbedding.ts) (see all [here](/packages/llamaindex/src/embeddings)).
- [Indices](/packages/llamaindex/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
-15
View File
@@ -1,20 +1,5 @@
# docs
## 0.0.54
### Patch Changes
- llamaindex@0.5.13
## 0.0.53
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
## 0.0.52
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.54",
"version": "0.0.52",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
@@ -1,22 +1,5 @@
# @llamaindex/autotool-02-next-example
## 0.1.38
### Patch Changes
- llamaindex@0.5.13
- @llamaindex/autotool@2.0.0
## 0.1.37
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
- @llamaindex/autotool@2.0.0
## 0.1.36
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.38",
"version": "0.1.36",
"scripts": {
"dev": "next dev",
"build": "next build",
+2 -2
View File
@@ -51,7 +51,7 @@
"unplugin": "^1.10.1"
},
"peerDependencies": {
"llamaindex": "^0.5.13",
"llamaindex": "^0.5.11",
"openai": "^4",
"typescript": "^4"
},
@@ -70,7 +70,7 @@
"@swc/types": "^0.1.8",
"@types/json-schema": "^7.0.15",
"@types/node": "^20.12.11",
"bunchee": "5.3.1",
"bunchee": "5.3.0-beta.0",
"llamaindex": "workspace:*",
"next": "14.2.5",
"rollup": "^4.18.0",
+1 -1
View File
@@ -35,6 +35,6 @@
},
"devDependencies": {
"@hey-api/openapi-ts": "^0.48.0",
"bunchee": "5.3.1"
"bunchee": "5.3.0-beta.0"
}
}
-14
View File
@@ -1,19 +1,5 @@
# @llamaindex/community
## 0.0.28
### Patch Changes
- Updated dependencies [04b2f8e]
- @llamaindex/core@0.1.7
## 0.0.27
### Patch Changes
- Updated dependencies [0452af9]
- @llamaindex/core@0.1.6
## 0.0.26
### Patch Changes
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.28",
"version": "0.0.26",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
@@ -43,7 +43,7 @@
},
"devDependencies": {
"@types/node": "^20.14.2",
"bunchee": "5.3.1"
"bunchee": "5.3.0-beta.0"
},
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.613.0",
-12
View File
@@ -1,17 +1,5 @@
# @llamaindex/core
## 0.1.7
### Patch Changes
- 04b2f8e: Fix issue with metadata included after sentence splitter
## 0.1.6
### Patch Changes
- 0452af9: fix: handling errors in splitBySentenceTokenizer
## 0.1.5
### Patch Changes
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.1.7",
"version": "0.1.5",
"description": "LlamaIndex Core Module",
"exports": {
"./node-parser": {
@@ -131,7 +131,7 @@
},
"devDependencies": {
"ajv": "^8.16.0",
"bunchee": "5.3.1",
"bunchee": "5.3.0-beta.0",
"natural": "^7.1.0"
},
"dependencies": {
+1 -1
View File
@@ -140,7 +140,7 @@ export abstract class MetadataAwareTextSplitter extends TextSplitter {
return nodes.reduce<TextNode[]>((allNodes, node) => {
const metadataStr = this.getMetadataString(node);
const splits = this.splitTextMetadataAware(
node.getContent(MetadataMode.NONE),
node.getContent(MetadataMode.ALL),
metadataStr,
);
return allNodes.concat(buildNodeFromSplits(splits, node));
+1 -5
View File
@@ -39,11 +39,7 @@ export const splitBySentenceTokenizer = (): TextSplitterFn => {
}
const tokenizer = sentenceTokenizer;
return (text: string) => {
try {
return tokenizer.tokenize(text);
} catch {
return [text];
}
return tokenizer.tokenize(text);
};
};
@@ -1,10 +1,7 @@
import {
SentenceSplitter,
splitBySentenceTokenizer,
} from "@llamaindex/core/node-parser";
import { SentenceSplitter } from "@llamaindex/core/node-parser";
import { describe, expect, test } from "vitest";
describe("sentence splitter", () => {
describe("SentenceSplitter", () => {
test("initializes", () => {
const sentenceSplitter = new SentenceSplitter();
expect(sentenceSplitter).toBeDefined();
@@ -108,11 +105,4 @@ describe("sentence splitter", () => {
"因为他照了人类,连我都在内。",
]);
});
test("issue 1087 - edge case when input with brackets", () => {
const text =
"A card must be of uniform thickness and made of unfolded and uncreased paper or cardstock of approximately the quality and weight of a stamped card (i.e., a card available from USPS).";
const split = splitBySentenceTokenizer();
expect(split(text)).toEqual([text]);
});
});
-15
View File
@@ -1,20 +1,5 @@
# @llamaindex/experimental
## 0.0.63
### Patch Changes
- llamaindex@0.5.13
## 0.0.62
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
## 0.0.61
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.63",
"version": "0.0.61",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
@@ -162,18 +162,18 @@ export class JSONQueryEngine implements QueryEngine {
const schema = this.getSchemaContext();
const { text: jsonPathResponse } = await this.serviceContext.llm.complete({
const jsonPathResponseStr = await this.serviceContext.llm.complete({
prompt: this.jsonPathPrompt({ query, schema }),
});
if (this.verbose) {
console.log(
`> JSONPath Instructions:\n\`\`\`\n${jsonPathResponse}\n\`\`\`\n`,
`> JSONPath Instructions:\n\`\`\`\n${jsonPathResponseStr}\n\`\`\`\n`,
);
}
const jsonPathOutput = await this.outputProcessor({
llmOutput: jsonPathResponse,
llmOutput: jsonPathResponseStr.text,
jsonValue: this.jsonValue,
});
@@ -188,7 +188,7 @@ export class JSONQueryEngine implements QueryEngine {
prompt: this.responseSynthesisPrompt({
query,
jsonSchema: schema,
jsonPath: jsonPathResponse,
jsonPath: jsonPathResponseStr.text,
jsonPathValue: JSON.stringify(jsonPathOutput),
}),
});
@@ -199,7 +199,7 @@ export class JSONQueryEngine implements QueryEngine {
}
const responseMetadata = {
jsonPathResponse,
jsonPathResponseStr,
};
const response = EngineResponse.fromResponse(responseStr, false);
-17
View File
@@ -1,22 +1,5 @@
# llamaindex
## 0.5.13
### Patch Changes
- Updated dependencies [04b2f8e]
- @llamaindex/core@0.1.7
## 0.5.12
### Patch Changes
- 345300f: feat: add splitByPage mode to LlamaParseReader
- da5cfc4: Add metadatafilter options to retriever constructors
- da5cfc4: Fix system prompt not used in ContextChatEngine
- Updated dependencies [0452af9]
- @llamaindex/core@0.1.6
## 0.5.11
### Patch Changes
@@ -1,20 +1,5 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.47
### Patch Changes
- llamaindex@0.5.13
## 0.0.46
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
## 0.0.45
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.47",
"version": "0.0.45",
"type": "module",
"private": true,
"scripts": {
@@ -1,20 +1,5 @@
# @llamaindex/next-agent-test
## 0.1.47
### Patch Changes
- llamaindex@0.5.13
## 0.1.46
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
## 0.1.45
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.47",
"version": "0.1.45",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,20 +1,5 @@
# test-edge-runtime
## 0.1.46
### Patch Changes
- llamaindex@0.5.13
## 0.1.45
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
## 0.1.44
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.46",
"version": "0.1.44",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,20 +1,5 @@
# @llamaindex/next-node-runtime
## 0.0.28
### Patch Changes
- llamaindex@0.5.13
## 0.0.27
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
## 0.0.26
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.0.28",
"version": "0.0.26",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,20 +1,5 @@
# @llamaindex/waku-query-engine-test
## 0.0.47
### Patch Changes
- llamaindex@0.5.13
## 0.0.46
### Patch Changes
- Updated dependencies [345300f]
- Updated dependencies [da5cfc4]
- Updated dependencies [da5cfc4]
- llamaindex@0.5.12
## 0.0.45
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.47",
"version": "0.0.45",
"type": "module",
"private": true,
"scripts": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.5.13",
"version": "0.5.11",
"license": "MIT",
"type": "module",
"keywords": [
@@ -79,7 +79,7 @@ export class JinaAIEmbedding extends MultiModalEmbedding {
private async getImageInput(
image: ImageType,
): Promise<{ bytes: string } | { url: string }> {
if (isLocal(image) || image instanceof Blob) {
if (isLocal(image)) {
const base64 = await imageToDataUrl(image);
const bytes = base64.split(",")[1];
return { bytes };
@@ -133,7 +133,7 @@ export class RouterQueryEngine extends PromptMixin implements QueryEngine {
const responses: EngineResponse[] = [];
for (let i = 0; i < result.selections.length; i++) {
const engineInd = result.selections[i];
const logStr = `Selecting query engine ${engineInd.index}: ${result.selections[i].index}.`;
const logStr = `Selecting query engine ${engineInd}: ${result.selections[i]}.`;
if (this.verbose) {
console.log(logStr + "\n");
@@ -119,15 +119,15 @@ export class SubQuestionQueryEngine
return null;
}
const responseValue = await queryEngine?.call?.({
const responseText = await queryEngine?.call?.({
query: question,
});
if (responseValue == null) {
if (!responseText) {
return null;
}
const nodeText = `Sub question: ${question}\nResponse: ${typeof responseValue === "string" ? responseValue : JSON.stringify(responseValue)}`;
const nodeText = `Sub question: ${question}\nResponse: ${responseText}`;
const node = new TextNode({ text: nodeText });
return { node, score: 0 };
} catch (error) {
@@ -78,7 +78,7 @@ export class RelevancyEvaluator extends PromptMixin implements BaseEvaluator {
serviceContext: this.serviceContext,
});
const queryResponse = `Question: ${extractText(query)}\nResponse: ${response}`;
const queryResponse = `Question: ${query}\nResponse: ${response}`;
const queryEngine = index.asQueryEngine();
@@ -185,7 +185,7 @@ export class JSONReader<T extends JSONValue> extends FileReader {
return jsonStr;
} catch (e) {
throw new JSONStringifyError(
`Error stringifying JSON: ${e} in "${JSON.stringify(data)}"`,
`Error stringifying JSON: ${e} in "${data}"`,
);
}
}
+129 -346
View File
File diff suppressed because it is too large Load Diff