mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-04 03:40:26 -04:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ec6a529c7 | |||
| e8e21a0e4e | |||
| 88d243f145 | |||
| 3a6e287443 | |||
| beb3e5cd7f | |||
| 7416a87e10 | |||
| 65b85b237e | |||
| b17a80014a | |||
| ff87f99807 |
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"llamaindex": patch
|
||||
---
|
||||
|
||||
build: use ESM as default
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"llamaindex": patch
|
||||
---
|
||||
|
||||
feat: abstract `@llamaindex/env` package
|
||||
+1
-1
@@ -11,5 +11,5 @@ module.exports = {
|
||||
"max-params": ["error", 4],
|
||||
"prefer-const": "error",
|
||||
},
|
||||
ignorePatterns: ["dist/"],
|
||||
ignorePatterns: ["dist/", "lib/"],
|
||||
};
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
# llamaindex
|
||||
|
||||
## 0.1.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- e8e21a0: build: set files in package.json
|
||||
- Updated dependencies [e8e21a0]
|
||||
- @llamaindex/env@0.0.3
|
||||
|
||||
## 0.1.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3a6e287: build: improve tree-shake & reduce unused package import
|
||||
|
||||
## 0.1.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 7416a87: build: cjs file not found
|
||||
- Updated dependencies [7416a87]
|
||||
- @llamaindex/env@0.0.2
|
||||
|
||||
## 0.1.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b8be4c0: build: use ESM as default
|
||||
- 65d8346: feat: abstract `@llamaindex/env` package
|
||||
|
||||
## 0.1.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "llamaindex",
|
||||
"private": true,
|
||||
"version": "0.1.12",
|
||||
"version": "0.1.16",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
@@ -53,7 +52,7 @@
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"types": "./dist/type/index.d.ts",
|
||||
"main": "./dist/cjs/index.cjs",
|
||||
"main": "./dist/cjs/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
@@ -66,7 +65,7 @@
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/type/index.d.ts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
"default": "./dist/cjs/index.js"
|
||||
}
|
||||
},
|
||||
"./*": {
|
||||
@@ -76,12 +75,14 @@
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/type/*.d.ts",
|
||||
"default": "./dist/cjs/*.cjs"
|
||||
"default": "./dist/cjs/*.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"**"
|
||||
"dist",
|
||||
"CHANGELOG.md",
|
||||
"examples"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -92,8 +93,9 @@
|
||||
"lint": "eslint .",
|
||||
"build": "rm -rf ./dist && pnpm run build:esm && pnpm run build:cjs && pnpm run build:type",
|
||||
"build:esm": "swc src -d dist --strip-leading-paths --config-file .swcrc",
|
||||
"build:cjs": "swc src -d dist/cjs --strip-leading-paths --config-file .cjs.swcrc --out-file-extension cjs",
|
||||
"build:cjs": "swc src -d dist/cjs --strip-leading-paths --config-file .cjs.swcrc",
|
||||
"build:type": "tsc -p tsconfig.json",
|
||||
"postbuild": "node -e \"require('fs').writeFileSync('./dist/cjs/package.json', JSON.stringify({ type: 'commonjs' }))\"",
|
||||
"circular-check": "madge -c ./src/index.ts",
|
||||
"dev": "concurrently \"pnpm run build:esm --watch\" \"pnpm run build:cjs --watch\" \"pnpm run build:type --watch\""
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { OpenAI } from "./llm/LLM.js";
|
||||
import { ChatMessage, LLM, MessageType } from "./llm/types.js";
|
||||
import {
|
||||
defaultSummaryPrompt,
|
||||
messagesToHistoryStr,
|
||||
SummaryPrompt,
|
||||
} from "./Prompt.js";
|
||||
import type { ChatMessage, LLM, MessageType } from "./llm/types.js";
|
||||
import type { SummaryPrompt } from "./Prompt.js";
|
||||
import { defaultSummaryPrompt, messagesToHistoryStr } from "./Prompt.js";
|
||||
|
||||
/**
|
||||
* A ChatHistory is used to keep the state of back and forth chat messages
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { encodingForModel } from "js-tiktoken";
|
||||
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import { Event, EventTag, EventType } from "./callbacks/CallbackManager.js";
|
||||
import type {
|
||||
Event,
|
||||
EventTag,
|
||||
EventType,
|
||||
} from "./callbacks/CallbackManager.js";
|
||||
|
||||
export enum Tokenizers {
|
||||
CL100K_BASE = "cl100k_base",
|
||||
@@ -32,7 +36,7 @@ class GlobalsHelper {
|
||||
};
|
||||
}
|
||||
|
||||
tokenizer(encoding?: string) {
|
||||
tokenizer(encoding?: Tokenizers) {
|
||||
if (encoding && encoding !== Tokenizers.CL100K_BASE) {
|
||||
throw new Error(`Tokenizer encoding ${encoding} not yet supported`);
|
||||
}
|
||||
@@ -43,7 +47,7 @@ class GlobalsHelper {
|
||||
return this.defaultTokenizer!.encode.bind(this.defaultTokenizer);
|
||||
}
|
||||
|
||||
tokenizerDecoder(encoding?: string) {
|
||||
tokenizerDecoder(encoding?: Tokenizers) {
|
||||
if (encoding && encoding !== Tokenizers.CL100K_BASE) {
|
||||
throw new Error(`Tokenizer encoding ${encoding} not yet supported`);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,8 @@ export abstract class BaseNode<T extends Metadata = Metadata> {
|
||||
|
||||
abstract getContent(metadataMode: MetadataMode): string;
|
||||
abstract getMetadataStr(metadataMode: MetadataMode): string;
|
||||
abstract setContent(value: any): void;
|
||||
// todo: set value as a generic type
|
||||
abstract setContent(value: unknown): void;
|
||||
|
||||
get sourceNode(): RelatedNodeInfo<T> | undefined {
|
||||
const relationship = this.relationships[NodeRelationship.SOURCE];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SubQuestion } from "./engines/query/types.js";
|
||||
import { BaseOutputParser, StructuredOutput } from "./types.js";
|
||||
import type { SubQuestion } from "./engines/query/types.js";
|
||||
import type { BaseOutputParser, StructuredOutput } from "./types.js";
|
||||
|
||||
/**
|
||||
* Error class for output parsing. Due to the nature of LLMs, anytime we use LLM
|
||||
@@ -44,8 +44,8 @@ export function parseJsonMarkdown(text: string) {
|
||||
const left_square = text.indexOf("[");
|
||||
const left_brace = text.indexOf("{");
|
||||
|
||||
var left: number;
|
||||
var right: number;
|
||||
let left: number;
|
||||
let right: number;
|
||||
if (left_square < left_brace && left_square != -1) {
|
||||
left = left_square;
|
||||
right = text.lastIndexOf("]");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SubQuestion } from "./engines/query/types.js";
|
||||
import { ChatMessage } from "./llm/types.js";
|
||||
import { ToolMetadata } from "./types.js";
|
||||
import type { SubQuestion } from "./engines/query/types.js";
|
||||
import type { ChatMessage } from "./llm/types.js";
|
||||
import type { ToolMetadata } from "./types.js";
|
||||
|
||||
/**
|
||||
* A SimplePrompt is a function that takes a dictionary of inputs and returns a string.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { globalsHelper } from "./GlobalsHelper.js";
|
||||
import { SimplePrompt } from "./Prompt.js";
|
||||
import type { SimplePrompt } from "./Prompt.js";
|
||||
import { SentenceSplitter } from "./TextSplitter.js";
|
||||
import {
|
||||
DEFAULT_CHUNK_OVERLAP_RATIO,
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { SubQuestionOutputParser } from "./OutputParser.js";
|
||||
import {
|
||||
SubQuestionPrompt,
|
||||
buildToolsText,
|
||||
defaultSubQuestionPrompt,
|
||||
} from "./Prompt.js";
|
||||
import { BaseQuestionGenerator, SubQuestion } from "./engines/query/types.js";
|
||||
import type { SubQuestionPrompt } from "./Prompt.js";
|
||||
import { buildToolsText, defaultSubQuestionPrompt } from "./Prompt.js";
|
||||
import type {
|
||||
BaseQuestionGenerator,
|
||||
SubQuestion,
|
||||
} from "./engines/query/types.js";
|
||||
import { OpenAI } from "./llm/LLM.js";
|
||||
import { LLM } from "./llm/types.js";
|
||||
import type { LLM } from "./llm/types.js";
|
||||
import { PromptMixin } from "./prompts/index.js";
|
||||
import { BaseOutputParser, StructuredOutput, ToolMetadata } from "./types.js";
|
||||
import type {
|
||||
BaseOutputParser,
|
||||
StructuredOutput,
|
||||
ToolMetadata,
|
||||
} from "./types.js";
|
||||
|
||||
/**
|
||||
* LLMQuestionGenerator uses the LLM to generate new questions for the LLM using tools and a user query.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseNode } from "./Node.js";
|
||||
import type { BaseNode } from "./Node.js";
|
||||
|
||||
/**
|
||||
* Response is the output of a LLM
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Event } from "./callbacks/CallbackManager.js";
|
||||
import { NodeWithScore } from "./Node.js";
|
||||
import { ServiceContext } from "./ServiceContext.js";
|
||||
import type { Event } from "./callbacks/CallbackManager.js";
|
||||
import type { NodeWithScore } from "./Node.js";
|
||||
import type { ServiceContext } from "./ServiceContext.js";
|
||||
|
||||
/**
|
||||
* Retrievers retrieve the nodes that most closely match our query in similarity.
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { PromptHelper } from "./PromptHelper.js";
|
||||
import { CallbackManager } from "./callbacks/CallbackManager.js";
|
||||
import { OpenAIEmbedding } from "./embeddings/OpenAIEmbedding.js";
|
||||
import { BaseEmbedding } from "./embeddings/types.js";
|
||||
import { LLM, OpenAI } from "./llm/index.js";
|
||||
import type { BaseEmbedding } from "./embeddings/types.js";
|
||||
import type { LLM } from "./llm/index.js";
|
||||
import { OpenAI } from "./llm/index.js";
|
||||
import { SimpleNodeParser } from "./nodeParsers/SimpleNodeParser.js";
|
||||
import { NodeParser } from "./nodeParsers/types.js";
|
||||
import type { NodeParser } from "./nodeParsers/types.js";
|
||||
|
||||
/**
|
||||
* The ServiceContext is a collection of components that are used in different parts of the application.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import { ChatMessage, OpenAI } from "../../llm/index.js";
|
||||
import { ObjectRetriever } from "../../objects/base.js";
|
||||
import { BaseTool } from "../../types.js";
|
||||
import type { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import type { ChatMessage } from "../../llm/index.js";
|
||||
import { OpenAI } from "../../llm/index.js";
|
||||
import type { ObjectRetriever } from "../../objects/base.js";
|
||||
import type { BaseTool } from "../../types.js";
|
||||
import { AgentRunner } from "../runner/base.js";
|
||||
import { OpenAIAgentWorker } from "./worker.js";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ToolMetadata } from "../../types.js";
|
||||
import type { ToolMetadata } from "../../types.js";
|
||||
|
||||
export type OpenAIFunction = {
|
||||
type: "function";
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
// Assuming that the necessary interfaces and classes (like BaseTool, OpenAI, ChatMessage, CallbackManager, etc.) are defined elsewhere
|
||||
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import type { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import {
|
||||
AgentChatResponse,
|
||||
ChatResponseMode,
|
||||
} from "../../engines/chat/types.js";
|
||||
import {
|
||||
import type {
|
||||
ChatMessage,
|
||||
ChatResponse,
|
||||
ChatResponseChunk,
|
||||
OpenAI,
|
||||
} from "../../llm/index.js";
|
||||
import { OpenAI } from "../../llm/index.js";
|
||||
import { ChatMemoryBuffer } from "../../memory/ChatMemoryBuffer.js";
|
||||
import { ObjectRetriever } from "../../objects/base.js";
|
||||
import { ToolOutput } from "../../tools/types.js";
|
||||
import type { ObjectRetriever } from "../../objects/base.js";
|
||||
import type { ToolOutput } from "../../tools/types.js";
|
||||
import { callToolWithErrorHandling } from "../../tools/utils.js";
|
||||
import { BaseTool } from "../../types.js";
|
||||
import { AgentWorker, Task, TaskStep, TaskStepOutput } from "../types.js";
|
||||
import type { BaseTool } from "../../types.js";
|
||||
import type { AgentWorker, Task } from "../types.js";
|
||||
import { TaskStep, TaskStepOutput } from "../types.js";
|
||||
import { addUserStepToMemory, getFunctionByName } from "../utils.js";
|
||||
import { OpenAIToolCall } from "./types/chat.js";
|
||||
import type { OpenAIToolCall } from "./types/chat.js";
|
||||
import { toOpenAiTool } from "./utils.js";
|
||||
|
||||
const DEFAULT_MAX_FUNCTION_CALLS = 5;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import { ChatMessage, LLM } from "../../llm/index.js";
|
||||
import { ObjectRetriever } from "../../objects/base.js";
|
||||
import { BaseTool } from "../../types.js";
|
||||
import type { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import type { ChatMessage, LLM } from "../../llm/index.js";
|
||||
import type { ObjectRetriever } from "../../objects/base.js";
|
||||
import type { BaseTool } from "../../types.js";
|
||||
import { AgentRunner } from "../runner/base.js";
|
||||
import { ReActAgentWorker } from "./worker.js";
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ChatMessage } from "../../llm/index.js";
|
||||
import { BaseTool } from "../../types.js";
|
||||
import type { ChatMessage } from "../../llm/index.js";
|
||||
import type { BaseTool } from "../../types.js";
|
||||
import { getReactChatSystemHeader } from "./prompts.js";
|
||||
import { BaseReasoningStep, ObservationReasoningStep } from "./types.js";
|
||||
import type { BaseReasoningStep } from "./types.js";
|
||||
import { ObservationReasoningStep } from "./types.js";
|
||||
|
||||
function getReactToolDescriptions(tools: BaseTool[]): string[] {
|
||||
const toolDescs: string[] = [];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { BaseReasoningStep } from "./types.js";
|
||||
import {
|
||||
ActionReasoningStep,
|
||||
BaseOutputParser,
|
||||
BaseReasoningStep,
|
||||
ResponseReasoningStep,
|
||||
} from "./types.js";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChatMessage } from "../../llm/index.js";
|
||||
import type { ChatMessage } from "../../llm/index.js";
|
||||
|
||||
export interface BaseReasoningStep {
|
||||
getContent(): string;
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import { randomUUID } from "crypto";
|
||||
import { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import { AgentChatResponse } from "../../engines/chat/index.js";
|
||||
import { ChatResponse, LLM, OpenAI } from "../../llm/index.js";
|
||||
import type { ChatResponse, LLM } from "../../llm/index.js";
|
||||
import { OpenAI } from "../../llm/index.js";
|
||||
import { ChatMemoryBuffer } from "../../memory/ChatMemoryBuffer.js";
|
||||
import { ObjectRetriever } from "../../objects/base.js";
|
||||
import type { ObjectRetriever } from "../../objects/base.js";
|
||||
import { ToolOutput } from "../../tools/index.js";
|
||||
import { BaseTool } from "../../types.js";
|
||||
import { AgentWorker, Task, TaskStep, TaskStepOutput } from "../types.js";
|
||||
import type { BaseTool } from "../../types.js";
|
||||
import type { AgentWorker, Task } from "../types.js";
|
||||
import { TaskStep, TaskStepOutput } from "../types.js";
|
||||
import { ReActChatFormatter } from "./formatter.js";
|
||||
import { ReActOutputParser } from "./outputParser.js";
|
||||
import type { BaseReasoningStep } from "./types.js";
|
||||
import {
|
||||
ActionReasoningStep,
|
||||
BaseReasoningStep,
|
||||
ObservationReasoningStep,
|
||||
ResponseReasoningStep,
|
||||
} from "./types.js";
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { randomUUID } from "crypto";
|
||||
import { CallbackManager } from "../../callbacks/CallbackManager.js";
|
||||
import type { ChatEngineAgentParams } from "../../engines/chat/index.js";
|
||||
import {
|
||||
AgentChatResponse,
|
||||
ChatEngineAgentParams,
|
||||
ChatResponseMode,
|
||||
} from "../../engines/chat/index.js";
|
||||
import { ChatMessage, LLM } from "../../llm/index.js";
|
||||
import type { ChatMessage, LLM } from "../../llm/index.js";
|
||||
import { ChatMemoryBuffer } from "../../memory/ChatMemoryBuffer.js";
|
||||
import { BaseMemory } from "../../memory/types.js";
|
||||
import { AgentWorker, Task, TaskStep, TaskStepOutput } from "../types.js";
|
||||
import type { BaseMemory } from "../../memory/types.js";
|
||||
import type { AgentWorker, TaskStepOutput } from "../types.js";
|
||||
import { Task, TaskStep } from "../types.js";
|
||||
import { AgentState, BaseAgentRunner, TaskState } from "./types.js";
|
||||
|
||||
const validateStepFromArgs = (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AgentChatResponse } from "../../engines/chat/index.js";
|
||||
import { BaseAgent, Task, TaskStep, TaskStepOutput } from "../types.js";
|
||||
import type { AgentChatResponse } from "../../engines/chat/index.js";
|
||||
import type { Task, TaskStep, TaskStepOutput } from "../types.js";
|
||||
import { BaseAgent } from "../types.js";
|
||||
|
||||
export class TaskState {
|
||||
task!: Task;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
import type {
|
||||
AgentChatResponse,
|
||||
ChatEngineAgentParams,
|
||||
} from "../engines/chat/index.js";
|
||||
import { QueryEngineParamsNonStreaming } from "../types.js";
|
||||
import type { QueryEngineParamsNonStreaming } from "../types.js";
|
||||
|
||||
export interface AgentWorker {
|
||||
initializeStep(task: Task, kwargs?: any): TaskStep;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChatMessage } from "../llm/index.js";
|
||||
import { ChatMemoryBuffer } from "../memory/ChatMemoryBuffer.js";
|
||||
import { BaseTool } from "../types.js";
|
||||
import { TaskStep } from "./types.js";
|
||||
import type { ChatMessage } from "../llm/index.js";
|
||||
import type { ChatMemoryBuffer } from "../memory/ChatMemoryBuffer.js";
|
||||
import type { BaseTool } from "../types.js";
|
||||
import type { TaskStep } from "./types.js";
|
||||
|
||||
/**
|
||||
* Adds the user's input to the memory.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Anthropic } from "@anthropic-ai/sdk";
|
||||
import { NodeWithScore } from "../Node.js";
|
||||
import type { NodeWithScore } from "../Node.js";
|
||||
|
||||
/*
|
||||
An event is a wrapper that groups related operations.
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { BaseRetriever } from "../Retriever.js";
|
||||
import type { BaseRetriever } from "../Retriever.js";
|
||||
import { RetrieverQueryEngine } from "../engines/query/RetrieverQueryEngine.js";
|
||||
import { BaseNodePostprocessor } from "../postprocessors/types.js";
|
||||
import { BaseSynthesizer } from "../synthesizers/types.js";
|
||||
import { BaseQueryEngine } from "../types.js";
|
||||
import { LlamaCloudRetriever, RetrieveParams } from "./LlamaCloudRetriever.js";
|
||||
import { CloudConstructorParams } from "./types.js";
|
||||
import type { BaseNodePostprocessor } from "../postprocessors/types.js";
|
||||
import type { BaseSynthesizer } from "../synthesizers/types.js";
|
||||
import type { BaseQueryEngine } from "../types.js";
|
||||
import type { RetrieveParams } from "./LlamaCloudRetriever.js";
|
||||
import { LlamaCloudRetriever } from "./LlamaCloudRetriever.js";
|
||||
import type { CloudConstructorParams } from "./types.js";
|
||||
|
||||
export class LlamaCloudIndex {
|
||||
params: CloudConstructorParams;
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import { PlatformApi, PlatformApiClient } from "@llamaindex/cloud";
|
||||
import type { PlatformApi, PlatformApiClient } from "@llamaindex/cloud";
|
||||
import { globalsHelper } from "../GlobalsHelper.js";
|
||||
import { NodeWithScore, ObjectType, jsonToNode } from "../Node.js";
|
||||
import { BaseRetriever } from "../Retriever.js";
|
||||
import {
|
||||
ServiceContext,
|
||||
serviceContextFromDefaults,
|
||||
} from "../ServiceContext.js";
|
||||
import { Event } from "../callbacks/CallbackManager.js";
|
||||
import {
|
||||
ClientParams,
|
||||
CloudConstructorParams,
|
||||
DEFAULT_PROJECT_NAME,
|
||||
} from "./types.js";
|
||||
import type { NodeWithScore } from "../Node.js";
|
||||
import { ObjectType, jsonToNode } from "../Node.js";
|
||||
import type { BaseRetriever } from "../Retriever.js";
|
||||
import type { ServiceContext } from "../ServiceContext.js";
|
||||
import { serviceContextFromDefaults } from "../ServiceContext.js";
|
||||
import type { Event } from "../callbacks/CallbackManager.js";
|
||||
import type { ClientParams, CloudConstructorParams } from "./types.js";
|
||||
import { DEFAULT_PROJECT_NAME } from "./types.js";
|
||||
import { getClient } from "./utils.js";
|
||||
|
||||
export type RetrieveParams = Omit<
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ServiceContext } from "../ServiceContext.js";
|
||||
import type { ServiceContext } from "../ServiceContext.js";
|
||||
|
||||
export const DEFAULT_PROJECT_NAME = "default";
|
||||
export const DEFAULT_BASE_URL = "https://api.cloud.llamaindex.ai";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { PlatformApiClient } from "@llamaindex/cloud";
|
||||
import { ClientParams, DEFAULT_BASE_URL } from "./types.js";
|
||||
import type { PlatformApiClient } from "@llamaindex/cloud";
|
||||
import type { ClientParams } from "./types.js";
|
||||
import { DEFAULT_BASE_URL } from "./types.js";
|
||||
|
||||
export async function getClient({
|
||||
apiKey,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ImageType } from "../Node.js";
|
||||
import type { ImageType } from "../Node.js";
|
||||
import { MultiModalEmbedding } from "./MultiModalEmbedding.js";
|
||||
import { readImage } from "./utils.js";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ImageType } from "../Node.js";
|
||||
import type { ImageType } from "../Node.js";
|
||||
import { BaseEmbedding } from "./types.js";
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Ollama } from "../llm/ollama.js";
|
||||
import { BaseEmbedding } from "./types.js";
|
||||
import type { BaseEmbedding } from "./types.js";
|
||||
|
||||
/**
|
||||
* OllamaEmbedding is an alias for Ollama that implements the BaseEmbedding interface.
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { ClientOptions as OpenAIClientOptions } from "openai";
|
||||
import type { ClientOptions as OpenAIClientOptions } from "openai";
|
||||
import type { AzureOpenAIConfig } from "../llm/azure.js";
|
||||
import {
|
||||
AzureOpenAIConfig,
|
||||
getAzureBaseUrl,
|
||||
getAzureConfigFromEnv,
|
||||
getAzureModel,
|
||||
shouldUseAzure,
|
||||
} from "../llm/azure.js";
|
||||
import { OpenAISession, getOpenAISession } from "../llm/open_ai.js";
|
||||
import type { OpenAISession } from "../llm/open_ai.js";
|
||||
import { getOpenAISession } from "../llm/open_ai.js";
|
||||
import { BaseEmbedding } from "./types.js";
|
||||
|
||||
export const ALL_OPENAI_EMBEDDING_MODELS = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BaseNode, MetadataMode } from "../Node.js";
|
||||
import { TransformComponent } from "../ingestion/types.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import { MetadataMode } from "../Node.js";
|
||||
import type { TransformComponent } from "../ingestion/types.js";
|
||||
import { SimilarityType, similarity } from "./utils.js";
|
||||
|
||||
const DEFAULT_EMBED_BATCH_SIZE = 10;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { defaultFS } from "@llamaindex/env";
|
||||
import _ from "lodash";
|
||||
import { ImageType } from "../Node.js";
|
||||
import type { ImageType } from "../Node.js";
|
||||
import { DEFAULT_SIMILARITY_TOP_K } from "../constants.js";
|
||||
import { VectorStoreQueryMode } from "../storage/vectorStore/types.js";
|
||||
|
||||
@@ -171,13 +171,13 @@ export function getTopKMMREmbeddings(
|
||||
|
||||
while (results.length < Math.min(similarityTopKCount, embeddingLength)) {
|
||||
results.push([score, highScoreId]);
|
||||
embedMap.delete(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!)!],
|
||||
embeddings[fullEmbedMap.get(recentEmbeddingId)!],
|
||||
);
|
||||
if (
|
||||
threshold * embedSimilarity.get(embedId)! -
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
import { ChatHistory, getHistory } from "../../ChatHistory.js";
|
||||
import type { ChatHistory } from "../../ChatHistory.js";
|
||||
import { getHistory } from "../../ChatHistory.js";
|
||||
import type { CondenseQuestionPrompt } from "../../Prompt.js";
|
||||
import {
|
||||
CondenseQuestionPrompt,
|
||||
defaultCondenseQuestionPrompt,
|
||||
messagesToHistoryStr,
|
||||
} from "../../Prompt.js";
|
||||
import { Response } from "../../Response.js";
|
||||
import {
|
||||
ServiceContext,
|
||||
serviceContextFromDefaults,
|
||||
} from "../../ServiceContext.js";
|
||||
import { ChatMessage, LLM } from "../../llm/index.js";
|
||||
import type { Response } from "../../Response.js";
|
||||
import type { ServiceContext } from "../../ServiceContext.js";
|
||||
import { serviceContextFromDefaults } from "../../ServiceContext.js";
|
||||
import type { ChatMessage, LLM } from "../../llm/index.js";
|
||||
import { extractText, streamReducer } from "../../llm/utils.js";
|
||||
import { PromptMixin } from "../../prompts/index.js";
|
||||
import { BaseQueryEngine } from "../../types.js";
|
||||
import {
|
||||
import type { BaseQueryEngine } from "../../types.js";
|
||||
import type {
|
||||
ChatEngine,
|
||||
ChatEngineParamsNonStreaming,
|
||||
ChatEngineParamsStreaming,
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import { ChatHistory, getHistory } from "../../ChatHistory.js";
|
||||
import { ContextSystemPrompt } from "../../Prompt.js";
|
||||
import type { ChatHistory } from "../../ChatHistory.js";
|
||||
import { getHistory } from "../../ChatHistory.js";
|
||||
import type { ContextSystemPrompt } from "../../Prompt.js";
|
||||
import { Response } from "../../Response.js";
|
||||
import { BaseRetriever } from "../../Retriever.js";
|
||||
import { Event } from "../../callbacks/CallbackManager.js";
|
||||
import {
|
||||
ChatMessage,
|
||||
ChatResponseChunk,
|
||||
LLM,
|
||||
OpenAI,
|
||||
} from "../../llm/index.js";
|
||||
import { MessageContent } from "../../llm/types.js";
|
||||
import type { BaseRetriever } from "../../Retriever.js";
|
||||
import type { Event } from "../../callbacks/CallbackManager.js";
|
||||
import type { ChatMessage, ChatResponseChunk, LLM } from "../../llm/index.js";
|
||||
import { OpenAI } from "../../llm/index.js";
|
||||
import type { MessageContent } from "../../llm/types.js";
|
||||
import {
|
||||
extractText,
|
||||
streamConverter,
|
||||
streamReducer,
|
||||
} from "../../llm/utils.js";
|
||||
import { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import type { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import { PromptMixin } from "../../prompts/Mixin.js";
|
||||
import { DefaultContextGenerator } from "./DefaultContextGenerator.js";
|
||||
import {
|
||||
import type {
|
||||
ChatEngine,
|
||||
ChatEngineParamsNonStreaming,
|
||||
ChatEngineParamsStreaming,
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import { NodeWithScore, TextNode } from "../../Node.js";
|
||||
import {
|
||||
ContextSystemPrompt,
|
||||
defaultContextSystemPrompt,
|
||||
} from "../../Prompt.js";
|
||||
import { BaseRetriever } from "../../Retriever.js";
|
||||
import { Event } from "../../callbacks/CallbackManager.js";
|
||||
import { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import type { NodeWithScore, TextNode } from "../../Node.js";
|
||||
import type { ContextSystemPrompt } from "../../Prompt.js";
|
||||
import { defaultContextSystemPrompt } from "../../Prompt.js";
|
||||
import type { BaseRetriever } from "../../Retriever.js";
|
||||
import type { Event } from "../../callbacks/CallbackManager.js";
|
||||
import type { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import { PromptMixin } from "../../prompts/index.js";
|
||||
import { Context, ContextGenerator } from "./types.js";
|
||||
import type { Context, ContextGenerator } from "./types.js";
|
||||
|
||||
export class DefaultContextGenerator
|
||||
extends PromptMixin
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { ChatHistory, getHistory } from "../../ChatHistory.js";
|
||||
import type { ChatHistory } from "../../ChatHistory.js";
|
||||
import { getHistory } from "../../ChatHistory.js";
|
||||
import { Response } from "../../Response.js";
|
||||
import { ChatResponseChunk, LLM, OpenAI } from "../../llm/index.js";
|
||||
import type { ChatResponseChunk, LLM } from "../../llm/index.js";
|
||||
import { OpenAI } from "../../llm/index.js";
|
||||
import { streamConverter, streamReducer } from "../../llm/utils.js";
|
||||
import {
|
||||
import type {
|
||||
ChatEngine,
|
||||
ChatEngineParamsNonStreaming,
|
||||
ChatEngineParamsStreaming,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ChatHistory } from "../../ChatHistory.js";
|
||||
import { BaseNode, NodeWithScore } from "../../Node.js";
|
||||
import { Response } from "../../Response.js";
|
||||
import { Event } from "../../callbacks/CallbackManager.js";
|
||||
import { ChatMessage } from "../../llm/index.js";
|
||||
import { MessageContent } from "../../llm/types.js";
|
||||
import { ToolOutput } from "../../tools/types.js";
|
||||
import type { ChatHistory } from "../../ChatHistory.js";
|
||||
import type { BaseNode, NodeWithScore } from "../../Node.js";
|
||||
import type { Response } from "../../Response.js";
|
||||
import type { Event } from "../../callbacks/CallbackManager.js";
|
||||
import type { ChatMessage } from "../../llm/index.js";
|
||||
import type { MessageContent } from "../../llm/types.js";
|
||||
import type { ToolOutput } from "../../tools/types.js";
|
||||
|
||||
/**
|
||||
* Represents the base parameters for ChatEngine.
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import { NodeWithScore } from "../../Node.js";
|
||||
import { Response } from "../../Response.js";
|
||||
import { BaseRetriever } from "../../Retriever.js";
|
||||
import { ServiceContext } from "../../ServiceContext.js";
|
||||
import { Event } from "../../callbacks/CallbackManager.js";
|
||||
import { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import type { NodeWithScore } from "../../Node.js";
|
||||
import type { Response } from "../../Response.js";
|
||||
import type { BaseRetriever } from "../../Retriever.js";
|
||||
import type { ServiceContext } from "../../ServiceContext.js";
|
||||
import type { Event } from "../../callbacks/CallbackManager.js";
|
||||
import type { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import { PromptMixin } from "../../prompts/Mixin.js";
|
||||
import {
|
||||
BaseSynthesizer,
|
||||
ResponseSynthesizer,
|
||||
} from "../../synthesizers/index.js";
|
||||
import {
|
||||
import type { BaseSynthesizer } from "../../synthesizers/index.js";
|
||||
import { ResponseSynthesizer } from "../../synthesizers/index.js";
|
||||
import type {
|
||||
BaseQueryEngine,
|
||||
QueryEngineParamsNonStreaming,
|
||||
QueryEngineParamsStreaming,
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { BaseNode } from "../../Node.js";
|
||||
import type { BaseNode } from "../../Node.js";
|
||||
import { Response } from "../../Response.js";
|
||||
import {
|
||||
ServiceContext,
|
||||
serviceContextFromDefaults,
|
||||
} from "../../ServiceContext.js";
|
||||
import type { ServiceContext } from "../../ServiceContext.js";
|
||||
import { serviceContextFromDefaults } from "../../ServiceContext.js";
|
||||
import { PromptMixin } from "../../prompts/index.js";
|
||||
import { BaseSelector, LLMSingleSelector } from "../../selectors/index.js";
|
||||
import type { BaseSelector } from "../../selectors/index.js";
|
||||
import { LLMSingleSelector } from "../../selectors/index.js";
|
||||
import { TreeSummarize } from "../../synthesizers/index.js";
|
||||
import {
|
||||
import type {
|
||||
BaseQueryEngine,
|
||||
QueryBundle,
|
||||
QueryEngineParamsNonStreaming,
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import { NodeWithScore, TextNode } from "../../Node.js";
|
||||
import type { NodeWithScore } from "../../Node.js";
|
||||
import { TextNode } from "../../Node.js";
|
||||
import { LLMQuestionGenerator } from "../../QuestionGenerator.js";
|
||||
import { Response } from "../../Response.js";
|
||||
import {
|
||||
ServiceContext,
|
||||
serviceContextFromDefaults,
|
||||
} from "../../ServiceContext.js";
|
||||
import { Event } from "../../callbacks/CallbackManager.js";
|
||||
import type { Response } from "../../Response.js";
|
||||
import type { ServiceContext } from "../../ServiceContext.js";
|
||||
import { serviceContextFromDefaults } from "../../ServiceContext.js";
|
||||
import type { Event } from "../../callbacks/CallbackManager.js";
|
||||
import { PromptMixin } from "../../prompts/Mixin.js";
|
||||
import type { BaseSynthesizer } from "../../synthesizers/index.js";
|
||||
import {
|
||||
BaseSynthesizer,
|
||||
CompactAndRefine,
|
||||
ResponseSynthesizer,
|
||||
} from "../../synthesizers/index.js";
|
||||
|
||||
import {
|
||||
import type {
|
||||
BaseQueryEngine,
|
||||
BaseTool,
|
||||
QueryEngineParamsNonStreaming,
|
||||
@@ -22,7 +21,7 @@ import {
|
||||
ToolMetadata,
|
||||
} from "../../types.js";
|
||||
|
||||
import { BaseQuestionGenerator, SubQuestion } from "./types.js";
|
||||
import type { BaseQuestionGenerator, SubQuestion } from "./types.js";
|
||||
|
||||
/**
|
||||
* SubQuestionQueryEngine decomposes a question into subquestions and then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ToolMetadata } from "../../types.js";
|
||||
import type { ToolMetadata } from "../../types.js";
|
||||
|
||||
/**
|
||||
* QuestionGenerators generate new questions for the LLM using tools and a user query.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { BaseNode, MetadataMode, TextNode } from "../Node.js";
|
||||
import { LLM, OpenAI } from "../llm/index.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import { MetadataMode, TextNode } from "../Node.js";
|
||||
import type { LLM } from "../llm/index.js";
|
||||
import { OpenAI } from "../llm/index.js";
|
||||
import {
|
||||
defaultKeywordExtractorPromptTemplate,
|
||||
defaultQuestionAnswerPromptTemplate,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BaseNode, MetadataMode, TextNode } from "../Node.js";
|
||||
import { TransformComponent } from "../ingestion/types.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import { MetadataMode, TextNode } from "../Node.js";
|
||||
import type { TransformComponent } from "../ingestion/types.js";
|
||||
import { defaultNodeTextTemplate } from "./prompts.js";
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { BaseNode, Document } from "../Node.js";
|
||||
import { BaseRetriever } from "../Retriever.js";
|
||||
import { ServiceContext } from "../ServiceContext.js";
|
||||
import type { BaseNode, Document } from "../Node.js";
|
||||
import type { BaseRetriever } from "../Retriever.js";
|
||||
import type { ServiceContext } from "../ServiceContext.js";
|
||||
import { runTransformations } from "../ingestion/IngestionPipeline.js";
|
||||
import { StorageContext } from "../storage/StorageContext.js";
|
||||
import { BaseDocumentStore } from "../storage/docStore/types.js";
|
||||
import { BaseIndexStore } from "../storage/indexStore/types.js";
|
||||
import { VectorStore } from "../storage/vectorStore/types.js";
|
||||
import { BaseSynthesizer } from "../synthesizers/types.js";
|
||||
import { BaseQueryEngine } from "../types.js";
|
||||
import type { StorageContext } from "../storage/StorageContext.js";
|
||||
import type { BaseDocumentStore } from "../storage/docStore/types.js";
|
||||
import type { BaseIndexStore } from "../storage/indexStore/types.js";
|
||||
import type { VectorStore } from "../storage/vectorStore/types.js";
|
||||
import type { BaseSynthesizer } from "../synthesizers/types.js";
|
||||
import type { BaseQueryEngine } from "../types.js";
|
||||
import { IndexStruct } from "./IndexStruct.js";
|
||||
import { IndexStructType } from "./json-to-index-struct.js";
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BaseNode, jsonToNode } from "../Node.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import { jsonToNode } from "../Node.js";
|
||||
import { IndexStruct } from "./IndexStruct.js";
|
||||
|
||||
export enum IndexStructType {
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
import { BaseNode, Document, MetadataMode, NodeWithScore } from "../../Node.js";
|
||||
import {
|
||||
import type { BaseNode, Document, NodeWithScore } from "../../Node.js";
|
||||
import { MetadataMode } from "../../Node.js";
|
||||
import type {
|
||||
KeywordExtractPrompt,
|
||||
QueryKeywordExtractPrompt,
|
||||
} from "../../Prompt.js";
|
||||
import {
|
||||
defaultKeywordExtractPrompt,
|
||||
defaultQueryKeywordExtractPrompt,
|
||||
} from "../../Prompt.js";
|
||||
import { BaseRetriever } from "../../Retriever.js";
|
||||
import {
|
||||
ServiceContext,
|
||||
serviceContextFromDefaults,
|
||||
} from "../../ServiceContext.js";
|
||||
import type { BaseRetriever } from "../../Retriever.js";
|
||||
import type { ServiceContext } from "../../ServiceContext.js";
|
||||
import { serviceContextFromDefaults } from "../../ServiceContext.js";
|
||||
import { RetrieverQueryEngine } from "../../engines/query/index.js";
|
||||
import { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import {
|
||||
BaseDocumentStore,
|
||||
StorageContext,
|
||||
storageContextFromDefaults,
|
||||
} from "../../storage/index.js";
|
||||
import { BaseSynthesizer } from "../../synthesizers/index.js";
|
||||
import { BaseQueryEngine } from "../../types.js";
|
||||
import { BaseIndex, BaseIndexInit, KeywordTable } from "../BaseIndex.js";
|
||||
import type { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import type { BaseDocumentStore, StorageContext } from "../../storage/index.js";
|
||||
import { storageContextFromDefaults } from "../../storage/index.js";
|
||||
import type { BaseSynthesizer } from "../../synthesizers/index.js";
|
||||
import type { BaseQueryEngine } from "../../types.js";
|
||||
import type { BaseIndexInit } from "../BaseIndex.js";
|
||||
import { BaseIndex, KeywordTable } from "../BaseIndex.js";
|
||||
import { IndexStructType } from "../json-to-index-struct.js";
|
||||
import {
|
||||
extractKeywordsGivenResponse,
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
import _ from "lodash";
|
||||
import { globalsHelper } from "../../GlobalsHelper.js";
|
||||
import { BaseNode, Document, NodeWithScore } from "../../Node.js";
|
||||
import { ChoiceSelectPrompt, defaultChoiceSelectPrompt } from "../../Prompt.js";
|
||||
import { BaseRetriever } from "../../Retriever.js";
|
||||
import {
|
||||
ServiceContext,
|
||||
serviceContextFromDefaults,
|
||||
} from "../../ServiceContext.js";
|
||||
import { Event } from "../../callbacks/CallbackManager.js";
|
||||
import type { BaseNode, Document, NodeWithScore } from "../../Node.js";
|
||||
import type { ChoiceSelectPrompt } from "../../Prompt.js";
|
||||
import { defaultChoiceSelectPrompt } from "../../Prompt.js";
|
||||
import type { BaseRetriever } from "../../Retriever.js";
|
||||
import type { ServiceContext } from "../../ServiceContext.js";
|
||||
import { serviceContextFromDefaults } from "../../ServiceContext.js";
|
||||
import type { Event } from "../../callbacks/CallbackManager.js";
|
||||
import { RetrieverQueryEngine } from "../../engines/query/index.js";
|
||||
import { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import {
|
||||
import type { BaseNodePostprocessor } from "../../postprocessors/index.js";
|
||||
import type {
|
||||
BaseDocumentStore,
|
||||
RefDocInfo,
|
||||
StorageContext,
|
||||
storageContextFromDefaults,
|
||||
} from "../../storage/index.js";
|
||||
import { storageContextFromDefaults } from "../../storage/index.js";
|
||||
import type { BaseSynthesizer } from "../../synthesizers/index.js";
|
||||
import {
|
||||
BaseSynthesizer,
|
||||
CompactAndRefine,
|
||||
ResponseSynthesizer,
|
||||
} from "../../synthesizers/index.js";
|
||||
import { BaseQueryEngine } from "../../types.js";
|
||||
import { BaseIndex, BaseIndexInit } from "../BaseIndex.js";
|
||||
import type { BaseQueryEngine } from "../../types.js";
|
||||
import type { BaseIndexInit } from "../BaseIndex.js";
|
||||
import { BaseIndex } from "../BaseIndex.js";
|
||||
import { IndexList, IndexStructType } from "../json-to-index-struct.js";
|
||||
import {
|
||||
import type {
|
||||
ChoiceSelectParserFunction,
|
||||
NodeFormatterFunction,
|
||||
} from "./utils.js";
|
||||
import {
|
||||
defaultFormatNodeBatchFn,
|
||||
defaultParseChoiceSelectAnswerFn,
|
||||
} from "./utils.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import { BaseNode, MetadataMode } from "../../Node.js";
|
||||
import type { BaseNode } from "../../Node.js";
|
||||
import { MetadataMode } from "../../Node.js";
|
||||
|
||||
export type NodeFormatterFunction = (summaryNodes: BaseNode[]) => string;
|
||||
export const defaultFormatNodeBatchFn: NodeFormatterFunction = (
|
||||
|
||||
@@ -1,42 +1,45 @@
|
||||
import { globalsHelper } from "../../GlobalsHelper.js";
|
||||
import {
|
||||
import type {
|
||||
BaseNode,
|
||||
Document,
|
||||
ImageNode,
|
||||
Metadata,
|
||||
MetadataMode,
|
||||
NodeWithScore,
|
||||
} from "../../Node.js";
|
||||
import {
|
||||
ImageNode,
|
||||
MetadataMode,
|
||||
ObjectType,
|
||||
splitNodesByType,
|
||||
} from "../../Node.js";
|
||||
import { BaseRetriever } from "../../Retriever.js";
|
||||
import {
|
||||
ServiceContext,
|
||||
serviceContextFromDefaults,
|
||||
} from "../../ServiceContext.js";
|
||||
import { Event } from "../../callbacks/CallbackManager.js";
|
||||
import type { BaseRetriever } from "../../Retriever.js";
|
||||
import type { ServiceContext } from "../../ServiceContext.js";
|
||||
import { serviceContextFromDefaults } from "../../ServiceContext.js";
|
||||
import type { Event } from "../../callbacks/CallbackManager.js";
|
||||
import { DEFAULT_SIMILARITY_TOP_K } from "../../constants.js";
|
||||
import {
|
||||
import type {
|
||||
BaseEmbedding,
|
||||
ClipEmbedding,
|
||||
MultiModalEmbedding,
|
||||
} from "../../embeddings/index.js";
|
||||
import { ClipEmbedding } from "../../embeddings/index.js";
|
||||
import { RetrieverQueryEngine } from "../../engines/query/RetrieverQueryEngine.js";
|
||||
import { runTransformations } from "../../ingestion/index.js";
|
||||
import { BaseNodePostprocessor } from "../../postprocessors/types.js";
|
||||
import {
|
||||
import type { BaseNodePostprocessor } from "../../postprocessors/types.js";
|
||||
import type {
|
||||
BaseIndexStore,
|
||||
MetadataFilters,
|
||||
StorageContext,
|
||||
VectorStore,
|
||||
VectorStoreQuery,
|
||||
VectorStoreQueryMode,
|
||||
VectorStoreQueryResult,
|
||||
} from "../../storage/index.js";
|
||||
import {
|
||||
VectorStoreQueryMode,
|
||||
storageContextFromDefaults,
|
||||
} from "../../storage/index.js";
|
||||
import { BaseSynthesizer } from "../../synthesizers/types.js";
|
||||
import { BaseQueryEngine } from "../../types.js";
|
||||
import { BaseIndex, BaseIndexInit } from "../BaseIndex.js";
|
||||
import type { BaseSynthesizer } from "../../synthesizers/types.js";
|
||||
import type { BaseQueryEngine } from "../../types.js";
|
||||
import type { BaseIndexInit } from "../BaseIndex.js";
|
||||
import { BaseIndex } from "../BaseIndex.js";
|
||||
import { IndexDict, IndexStructType } from "../json-to-index-struct.js";
|
||||
|
||||
interface IndexStructOptions {
|
||||
@@ -189,15 +192,12 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
|
||||
) {
|
||||
// Check if the index already has nodes with the same hash
|
||||
const newNodes = nodes.filter((node) =>
|
||||
Object.entries(this.indexStruct!.nodesDict).reduce(
|
||||
(acc, [key, value]) => {
|
||||
if (value.hash === node.hash) {
|
||||
acc = false;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
true,
|
||||
),
|
||||
Object.entries(this.indexStruct.nodesDict).reduce((acc, [key, value]) => {
|
||||
if (value.hash === node.hash) {
|
||||
acc = false;
|
||||
}
|
||||
return acc;
|
||||
}, true),
|
||||
);
|
||||
|
||||
await this.insertNodes(newNodes, options);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { createSHA256 } from "@llamaindex/env";
|
||||
import { BaseNode, MetadataMode } from "../Node.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import { MetadataMode } from "../Node.js";
|
||||
import { docToJson, jsonToDoc } from "../storage/docStore/utils.js";
|
||||
import { SimpleKVStore } from "../storage/kvStore/SimpleKVStore.js";
|
||||
import { BaseKVStore } from "../storage/kvStore/types.js";
|
||||
import { TransformComponent } from "./types.js";
|
||||
import type { BaseKVStore } from "../storage/kvStore/types.js";
|
||||
import type { TransformComponent } from "./types.js";
|
||||
|
||||
const transformToJSON = (obj: TransformComponent) => {
|
||||
const seen: any[] = [];
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { BaseNode, Document } from "../Node.js";
|
||||
import { BaseReader } from "../readers/type.js";
|
||||
import { BaseDocumentStore } from "../storage/docStore/types.js";
|
||||
import { VectorStore } from "../storage/vectorStore/types.js";
|
||||
import type { BaseNode, Document } from "../Node.js";
|
||||
import type { BaseReader } from "../readers/type.js";
|
||||
import type { BaseDocumentStore } from "../storage/docStore/types.js";
|
||||
import type { VectorStore } from "../storage/vectorStore/types.js";
|
||||
import { IngestionCache, getTransformationHash } from "./IngestionCache.js";
|
||||
import {
|
||||
DocStoreStrategy,
|
||||
createDocStoreStrategy,
|
||||
} from "./strategies/index.js";
|
||||
import { TransformComponent } from "./types.js";
|
||||
import type { TransformComponent } from "./types.js";
|
||||
|
||||
type IngestionRunArgs = {
|
||||
documents?: Document[];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BaseNode } from "../../Node.js";
|
||||
import { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
import { TransformComponent } from "../types.js";
|
||||
import type { BaseNode } from "../../Node.js";
|
||||
import type { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
import type { TransformComponent } from "../types.js";
|
||||
|
||||
/**
|
||||
* Handle doc store duplicates by checking all hashes.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BaseNode } from "../../Node.js";
|
||||
import { BaseDocumentStore, VectorStore } from "../../storage/index.js";
|
||||
import type { BaseNode } from "../../Node.js";
|
||||
import type { BaseDocumentStore, VectorStore } from "../../storage/index.js";
|
||||
import { classify } from "./classify.js";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BaseNode } from "../../Node.js";
|
||||
import { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
import { VectorStore } from "../../storage/vectorStore/types.js";
|
||||
import { TransformComponent } from "../types.js";
|
||||
import type { BaseNode } from "../../Node.js";
|
||||
import type { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
import type { VectorStore } from "../../storage/vectorStore/types.js";
|
||||
import type { TransformComponent } from "../types.js";
|
||||
import { classify } from "./classify.js";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BaseNode } from "../../Node.js";
|
||||
import { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
import type { BaseNode } from "../../Node.js";
|
||||
import type { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
|
||||
export async function classify(docStore: BaseDocumentStore, nodes: BaseNode[]) {
|
||||
const existingDocIds = Object.values(await docStore.getAllDocumentHashes());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
import { VectorStore } from "../../storage/vectorStore/types.js";
|
||||
import { TransformComponent } from "../types.js";
|
||||
import type { BaseDocumentStore } from "../../storage/docStore/types.js";
|
||||
import type { VectorStore } from "../../storage/vectorStore/types.js";
|
||||
import type { TransformComponent } from "../types.js";
|
||||
import { DuplicatesStrategy } from "./DuplicatesStrategy.js";
|
||||
import { UpsertsStrategy } from "./UpsertsStrategy.js";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseNode } from "../Node.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
|
||||
export interface TransformComponent {
|
||||
transform(nodes: BaseNode[], options?: any): Promise<BaseNode[]>;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import OpenAILLM, { ClientOptions as OpenAIClientOptions } from "openai";
|
||||
import {
|
||||
import type OpenAILLM from "openai";
|
||||
import type { ClientOptions as OpenAIClientOptions } from "openai";
|
||||
import type {
|
||||
AnthropicStreamToken,
|
||||
CallbackManager,
|
||||
Event,
|
||||
@@ -8,27 +9,29 @@ import {
|
||||
StreamCallbackResponse,
|
||||
} from "../callbacks/CallbackManager.js";
|
||||
|
||||
import { ChatCompletionMessageParam } from "openai/resources/index.js";
|
||||
import { LLMOptions } from "portkey-ai";
|
||||
import type { ChatCompletionMessageParam } from "openai/resources/index.js";
|
||||
import type { LLMOptions } from "portkey-ai";
|
||||
import { Tokenizers, globalsHelper } from "../GlobalsHelper.js";
|
||||
import type { AnthropicSession } from "./anthropic.js";
|
||||
import {
|
||||
ANTHROPIC_AI_PROMPT,
|
||||
ANTHROPIC_HUMAN_PROMPT,
|
||||
AnthropicSession,
|
||||
getAnthropicSession,
|
||||
} from "./anthropic.js";
|
||||
import type { AzureOpenAIConfig } from "./azure.js";
|
||||
import {
|
||||
AzureOpenAIConfig,
|
||||
getAzureBaseUrl,
|
||||
getAzureConfigFromEnv,
|
||||
getAzureModel,
|
||||
shouldUseAzure,
|
||||
} from "./azure.js";
|
||||
import { BaseLLM } from "./base.js";
|
||||
import { OpenAISession, getOpenAISession } from "./open_ai.js";
|
||||
import { PortkeySession, getPortkeySession } from "./portkey.js";
|
||||
import type { OpenAISession } from "./open_ai.js";
|
||||
import { getOpenAISession } from "./open_ai.js";
|
||||
import type { PortkeySession } from "./portkey.js";
|
||||
import { getPortkeySession } from "./portkey.js";
|
||||
import { ReplicateSession } from "./replicate_ai.js";
|
||||
import {
|
||||
import type {
|
||||
ChatMessage,
|
||||
ChatResponse,
|
||||
ChatResponseChunk,
|
||||
@@ -313,7 +316,7 @@ export class OpenAI extends BaseLLM {
|
||||
|
||||
// TODO: add callback to streamConverter and use streamConverter here
|
||||
//Indices
|
||||
var idx_counter: number = 0;
|
||||
let idx_counter: number = 0;
|
||||
for await (const part of chunk_stream) {
|
||||
if (!part.choices.length) continue;
|
||||
|
||||
@@ -732,7 +735,7 @@ export class Anthropic extends BaseLLM {
|
||||
stream: true,
|
||||
});
|
||||
|
||||
var idx_counter: number = 0;
|
||||
let idx_counter: number = 0;
|
||||
for await (const part of stream) {
|
||||
//TODO: LLM Stream Callback, pending re-work.
|
||||
|
||||
@@ -821,7 +824,7 @@ export class Portkey extends BaseLLM {
|
||||
};
|
||||
|
||||
//Indices
|
||||
var idx_counter: number = 0;
|
||||
let idx_counter: number = 0;
|
||||
for await (const part of chunkStream) {
|
||||
//Increment
|
||||
part.choices[0].index = idx_counter;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import Anthropic, {
|
||||
AI_PROMPT,
|
||||
ClientOptions,
|
||||
HUMAN_PROMPT,
|
||||
} from "@anthropic-ai/sdk";
|
||||
import type { ClientOptions } from "@anthropic-ai/sdk";
|
||||
import Anthropic, { AI_PROMPT, HUMAN_PROMPT } from "@anthropic-ai/sdk";
|
||||
import _ from "lodash";
|
||||
|
||||
export class AnthropicSession {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {
|
||||
import type {
|
||||
ChatMessage,
|
||||
ChatResponse,
|
||||
ChatResponseChunk,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
import type {
|
||||
CallbackManager,
|
||||
Event,
|
||||
EventType,
|
||||
StreamCallbackResponse,
|
||||
} from "../callbacks/CallbackManager.js";
|
||||
import { BaseLLM } from "./base.js";
|
||||
import {
|
||||
import type {
|
||||
ChatMessage,
|
||||
ChatResponse,
|
||||
ChatResponseChunk,
|
||||
@@ -141,7 +141,7 @@ export class MistralAI extends BaseLLM {
|
||||
};
|
||||
|
||||
//Indices
|
||||
var idx_counter: number = 0;
|
||||
let idx_counter: number = 0;
|
||||
for await (const part of chunkStream) {
|
||||
if (!part.choices.length) continue;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ok } from "@llamaindex/env";
|
||||
import { CallbackManager, Event } from "../callbacks/CallbackManager.js";
|
||||
import type { CallbackManager, Event } from "../callbacks/CallbackManager.js";
|
||||
import { BaseEmbedding } from "../embeddings/types.js";
|
||||
import {
|
||||
import type {
|
||||
ChatMessage,
|
||||
ChatResponse,
|
||||
ChatResponseChunk,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import OpenAI, { ClientOptions } from "openai";
|
||||
import type { ClientOptions } from "openai";
|
||||
import OpenAI from "openai";
|
||||
|
||||
export class AzureOpenAI extends OpenAI {
|
||||
protected override authHeaders() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import { LLMOptions, Portkey } from "portkey-ai";
|
||||
import type { LLMOptions } from "portkey-ai";
|
||||
import { Portkey } from "portkey-ai";
|
||||
|
||||
export const readEnv = (
|
||||
env: string,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Tokenizers } from "../GlobalsHelper.js";
|
||||
import { Event } from "../callbacks/CallbackManager.js";
|
||||
import type { Tokenizers } from "../GlobalsHelper.js";
|
||||
import type { Event } from "../callbacks/CallbackManager.js";
|
||||
|
||||
/**
|
||||
* Unified language model interface
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MessageContent, MessageContentDetail } from "./types.js";
|
||||
import type { MessageContent } from "./types.js";
|
||||
|
||||
export async function* streamConverter<S, D>(
|
||||
stream: AsyncIterable<S>,
|
||||
@@ -35,7 +35,7 @@ export function extractText(message: MessageContent): string {
|
||||
if (Array.isArray(message)) {
|
||||
// message is of type MessageContentDetail[] - retrieve just the text parts and concatenate them
|
||||
// so we can pass them to the context generator
|
||||
return (message as MessageContentDetail[])
|
||||
return message
|
||||
.filter((c) => c.type === "text")
|
||||
.map((c) => c.text)
|
||||
.join("\n\n");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChatMessage } from "../llm/index.js";
|
||||
import type { ChatMessage } from "../llm/index.js";
|
||||
import { SimpleChatStore } from "../storage/chatStore/SimpleChatStore.js";
|
||||
import { BaseChatStore } from "../storage/chatStore/types.js";
|
||||
import { BaseMemory } from "./types.js";
|
||||
import type { BaseChatStore } from "../storage/chatStore/types.js";
|
||||
import type { BaseMemory } from "./types.js";
|
||||
|
||||
type ChatMemoryBufferParams = {
|
||||
tokenLimit?: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChatMessage } from "../llm/index.js";
|
||||
import type { ChatMessage } from "../llm/index.js";
|
||||
|
||||
export interface BaseMemory {
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BaseNode, Metadata, MetadataMode, TextNode } from "../Node.js";
|
||||
import { NodeParser } from "./types.js";
|
||||
import type { BaseNode, Metadata } from "../Node.js";
|
||||
import { MetadataMode, TextNode } from "../Node.js";
|
||||
import type { NodeParser } from "./types.js";
|
||||
|
||||
export class MarkdownNodeParser implements NodeParser {
|
||||
includeMetadata: boolean;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BaseNode } from "../Node.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import { SentenceSplitter } from "../TextSplitter.js";
|
||||
import { NodeParser } from "./types.js";
|
||||
import type { NodeParser } from "./types.js";
|
||||
import { getNodesFromDocument } from "./utils.js";
|
||||
|
||||
export const DEFAULT_WINDOW_SIZE = 3;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BaseNode } from "../Node.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import { SentenceSplitter } from "../TextSplitter.js";
|
||||
import { DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE } from "../constants.js";
|
||||
import { NodeParser } from "./types.js";
|
||||
import type { NodeParser } from "./types.js";
|
||||
import { getNodesFromDocument } from "./utils.js";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BaseNode } from "../Node.js";
|
||||
import { TransformComponent } from "../ingestion/types.js";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import type { TransformComponent } from "../ingestion/types.js";
|
||||
|
||||
/**
|
||||
* A NodeParser generates Nodes from Documents
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import type { BaseNode } from "../Node.js";
|
||||
import {
|
||||
BaseNode,
|
||||
Document,
|
||||
ImageDocument,
|
||||
NodeRelationship,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { BaseNode, Metadata, TextNode } from "../Node.js";
|
||||
import { BaseRetriever } from "../Retriever.js";
|
||||
import { VectorStoreIndex } from "../indices/index.js";
|
||||
import { BaseTool } from "../types.js";
|
||||
import type { BaseNode, Metadata } from "../Node.js";
|
||||
import { TextNode } from "../Node.js";
|
||||
import type { BaseRetriever } from "../Retriever.js";
|
||||
import type { VectorStoreIndex } from "../indices/index.js";
|
||||
import type { BaseTool } from "../types.js";
|
||||
|
||||
// Assuming that necessary interfaces and classes (like OT, TextNode, BaseNode, etc.) are defined elsewhere
|
||||
// Import statements (e.g., for TextNode, BaseNode) should be added based on your project's structure
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { parseJsonMarkdown } from "../OutputParser.js";
|
||||
import { BaseOutputParser, StructuredOutput } from "../types.js";
|
||||
import type { BaseOutputParser, StructuredOutput } from "../types.js";
|
||||
|
||||
export type Answer = {
|
||||
choice: number;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MetadataMode, NodeWithScore } from "../Node.js";
|
||||
import { BaseNodePostprocessor } from "./types.js";
|
||||
import type { NodeWithScore } from "../Node.js";
|
||||
import { MetadataMode } from "../Node.js";
|
||||
import type { BaseNodePostprocessor } from "./types.js";
|
||||
|
||||
export class MetadataReplacementPostProcessor implements BaseNodePostprocessor {
|
||||
targetMetadataKey: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeWithScore } from "../Node.js";
|
||||
import { BaseNodePostprocessor } from "./types.js";
|
||||
import type { NodeWithScore } from "../Node.js";
|
||||
import type { BaseNodePostprocessor } from "./types.js";
|
||||
|
||||
export class SimilarityPostprocessor implements BaseNodePostprocessor {
|
||||
similarityCutoff?: number;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { CohereClient } from "cohere-ai";
|
||||
|
||||
import { MetadataMode, NodeWithScore } from "../../Node.js";
|
||||
import { BaseNodePostprocessor } from "../types.js";
|
||||
import type { NodeWithScore } from "../../Node.js";
|
||||
import { MetadataMode } from "../../Node.js";
|
||||
import type { BaseNodePostprocessor } from "../types.js";
|
||||
|
||||
type CohereRerankOptions = {
|
||||
topN?: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NodeWithScore } from "../Node.js";
|
||||
import type { NodeWithScore } from "../Node.js";
|
||||
|
||||
export interface BaseNodePostprocessor {
|
||||
/**
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {
|
||||
AssemblyAI,
|
||||
import type {
|
||||
BaseServiceParams,
|
||||
SubtitleFormat,
|
||||
TranscribeParams,
|
||||
TranscriptParagraph,
|
||||
TranscriptSentence,
|
||||
} from "assemblyai";
|
||||
import { AssemblyAI } from "assemblyai";
|
||||
import { Document } from "../Node.js";
|
||||
import { BaseReader } from "./type.js";
|
||||
import type { BaseReader } from "./type.js";
|
||||
|
||||
type AssemblyAIOptions = Partial<BaseServiceParams>;
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { defaultFS } from "@llamaindex/env";
|
||||
import { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import Papa, { ParseConfig } from "papaparse";
|
||||
import type { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import type { ParseConfig } from "papaparse";
|
||||
import Papa from "papaparse";
|
||||
import { Document } from "../Node.js";
|
||||
import { FileReader } from "./type.js";
|
||||
import type { FileReader } from "./type.js";
|
||||
|
||||
/**
|
||||
* papaparse-based csv parser
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { defaultFS } from "@llamaindex/env";
|
||||
import { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import type { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import mammoth from "mammoth";
|
||||
import { Document } from "../Node.js";
|
||||
import { FileReader } from "./type.js";
|
||||
import type { FileReader } from "./type.js";
|
||||
|
||||
export class DocxReader implements FileReader {
|
||||
/** DocxParser */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defaultFS } from "@llamaindex/env";
|
||||
import { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import type { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import { Document } from "../Node.js";
|
||||
import { FileReader } from "./type.js";
|
||||
import type { FileReader } from "./type.js";
|
||||
|
||||
/**
|
||||
* Extract the significant text from an arbitrary HTML document.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { defaultFS } from "@llamaindex/env";
|
||||
import { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import { Document, ImageDocument } from "../Node.js";
|
||||
import { FileReader } from "./type.js";
|
||||
import type { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import type { Document } from "../Node.js";
|
||||
import { ImageDocument } from "../Node.js";
|
||||
import type { FileReader } from "./type.js";
|
||||
|
||||
/**
|
||||
* Reads the content of an image file into a Document object (which stores the image file as a Blob).
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defaultFS } from "@llamaindex/env";
|
||||
import { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import type { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import { Document } from "../Node.js";
|
||||
import { FileReader } from "./type.js";
|
||||
import type { FileReader } from "./type.js";
|
||||
|
||||
type ResultType = "text" | "markdown";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defaultFS } from "@llamaindex/env";
|
||||
import { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import type { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import { Document } from "../Node.js";
|
||||
import { FileReader } from "./type.js";
|
||||
import type { FileReader } from "./type.js";
|
||||
|
||||
type MarkdownTuple = [string | null, string];
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Client } from "@notionhq/client";
|
||||
import { crawler, Crawler, Pages, pageToString } from "notion-md-crawler";
|
||||
import type { Client } from "@notionhq/client";
|
||||
import type { Crawler, Pages } from "notion-md-crawler";
|
||||
import { crawler, pageToString } from "notion-md-crawler";
|
||||
import { Document } from "../Node.js";
|
||||
import { BaseReader } from "./type.js";
|
||||
import type { BaseReader } from "./type.js";
|
||||
|
||||
type OptionalSerializers = Parameters<Crawler>[number]["serializers"];
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createSHA256, defaultFS } from "@llamaindex/env";
|
||||
import { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import type { GenericFileSystem } from "@llamaindex/env/type";
|
||||
import { Document } from "../Node.js";
|
||||
import { BaseReader } from "./type.js";
|
||||
import type { BaseReader } from "./type.js";
|
||||
|
||||
/**
|
||||
* Read the text of a PDF
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defaultFS, path } from "@llamaindex/env";
|
||||
import { CompleteFileSystem } from "@llamaindex/env/type";
|
||||
import type { CompleteFileSystem } from "@llamaindex/env/type";
|
||||
import { Document } from "../Node.js";
|
||||
import { walk } from "../storage/FileSystem.js";
|
||||
import { PapaCSVReader } from "./CSVReader.js";
|
||||
@@ -8,7 +8,7 @@ import { HTMLReader } from "./HTMLReader.js";
|
||||
import { ImageReader } from "./ImageReader.js";
|
||||
import { MarkdownReader } from "./MarkdownReader.js";
|
||||
import { PDFReader } from "./PDFReader.js";
|
||||
import { BaseReader } from "./type.js";
|
||||
import type { BaseReader } from "./type.js";
|
||||
|
||||
type ReaderCallback = (
|
||||
category: "file" | "directory",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { MongoClient } from "mongodb";
|
||||
import { Document, Metadata } from "../Node.js";
|
||||
import { BaseReader } from "./type.js";
|
||||
import type { MongoClient } from "mongodb";
|
||||
import type { Metadata } from "../Node.js";
|
||||
import { Document } from "../Node.js";
|
||||
import type { BaseReader } from "./type.js";
|
||||
|
||||
/**
|
||||
* Read in from MongoDB
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CompleteFileSystem } from "@llamaindex/env/type";
|
||||
import { Document } from "../Node.js";
|
||||
import type { CompleteFileSystem } from "@llamaindex/env/type";
|
||||
import type { Document } from "../Node.js";
|
||||
|
||||
/**
|
||||
* A reader takes imports data into Document objects.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PromptMixin } from "../prompts/Mixin.js";
|
||||
import { QueryBundle, ToolMetadataOnlyDescription } from "../types.js";
|
||||
import type { QueryBundle, ToolMetadataOnlyDescription } from "../types.js";
|
||||
|
||||
export interface SingleSelection {
|
||||
index: number;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { LLM } from "../llm/index.js";
|
||||
import { Answer, SelectionOutputParser } from "../outputParsers/selectors.js";
|
||||
import {
|
||||
import type { LLM } from "../llm/index.js";
|
||||
import type { Answer } from "../outputParsers/selectors.js";
|
||||
import { SelectionOutputParser } from "../outputParsers/selectors.js";
|
||||
import type {
|
||||
BaseOutputParser,
|
||||
QueryBundle,
|
||||
StructuredOutput,
|
||||
ToolMetadataOnlyDescription,
|
||||
} from "../types.js";
|
||||
import { BaseSelector, SelectorResult } from "./base.js";
|
||||
import type { SelectorResult } from "./base.js";
|
||||
import { BaseSelector } from "./base.js";
|
||||
import type { MultiSelectPrompt, SingleSelectPrompt } from "./prompts.js";
|
||||
import {
|
||||
MultiSelectPrompt,
|
||||
SingleSelectPrompt,
|
||||
defaultMultiSelectPrompt,
|
||||
defaultSingleSelectPrompt,
|
||||
} from "./prompts.js";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ServiceContext } from "../ServiceContext.js";
|
||||
import { BaseSelector } from "./base.js";
|
||||
import type { ServiceContext } from "../ServiceContext.js";
|
||||
import type { BaseSelector } from "./base.js";
|
||||
import { LLMMultiSelector, LLMSingleSelector } from "./llmSelectors.js";
|
||||
|
||||
export const getSelectorFromContext = (
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user