From 9a5525e1b3adc6c828af65dcdac7edd804ebaa7d Mon Sep 17 00:00:00 2001 From: Alex Yang <himself65@outlook.com> Date: Mon, 1 Jul 2024 20:13:35 -0700 Subject: [PATCH] refactor(core): migrate llms type (#1002) --- packages/core/package.json | 15 ++ packages/core/src/global/type.ts | 9 + packages/core/src/index.ts | 1 - packages/core/src/llms/index.ts | 31 +++ packages/core/src/llms/type.ts | 245 ++++++++++++++++++ packages/core/src/schema/zod.ts | 4 +- .../nextjs-agent/src/actions/index.tsx | 2 +- .../llamaindex/e2e/fixtures/llm/openai.ts | 2 +- packages/llamaindex/src/ChatHistory.ts | 2 +- packages/llamaindex/src/EngineResponse.ts | 4 +- packages/llamaindex/src/Prompt.ts | 3 +- packages/llamaindex/src/QuestionGenerator.ts | 8 +- packages/llamaindex/src/ServiceContext.ts | 2 +- packages/llamaindex/src/Settings.ts | 2 +- packages/llamaindex/src/agent/base.ts | 25 +- packages/llamaindex/src/agent/llm.ts | 3 +- packages/llamaindex/src/agent/react.ts | 15 +- packages/llamaindex/src/agent/types.ts | 12 +- packages/llamaindex/src/agent/utils.ts | 36 +-- .../src/callbacks/CallbackManager.ts | 2 +- .../src/embeddings/DeepInfraEmbedding.ts | 2 +- .../src/embeddings/MultiModalEmbedding.ts | 2 +- packages/llamaindex/src/embeddings/types.ts | 2 +- .../chat/CondenseQuestionChatEngine.ts | 2 +- .../src/engines/chat/ContextChatEngine.ts | 8 +- .../engines/chat/DefaultContextGenerator.ts | 6 +- .../src/engines/chat/SimpleChatEngine.ts | 2 +- packages/llamaindex/src/engines/chat/types.ts | 3 +- .../engines/query/SubQuestionQueryEngine.ts | 3 +- .../llamaindex/src/engines/query/types.ts | 2 +- .../llamaindex/src/evaluation/Correctness.ts | 6 +- .../src/extractors/MetadataExtractors.ts | 2 +- packages/llamaindex/src/index.edge.ts | 1 + .../llamaindex/src/indices/keyword/index.ts | 2 +- .../src/indices/vectorStore/index.ts | 2 +- .../llamaindex/src/internal/prompt/react.ts | 2 +- packages/llamaindex/src/llm/anthropic.ts | 10 +- packages/llamaindex/src/llm/base.ts | 2 +- packages/llamaindex/src/llm/gemini/base.ts | 6 +- packages/llamaindex/src/llm/gemini/types.ts | 2 +- packages/llamaindex/src/llm/gemini/utils.ts | 4 +- packages/llamaindex/src/llm/gemini/vertex.ts | 4 +- packages/llamaindex/src/llm/huggingface.ts | 16 +- packages/llamaindex/src/llm/mistral.ts | 10 +- packages/llamaindex/src/llm/ollama.ts | 22 +- packages/llamaindex/src/llm/openai.ts | 26 +- packages/llamaindex/src/llm/portkey.ts | 16 +- packages/llamaindex/src/llm/replicate_ai.ts | 8 +- packages/llamaindex/src/llm/types.ts | 205 +-------------- packages/llamaindex/src/llm/utils.ts | 8 +- .../llamaindex/src/memory/ChatMemoryBuffer.ts | 2 +- packages/llamaindex/src/memory/types.ts | 2 +- packages/llamaindex/src/objects/base.ts | 3 +- .../postprocessors/rerankers/CohereRerank.ts | 2 +- .../rerankers/JinaAIReranker.ts | 2 +- .../llamaindex/src/postprocessors/types.ts | 2 +- .../llamaindex/src/selectors/llmSelectors.ts | 2 +- .../src/storage/chatStore/SimpleChatStore.ts | 2 +- .../llamaindex/src/storage/chatStore/types.ts | 2 +- .../llamaindex/src/synthesizers/builders.ts | 2 +- packages/llamaindex/src/synthesizers/utils.ts | 2 +- .../src/tools/AzureDynamicSessionTool.node.ts | 2 +- .../llamaindex/src/tools/QueryEngineTool.ts | 3 +- .../llamaindex/src/tools/WikipediaTool.ts | 2 +- packages/llamaindex/src/tools/functionTool.ts | 3 +- packages/llamaindex/src/types.ts | 50 +--- .../llamaindex/tests/utility/mockOpenAI.ts | 2 +- pnpm-lock.yaml | 60 ++++- 68 files changed, 541 insertions(+), 413 deletions(-) create mode 100644 packages/core/src/global/type.ts delete mode 100644 packages/core/src/index.ts create mode 100644 packages/core/src/llms/index.ts create mode 100644 packages/core/src/llms/type.ts diff --git a/packages/core/package.json b/packages/core/package.json index f87dbf062..0bbb97a06 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -4,6 +4,20 @@ "version": "0.0.2", "description": "LlamaIndex Core Module", "exports": { + "./llms": { + "require": { + "types": "./dist/llms/index.d.cts", + "default": "./dist/llms/index.cjs" + }, + "import": { + "types": "./dist/llms/index.d.ts", + "default": "./dist/llms/index.js" + }, + "default": { + "types": "./dist/llms/index.d.ts", + "default": "./dist/llms/index.js" + } + }, "./decorator": { "require": { "types": "./dist/decorator/index.d.cts", @@ -60,6 +74,7 @@ "url": "https://github.com/himself65/LlamaIndexTS.git" }, "devDependencies": { + "ajv": "^8.16.0", "bunchee": "^5.2.1" }, "dependencies": { diff --git a/packages/core/src/global/type.ts b/packages/core/src/global/type.ts new file mode 100644 index 000000000..07df3d621 --- /dev/null +++ b/packages/core/src/global/type.ts @@ -0,0 +1,9 @@ +export type UUID = `${string}-${string}-${string}-${string}-${string}`; + +export type JSONValue = string | number | boolean | JSONObject | JSONArray; + +export type JSONObject = { + [key: string]: JSONValue; +}; + +export type JSONArray = Array<JSONValue>; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts deleted file mode 100644 index 686fbd9e9..000000000 --- a/packages/core/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./schema"; diff --git a/packages/core/src/llms/index.ts b/packages/core/src/llms/index.ts new file mode 100644 index 000000000..c387fe087 --- /dev/null +++ b/packages/core/src/llms/index.ts @@ -0,0 +1,31 @@ +export type { + BaseTool, + BaseToolWithCall, + ChatMessage, + ChatResponse, + ChatResponseChunk, + CompletionResponse, + LLM, + LLMChat, + LLMChatParamsBase, + LLMChatParamsNonStreaming, + LLMChatParamsStreaming, + LLMCompletionParamsBase, + LLMCompletionParamsNonStreaming, + LLMCompletionParamsStreaming, + LLMMetadata, + MessageContent, + MessageContentDetail, + MessageContentImageDetail, + MessageContentTextDetail, + MessageType, + PartialToolCall, + TextChatMessage, + ToolCall, + ToolCallLLMMessageOptions, + ToolCallOptions, + ToolMetadata, + ToolOutput, + ToolResult, + ToolResultOptions, +} from "./type"; diff --git a/packages/core/src/llms/type.ts b/packages/core/src/llms/type.ts new file mode 100644 index 000000000..cffe627f8 --- /dev/null +++ b/packages/core/src/llms/type.ts @@ -0,0 +1,245 @@ +import type { Tokenizers } from "@llamaindex/env"; +import type { JSONSchemaType } from "ajv"; +import type { JSONObject, JSONValue } from "../global/type"; + +/** + * @internal + */ +export interface LLMChat< + AdditionalChatOptions extends object = object, + AdditionalMessageOptions extends object = object, +> { + chat( + params: + | LLMChatParamsStreaming<AdditionalChatOptions> + | LLMChatParamsNonStreaming<AdditionalChatOptions>, + ): Promise< + | ChatResponse<AdditionalMessageOptions> + | AsyncIterable<ChatResponseChunk<AdditionalMessageOptions>> + >; +} + +/** + * Unified language model interface + */ +export interface LLM< + AdditionalChatOptions extends object = object, + AdditionalMessageOptions extends object = object, +> extends LLMChat<AdditionalChatOptions> { + metadata: LLMMetadata; + /** + * Get a chat response from the LLM + */ + chat( + params: LLMChatParamsStreaming< + AdditionalChatOptions, + AdditionalMessageOptions + >, + ): Promise<AsyncIterable<ChatResponseChunk>>; + chat( + params: LLMChatParamsNonStreaming< + AdditionalChatOptions, + AdditionalMessageOptions + >, + ): Promise<ChatResponse<AdditionalMessageOptions>>; + + /** + * Get a prompt completion from the LLM + */ + complete( + params: LLMCompletionParamsStreaming, + ): Promise<AsyncIterable<CompletionResponse>>; + complete( + params: LLMCompletionParamsNonStreaming, + ): Promise<CompletionResponse>; +} + +export type MessageType = "user" | "assistant" | "system" | "memory"; + +export type TextChatMessage<AdditionalMessageOptions extends object = object> = + { + content: string; + role: MessageType; + options?: undefined | AdditionalMessageOptions; + }; + +export type ChatMessage<AdditionalMessageOptions extends object = object> = { + content: MessageContent; + role: MessageType; + options?: undefined | AdditionalMessageOptions; +}; + +export interface ChatResponse< + AdditionalMessageOptions extends object = object, +> { + message: ChatMessage<AdditionalMessageOptions>; + /** + * Raw response from the LLM + * + * If LLM response an iterable of chunks, this will be an array of those chunks + */ + raw: object | null; +} + +export type ChatResponseChunk< + AdditionalMessageOptions extends object = object, +> = { + raw: object | null; + delta: string; + options?: undefined | AdditionalMessageOptions; +}; + +export interface CompletionResponse { + text: string; + /** + * Raw response from the LLM + * + * It's possible that this is `null` if the LLM response an iterable of chunks + */ + raw: object | null; +} + +export type LLMMetadata = { + model: string; + temperature: number; + topP: number; + maxTokens?: number; + contextWindow: number; + tokenizer: Tokenizers | undefined; +}; + +export interface LLMChatParamsBase< + AdditionalChatOptions extends object = object, + AdditionalMessageOptions extends object = object, +> { + messages: ChatMessage<AdditionalMessageOptions>[]; + additionalChatOptions?: AdditionalChatOptions; + tools?: BaseTool[]; +} + +export interface LLMChatParamsStreaming< + AdditionalChatOptions extends object = object, + AdditionalMessageOptions extends object = object, +> extends LLMChatParamsBase<AdditionalChatOptions, AdditionalMessageOptions> { + stream: true; +} + +export interface LLMChatParamsNonStreaming< + AdditionalChatOptions extends object = object, + AdditionalMessageOptions extends object = object, +> extends LLMChatParamsBase<AdditionalChatOptions, AdditionalMessageOptions> { + stream?: false; +} + +export interface LLMCompletionParamsBase { + prompt: MessageContent; +} + +export interface LLMCompletionParamsStreaming extends LLMCompletionParamsBase { + stream: true; +} + +export interface LLMCompletionParamsNonStreaming + extends LLMCompletionParamsBase { + stream?: false | null; +} + +export type MessageContentTextDetail = { + type: "text"; + text: string; +}; + +export type MessageContentImageDetail = { + type: "image_url"; + image_url: { url: string }; +}; + +export type MessageContentDetail = + | MessageContentTextDetail + | MessageContentImageDetail; + +/** + * Extended type for the content of a message that allows for multi-modal messages. + */ +export type MessageContent = string | MessageContentDetail[]; + +export type ToolCall = { + name: string; + input: JSONObject; + id: string; +}; + +// happened in streaming response, the tool call is not ready yet +export type PartialToolCall = { + name: string; + id: string; + // input is not ready yet, JSON.parse(input) will throw an error + input: string; +}; + +export type ToolResult = { + id: string; + result: string; + isError: boolean; +}; + +export type ToolCallOptions = { + toolCall: (ToolCall | PartialToolCall)[]; +}; + +export type ToolResultOptions = { + toolResult: ToolResult; +}; + +export type ToolCallLLMMessageOptions = + | ToolResultOptions + | ToolCallOptions + | {}; + +type Known = + | { [key: string]: Known } + | [Known, ...Known[]] + | Known[] + | number + | string + | boolean + | null; + +export type ToolMetadata< + Parameters extends Record<string, unknown> = Record<string, unknown>, +> = { + description: string; + name: string; + /** + * OpenAI uses JSON Schema to describe the parameters that a tool can take. + * @link https://json-schema.org/understanding-json-schema + */ + parameters?: Parameters; +}; + +/** + * Simple Tool interface. Likely to change. + */ +export interface BaseTool<Input = any> { + /** + * This could be undefined if the implementation is not provided, + * which might be the case when communicating with a llm. + * + * @return {JSONValue | Promise<JSONValue>} The output of the tool. + */ + call?: (input: Input) => JSONValue | Promise<JSONValue>; + metadata: // if user input any, we cannot check the schema + Input extends Known ? ToolMetadata<JSONSchemaType<Input>> : ToolMetadata; +} + +export type BaseToolWithCall<Input = any> = Omit<BaseTool<Input>, "call"> & { + call: NonNullable<Pick<BaseTool<Input>, "call">["call"]>; +}; + +export type ToolOutput = { + tool: BaseTool | undefined; + // all of existing function calling LLMs only support object input + input: JSONObject; + output: JSONValue; + isError: boolean; +}; diff --git a/packages/core/src/schema/zod.ts b/packages/core/src/schema/zod.ts index 8ea21ba3d..94cd4d2a4 100644 --- a/packages/core/src/schema/zod.ts +++ b/packages/core/src/schema/zod.ts @@ -1,5 +1,7 @@ import { z } from "zod"; +export const anyFunctionSchema = z.function(z.tuple([]).rest(z.any()), z.any()); + export const toolMetadataSchema = z.object({ description: z.string(), name: z.string(), @@ -7,7 +9,7 @@ export const toolMetadataSchema = z.object({ }); export const baseToolSchema = z.object({ - call: z.optional(z.function()), + call: anyFunctionSchema.optional(), metadata: toolMetadataSchema, }); diff --git a/packages/llamaindex/e2e/examples/nextjs-agent/src/actions/index.tsx b/packages/llamaindex/e2e/examples/nextjs-agent/src/actions/index.tsx index b092fd0b8..b71e52a92 100644 --- a/packages/llamaindex/e2e/examples/nextjs-agent/src/actions/index.tsx +++ b/packages/llamaindex/e2e/examples/nextjs-agent/src/actions/index.tsx @@ -1,7 +1,7 @@ "use server"; import { createStreamableUI } from "ai/rsc"; +import type { ChatMessage } from "llamaindex"; import { OpenAIAgent } from "llamaindex"; -import type { ChatMessage } from "llamaindex/llm/types"; export async function chatWithAgent( question: string, diff --git a/packages/llamaindex/e2e/fixtures/llm/openai.ts b/packages/llamaindex/e2e/fixtures/llm/openai.ts index 045cc0855..30d8b2cdb 100644 --- a/packages/llamaindex/e2e/fixtures/llm/openai.ts +++ b/packages/llamaindex/e2e/fixtures/llm/openai.ts @@ -7,7 +7,7 @@ import type { LLMChatParamsStreaming, LLMCompletionParamsNonStreaming, LLMCompletionParamsStreaming, -} from "llamaindex/llm/types"; +} from "llamaindex"; import { extractText } from "llamaindex/llm/utils"; import { deepStrictEqual, strictEqual } from "node:assert"; import { llmCompleteMockStorage } from "../../node/utils.js"; diff --git a/packages/llamaindex/src/ChatHistory.ts b/packages/llamaindex/src/ChatHistory.ts index 7d0093e51..c6423b9e8 100644 --- a/packages/llamaindex/src/ChatHistory.ts +++ b/packages/llamaindex/src/ChatHistory.ts @@ -1,8 +1,8 @@ +import type { ChatMessage, LLM, MessageType } from "@llamaindex/core/llms"; import { tokenizers, type Tokenizer } from "@llamaindex/env"; import type { SummaryPrompt } from "./Prompt.js"; import { defaultSummaryPrompt, messagesToHistoryStr } from "./Prompt.js"; import { OpenAI } from "./llm/openai.js"; -import type { ChatMessage, LLM, MessageType } from "./llm/types.js"; import { extractText } from "./llm/utils.js"; /** diff --git a/packages/llamaindex/src/EngineResponse.ts b/packages/llamaindex/src/EngineResponse.ts index dc2a3b436..543f33f6b 100644 --- a/packages/llamaindex/src/EngineResponse.ts +++ b/packages/llamaindex/src/EngineResponse.ts @@ -1,9 +1,9 @@ -import type { NodeWithScore } from "@llamaindex/core/schema"; import type { ChatMessage, ChatResponse, ChatResponseChunk, -} from "./llm/types.js"; +} from "@llamaindex/core/llms"; +import type { NodeWithScore } from "@llamaindex/core/schema"; import { extractText } from "./llm/utils.js"; export class EngineResponse implements ChatResponse, ChatResponseChunk { diff --git a/packages/llamaindex/src/Prompt.ts b/packages/llamaindex/src/Prompt.ts index ef344bd17..0763df484 100644 --- a/packages/llamaindex/src/Prompt.ts +++ b/packages/llamaindex/src/Prompt.ts @@ -1,6 +1,5 @@ +import type { ChatMessage, ToolMetadata } from "@llamaindex/core/llms"; 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. diff --git a/packages/llamaindex/src/QuestionGenerator.ts b/packages/llamaindex/src/QuestionGenerator.ts index 74c350564..e3a190d4e 100644 --- a/packages/llamaindex/src/QuestionGenerator.ts +++ b/packages/llamaindex/src/QuestionGenerator.ts @@ -1,3 +1,4 @@ +import type { LLM, ToolMetadata } from "@llamaindex/core/llms"; import { SubQuestionOutputParser } from "./OutputParser.js"; import type { SubQuestionPrompt } from "./Prompt.js"; import { buildToolsText, defaultSubQuestionPrompt } from "./Prompt.js"; @@ -6,13 +7,8 @@ import type { SubQuestion, } from "./engines/query/types.js"; import { OpenAI } from "./llm/openai.js"; -import type { LLM } from "./llm/types.js"; import { PromptMixin } from "./prompts/index.js"; -import type { - BaseOutputParser, - StructuredOutput, - ToolMetadata, -} from "./types.js"; +import type { BaseOutputParser, StructuredOutput } from "./types.js"; /** * LLMQuestionGenerator uses the LLM to generate new questions for the LLM using tools and a user query. diff --git a/packages/llamaindex/src/ServiceContext.ts b/packages/llamaindex/src/ServiceContext.ts index 0686d2a0b..dfb3f8fa4 100644 --- a/packages/llamaindex/src/ServiceContext.ts +++ b/packages/llamaindex/src/ServiceContext.ts @@ -1,8 +1,8 @@ +import type { LLM } from "@llamaindex/core/llms"; import { PromptHelper } from "./PromptHelper.js"; import { OpenAIEmbedding } from "./embeddings/OpenAIEmbedding.js"; import type { BaseEmbedding } from "./embeddings/types.js"; import { OpenAI } from "./llm/openai.js"; -import type { LLM } from "./llm/types.js"; import { SimpleNodeParser } from "./nodeParsers/SimpleNodeParser.js"; import type { NodeParser } from "./nodeParsers/types.js"; diff --git a/packages/llamaindex/src/Settings.ts b/packages/llamaindex/src/Settings.ts index 32ae2156b..12513125d 100644 --- a/packages/llamaindex/src/Settings.ts +++ b/packages/llamaindex/src/Settings.ts @@ -5,6 +5,7 @@ import { OpenAI } from "./llm/openai.js"; import { PromptHelper } from "./PromptHelper.js"; import { SimpleNodeParser } from "./nodeParsers/SimpleNodeParser.js"; +import type { LLM } from "@llamaindex/core/llms"; import { AsyncLocalStorage, getEnv } from "@llamaindex/env"; import type { ServiceContext } from "./ServiceContext.js"; import type { BaseEmbedding } from "./embeddings/types.js"; @@ -18,7 +19,6 @@ import { setEmbeddedModel, withEmbeddedModel, } from "./internal/settings/EmbedModel.js"; -import type { LLM } from "./llm/types.js"; import type { NodeParser } from "./nodeParsers/types.js"; export type PromptConfig = { diff --git a/packages/llamaindex/src/agent/base.ts b/packages/llamaindex/src/agent/base.ts index 49692dc85..7d1eea8a9 100644 --- a/packages/llamaindex/src/agent/base.ts +++ b/packages/llamaindex/src/agent/base.ts @@ -1,3 +1,10 @@ +import type { + BaseToolWithCall, + ChatMessage, + LLM, + MessageContent, + ToolOutput, +} from "@llamaindex/core/llms"; import { ReadableStream, TransformStream, randomUUID } from "@llamaindex/env"; import { ChatHistory } from "../ChatHistory.js"; import { EngineResponse } from "../EngineResponse.js"; @@ -11,9 +18,7 @@ import { wrapEventCaller } from "../internal/context/EventCaller.js"; import { consoleLogger, emptyLogger } from "../internal/logger.js"; import { getCallbackManager } from "../internal/settings/CallbackManager.js"; import { isAsyncIterable } from "../internal/utils.js"; -import type { ChatMessage, LLM, MessageContent } from "../llm/index.js"; import { ObjectRetriever } from "../objects/index.js"; -import type { BaseToolWithCall, ToolOutput } from "../types.js"; import type { AgentTaskContext, TaskHandler, @@ -229,13 +234,12 @@ export abstract class AgentRunner< const { llm, getTools, stream } = step.context; const lastMessage = step.context.store.messages.at(-1)!.content; const tools = await getTools(lastMessage); - const response = await llm.chat({ - // @ts-expect-error - stream, - tools, - messages: [...step.context.store.messages], - }); if (!stream) { + const response = await llm.chat({ + stream, + tools, + messages: [...step.context.store.messages], + }); await stepTools<LLM>({ response, tools, @@ -243,6 +247,11 @@ export abstract class AgentRunner< enqueueOutput, }); } else { + const response = await llm.chat({ + stream, + tools, + messages: [...step.context.store.messages], + }); await stepToolsStreaming<LLM>({ response, tools, diff --git a/packages/llamaindex/src/agent/llm.ts b/packages/llamaindex/src/agent/llm.ts index 9e4295cbe..6292c1cd7 100644 --- a/packages/llamaindex/src/agent/llm.ts +++ b/packages/llamaindex/src/agent/llm.ts @@ -1,7 +1,6 @@ -import type { LLM } from "../llm/index.js"; +import type { BaseToolWithCall, LLM } from "@llamaindex/core/llms"; import { ObjectRetriever } from "../objects/index.js"; import { Settings } from "../Settings.js"; -import type { BaseToolWithCall } from "../types.js"; import { AgentRunner, AgentWorker, type AgentParamsBase } from "./base.js"; import { validateAgentParams } from "./utils.js"; diff --git a/packages/llamaindex/src/agent/react.ts b/packages/llamaindex/src/agent/react.ts index fabef84c4..51ade05ba 100644 --- a/packages/llamaindex/src/agent/react.ts +++ b/packages/llamaindex/src/agent/react.ts @@ -1,18 +1,19 @@ +import type { + BaseTool, + ChatMessage, + ChatResponse, + ChatResponseChunk, + LLM, +} from "@llamaindex/core/llms"; import { randomUUID, ReadableStream } from "@llamaindex/env"; import { getReACTAgentSystemHeader } from "../internal/prompt/react.js"; import { isAsyncIterable, stringifyJSONToMessageContent, } from "../internal/utils.js"; -import { - type ChatMessage, - type ChatResponse, - type ChatResponseChunk, - type LLM, -} from "../llm/index.js"; import { extractText } from "../llm/utils.js"; import { Settings } from "../Settings.js"; -import type { BaseTool, JSONObject, JSONValue } from "../types.js"; +import type { JSONObject, JSONValue } from "../types.js"; import { AgentRunner, AgentWorker, type AgentParamsBase } from "./base.js"; import type { TaskHandler } from "./types.js"; import { diff --git a/packages/llamaindex/src/agent/types.ts b/packages/llamaindex/src/agent/types.ts index 22d562c1a..45ec942b6 100644 --- a/packages/llamaindex/src/agent/types.ts +++ b/packages/llamaindex/src/agent/types.ts @@ -1,14 +1,16 @@ -import { ReadableStream } from "@llamaindex/env"; -import type { Logger } from "../internal/logger.js"; -import type { BaseEvent } from "../internal/type.js"; import type { + BaseToolWithCall, ChatMessage, ChatResponse, ChatResponseChunk, LLM, MessageContent, -} from "../llm/types.js"; -import type { BaseToolWithCall, ToolOutput, UUID } from "../types.js"; + ToolOutput, +} from "@llamaindex/core/llms"; +import { ReadableStream } from "@llamaindex/env"; +import type { Logger } from "../internal/logger.js"; +import type { BaseEvent } from "../internal/type.js"; +import type { UUID } from "../types.js"; export type AgentTaskContext< Model extends LLM, diff --git a/packages/llamaindex/src/agent/utils.ts b/packages/llamaindex/src/agent/utils.ts index d3a41b513..8bf49abc8 100644 --- a/packages/llamaindex/src/agent/utils.ts +++ b/packages/llamaindex/src/agent/utils.ts @@ -1,3 +1,15 @@ +import type { + BaseTool, + ChatMessage, + ChatResponse, + ChatResponseChunk, + LLM, + PartialToolCall, + TextChatMessage, + ToolCall, + ToolCallLLMMessageOptions, + ToolOutput, +} from "@llamaindex/core/llms"; import { baseToolWithCallSchema } from "@llamaindex/core/schema"; import { ReadableStream } from "@llamaindex/env"; import { z } from "zod"; @@ -8,17 +20,7 @@ import { prettifyError, stringifyJSONToMessageContent, } from "../internal/utils.js"; -import type { - ChatMessage, - ChatResponse, - ChatResponseChunk, - LLM, - PartialToolCall, - TextChatMessage, - ToolCall, - ToolCallLLMMessageOptions, -} from "../llm/index.js"; -import type { BaseTool, JSONObject, JSONValue, ToolOutput } from "../types.js"; +import type { JSONObject, JSONValue } from "../types.js"; import type { AgentParamsBase } from "./base.js"; import type { TaskHandler } from "./types.js"; @@ -31,10 +33,12 @@ type StepToolsResponseParams<Model extends LLM> = { >[1]; }; -type StepToolsStreamingResponseParams<Model extends LLM> = - StepToolsResponseParams<Model> & { - response: AsyncIterable<ChatResponseChunk<ToolCallLLMMessageOptions>>; - }; +type StepToolsStreamingResponseParams<Model extends LLM> = Omit< + StepToolsResponseParams<Model>, + "response" +> & { + response: AsyncIterable<ChatResponseChunk<ToolCallLLMMessageOptions>>; +}; // #TODO stepTools and stepToolsStreaming should be moved to a better abstraction @@ -83,7 +87,7 @@ export async function stepToolsStreaming<Model extends LLM>({ } } - // If there are toolCalls but they didn't get read into the stream, used for Gemini + // If there are toolCalls, but they didn't get read into the stream, used for Gemini if (!toolCalls.size && value.options && "toolCall" in value.options) { value.options.toolCall.forEach((toolCall) => { toolCalls.set(toolCall.id, toolCall); diff --git a/packages/llamaindex/src/callbacks/CallbackManager.ts b/packages/llamaindex/src/callbacks/CallbackManager.ts index a304c45fb..e37617245 100644 --- a/packages/llamaindex/src/callbacks/CallbackManager.ts +++ b/packages/llamaindex/src/callbacks/CallbackManager.ts @@ -1,4 +1,5 @@ import type { Anthropic } from "@anthropic-ai/sdk"; +import type { MessageContent } from "@llamaindex/core/llms"; import type { NodeWithScore } from "@llamaindex/core/schema"; import { CustomEvent } from "@llamaindex/env"; import type { AgentEndEvent, AgentStartEvent } from "../agent/types.js"; @@ -12,7 +13,6 @@ import type { LLMStreamEvent, LLMToolCallEvent, LLMToolResultEvent, - MessageContent, RetrievalEndEvent, RetrievalStartEvent, } from "../llm/types.js"; diff --git a/packages/llamaindex/src/embeddings/DeepInfraEmbedding.ts b/packages/llamaindex/src/embeddings/DeepInfraEmbedding.ts index 0cd9366c6..c3c03c6fe 100644 --- a/packages/llamaindex/src/embeddings/DeepInfraEmbedding.ts +++ b/packages/llamaindex/src/embeddings/DeepInfraEmbedding.ts @@ -1,5 +1,5 @@ +import type { MessageContentDetail } from "@llamaindex/core/llms"; import { getEnv } from "@llamaindex/env"; -import type { MessageContentDetail } from "../llm/index.js"; import { extractSingleText } from "../llm/utils.js"; import { BaseEmbedding } from "./types.js"; diff --git a/packages/llamaindex/src/embeddings/MultiModalEmbedding.ts b/packages/llamaindex/src/embeddings/MultiModalEmbedding.ts index 88cd6ca69..aabc43372 100644 --- a/packages/llamaindex/src/embeddings/MultiModalEmbedding.ts +++ b/packages/llamaindex/src/embeddings/MultiModalEmbedding.ts @@ -1,3 +1,4 @@ +import type { MessageContentDetail } from "@llamaindex/core/llms"; import { ImageNode, MetadataMode, @@ -6,7 +7,6 @@ import { type BaseNode, type ImageType, } from "@llamaindex/core/schema"; -import type { MessageContentDetail } from "../llm/types.js"; import { extractImage, extractSingleText } from "../llm/utils.js"; import { BaseEmbedding, batchEmbeddings } from "./types.js"; diff --git a/packages/llamaindex/src/embeddings/types.ts b/packages/llamaindex/src/embeddings/types.ts index a69e01fec..de32669e9 100644 --- a/packages/llamaindex/src/embeddings/types.ts +++ b/packages/llamaindex/src/embeddings/types.ts @@ -1,8 +1,8 @@ +import type { MessageContentDetail } from "@llamaindex/core/llms"; import type { BaseNode } from "@llamaindex/core/schema"; import { MetadataMode } from "@llamaindex/core/schema"; import { type Tokenizers } from "@llamaindex/env"; import type { TransformComponent } from "../ingestion/types.js"; -import type { MessageContentDetail } from "../llm/types.js"; import { extractSingleText } from "../llm/utils.js"; import { truncateMaxTokens } from "./tokenizer.js"; import { SimilarityType, similarity } from "./utils.js"; diff --git a/packages/llamaindex/src/engines/chat/CondenseQuestionChatEngine.ts b/packages/llamaindex/src/engines/chat/CondenseQuestionChatEngine.ts index adf099dcd..357088e97 100644 --- a/packages/llamaindex/src/engines/chat/CondenseQuestionChatEngine.ts +++ b/packages/llamaindex/src/engines/chat/CondenseQuestionChatEngine.ts @@ -1,3 +1,4 @@ +import type { ChatMessage, LLM } from "@llamaindex/core/llms"; import type { ChatHistory } from "../../ChatHistory.js"; import { getHistory } from "../../ChatHistory.js"; import type { EngineResponse } from "../../EngineResponse.js"; @@ -9,7 +10,6 @@ import { import type { ServiceContext } from "../../ServiceContext.js"; import { llmFromSettingsOrContext } from "../../Settings.js"; import { wrapEventCaller } from "../../internal/context/EventCaller.js"; -import type { ChatMessage, LLM } from "../../llm/index.js"; import { extractText, streamReducer } from "../../llm/utils.js"; import { PromptMixin } from "../../prompts/index.js"; import type { QueryEngine } from "../../types.js"; diff --git a/packages/llamaindex/src/engines/chat/ContextChatEngine.ts b/packages/llamaindex/src/engines/chat/ContextChatEngine.ts index dcd90d219..6403c0595 100644 --- a/packages/llamaindex/src/engines/chat/ContextChatEngine.ts +++ b/packages/llamaindex/src/engines/chat/ContextChatEngine.ts @@ -1,3 +1,9 @@ +import type { + ChatMessage, + LLM, + MessageContent, + MessageType, +} from "@llamaindex/core/llms"; import type { ChatHistory } from "../../ChatHistory.js"; import { getHistory } from "../../ChatHistory.js"; import { EngineResponse } from "../../EngineResponse.js"; @@ -5,8 +11,6 @@ import type { ContextSystemPrompt } from "../../Prompt.js"; import type { BaseRetriever } from "../../Retriever.js"; import { Settings } from "../../Settings.js"; import { wrapEventCaller } from "../../internal/context/EventCaller.js"; -import type { ChatMessage, LLM } from "../../llm/index.js"; -import type { MessageContent, MessageType } from "../../llm/types.js"; import { extractText, streamConverter, diff --git a/packages/llamaindex/src/engines/chat/DefaultContextGenerator.ts b/packages/llamaindex/src/engines/chat/DefaultContextGenerator.ts index 095bef174..398390800 100644 --- a/packages/llamaindex/src/engines/chat/DefaultContextGenerator.ts +++ b/packages/llamaindex/src/engines/chat/DefaultContextGenerator.ts @@ -1,10 +1,10 @@ +import type { MessageContent, MessageType } from "@llamaindex/core/llms"; import { type NodeWithScore } from "@llamaindex/core/schema"; +import type { BaseNodePostprocessor } from "../../postprocessors/index.js"; import type { ContextSystemPrompt } from "../../Prompt.js"; import { defaultContextSystemPrompt } from "../../Prompt.js"; -import type { BaseRetriever } from "../../Retriever.js"; -import type { MessageContent, MessageType } from "../../llm/types.js"; -import type { BaseNodePostprocessor } from "../../postprocessors/index.js"; import { PromptMixin } from "../../prompts/index.js"; +import type { BaseRetriever } from "../../Retriever.js"; import { createMessageContent } from "../../synthesizers/utils.js"; import type { Context, ContextGenerator } from "./types.js"; diff --git a/packages/llamaindex/src/engines/chat/SimpleChatEngine.ts b/packages/llamaindex/src/engines/chat/SimpleChatEngine.ts index 248831e0b..fcb934e00 100644 --- a/packages/llamaindex/src/engines/chat/SimpleChatEngine.ts +++ b/packages/llamaindex/src/engines/chat/SimpleChatEngine.ts @@ -1,9 +1,9 @@ +import type { LLM } from "@llamaindex/core/llms"; import type { ChatHistory } from "../../ChatHistory.js"; import { getHistory } from "../../ChatHistory.js"; import { EngineResponse } from "../../EngineResponse.js"; import { Settings } from "../../Settings.js"; import { wrapEventCaller } from "../../internal/context/EventCaller.js"; -import type { LLM } from "../../llm/index.js"; import { streamConverter, streamReducer } from "../../llm/utils.js"; import type { ChatEngine, diff --git a/packages/llamaindex/src/engines/chat/types.ts b/packages/llamaindex/src/engines/chat/types.ts index e84128fca..26286084f 100644 --- a/packages/llamaindex/src/engines/chat/types.ts +++ b/packages/llamaindex/src/engines/chat/types.ts @@ -1,8 +1,7 @@ +import type { ChatMessage, MessageContent } from "@llamaindex/core/llms"; import type { NodeWithScore } from "@llamaindex/core/schema"; import type { ChatHistory } from "../../ChatHistory.js"; import type { EngineResponse } from "../../EngineResponse.js"; -import type { ChatMessage } from "../../llm/index.js"; -import type { MessageContent } from "../../llm/types.js"; /** * Represents the base parameters for ChatEngine. diff --git a/packages/llamaindex/src/engines/query/SubQuestionQueryEngine.ts b/packages/llamaindex/src/engines/query/SubQuestionQueryEngine.ts index 432a25a45..34f3912ef 100644 --- a/packages/llamaindex/src/engines/query/SubQuestionQueryEngine.ts +++ b/packages/llamaindex/src/engines/query/SubQuestionQueryEngine.ts @@ -11,13 +11,12 @@ import { } from "../../synthesizers/index.js"; import type { - BaseTool, QueryEngine, QueryEngineParamsNonStreaming, QueryEngineParamsStreaming, - ToolMetadata, } from "../../types.js"; +import type { BaseTool, ToolMetadata } from "@llamaindex/core/llms"; import { wrapEventCaller } from "../../internal/context/EventCaller.js"; import type { BaseQuestionGenerator, SubQuestion } from "./types.js"; diff --git a/packages/llamaindex/src/engines/query/types.ts b/packages/llamaindex/src/engines/query/types.ts index 883846316..e0e27b90c 100644 --- a/packages/llamaindex/src/engines/query/types.ts +++ b/packages/llamaindex/src/engines/query/types.ts @@ -1,4 +1,4 @@ -import type { ToolMetadata } from "../../types.js"; +import type { ToolMetadata } from "@llamaindex/core/llms"; /** * QuestionGenerators generate new questions for the LLM using tools and a user query. diff --git a/packages/llamaindex/src/evaluation/Correctness.ts b/packages/llamaindex/src/evaluation/Correctness.ts index f250959e8..acb177395 100644 --- a/packages/llamaindex/src/evaluation/Correctness.ts +++ b/packages/llamaindex/src/evaluation/Correctness.ts @@ -1,9 +1,9 @@ +import type { ChatMessage, LLM } from "@llamaindex/core/llms"; import { MetadataMode } from "@llamaindex/core/schema"; -import type { ServiceContext } from "../ServiceContext.js"; -import { llmFromSettingsOrContext } from "../Settings.js"; -import type { ChatMessage, LLM } from "../llm/types.js"; import { extractText } from "../llm/utils.js"; import { PromptMixin } from "../prompts/Mixin.js"; +import type { ServiceContext } from "../ServiceContext.js"; +import { llmFromSettingsOrContext } from "../Settings.js"; import type { CorrectnessSystemPrompt } from "./prompts.js"; import { defaultCorrectnessSystemPrompt, diff --git a/packages/llamaindex/src/extractors/MetadataExtractors.ts b/packages/llamaindex/src/extractors/MetadataExtractors.ts index 1492c9163..5ab760209 100644 --- a/packages/llamaindex/src/extractors/MetadataExtractors.ts +++ b/packages/llamaindex/src/extractors/MetadataExtractors.ts @@ -1,6 +1,6 @@ +import type { LLM } from "@llamaindex/core/llms"; import type { BaseNode } from "@llamaindex/core/schema"; import { MetadataMode, TextNode } from "@llamaindex/core/schema"; -import type { LLM } from "../llm/index.js"; import { OpenAI } from "../llm/index.js"; import { defaultKeywordExtractorPromptTemplate, diff --git a/packages/llamaindex/src/index.edge.ts b/packages/llamaindex/src/index.edge.ts index acde62523..6e060b603 100644 --- a/packages/llamaindex/src/index.edge.ts +++ b/packages/llamaindex/src/index.edge.ts @@ -1,3 +1,4 @@ +export * from "@llamaindex/core/llms"; export * from "@llamaindex/core/schema"; export * from "./agent/index.js"; export * from "./callbacks/CallbackManager.js"; diff --git a/packages/llamaindex/src/indices/keyword/index.ts b/packages/llamaindex/src/indices/keyword/index.ts index d06caf56d..1d8f4f4b2 100644 --- a/packages/llamaindex/src/indices/keyword/index.ts +++ b/packages/llamaindex/src/indices/keyword/index.ts @@ -31,8 +31,8 @@ import { simpleExtractKeywords, } from "./utils.js"; +import type { LLM } from "@llamaindex/core/llms"; import { llmFromSettingsOrContext } from "../../Settings.js"; -import type { LLM } from "../../llm/types.js"; import { extractText } from "../../llm/utils.js"; export interface KeywordIndexOptions { diff --git a/packages/llamaindex/src/indices/vectorStore/index.ts b/packages/llamaindex/src/indices/vectorStore/index.ts index 92cce3bf4..4eadc0d36 100644 --- a/packages/llamaindex/src/indices/vectorStore/index.ts +++ b/packages/llamaindex/src/indices/vectorStore/index.ts @@ -1,3 +1,4 @@ +import type { MessageContent } from "@llamaindex/core/llms"; import { ImageNode, ModalityType, @@ -23,7 +24,6 @@ import { } from "../../ingestion/strategies/index.js"; import { wrapEventCaller } from "../../internal/context/EventCaller.js"; import { getCallbackManager } from "../../internal/settings/CallbackManager.js"; -import type { MessageContent } from "../../llm/types.js"; import type { BaseNodePostprocessor } from "../../postprocessors/types.js"; import type { StorageContext } from "../../storage/StorageContext.js"; import { storageContextFromDefaults } from "../../storage/StorageContext.js"; diff --git a/packages/llamaindex/src/internal/prompt/react.ts b/packages/llamaindex/src/internal/prompt/react.ts index 3f4450b91..eb36d765a 100644 --- a/packages/llamaindex/src/internal/prompt/react.ts +++ b/packages/llamaindex/src/internal/prompt/react.ts @@ -1,4 +1,4 @@ -import type { BaseTool } from "../../types.js"; +import type { BaseTool } from "@llamaindex/core/llms"; export const getReACTAgentSystemHeader = (tools: BaseTool[]) => { const description = tools diff --git a/packages/llamaindex/src/llm/anthropic.ts b/packages/llamaindex/src/llm/anthropic.ts index 7ee536200..19aa677cf 100644 --- a/packages/llamaindex/src/llm/anthropic.ts +++ b/packages/llamaindex/src/llm/anthropic.ts @@ -17,18 +17,18 @@ import type { ImageBlockParam, MessageParam, } from "@anthropic-ai/sdk/resources/messages"; -import { getEnv } from "@llamaindex/env"; -import _ from "lodash"; -import type { BaseTool } from "../types.js"; -import { ToolCallLLM } from "./base.js"; import type { + BaseTool, ChatMessage, ChatResponse, ChatResponseChunk, LLMChatParamsNonStreaming, LLMChatParamsStreaming, ToolCallLLMMessageOptions, -} from "./types.js"; +} from "@llamaindex/core/llms"; +import { getEnv } from "@llamaindex/env"; +import _ from "lodash"; +import { ToolCallLLM } from "./base.js"; import { extractText, wrapLLMEvent } from "./utils.js"; export class AnthropicSession { diff --git a/packages/llamaindex/src/llm/base.ts b/packages/llamaindex/src/llm/base.ts index 8db28bc9b..e5633667a 100644 --- a/packages/llamaindex/src/llm/base.ts +++ b/packages/llamaindex/src/llm/base.ts @@ -9,7 +9,7 @@ import type { LLMCompletionParamsStreaming, LLMMetadata, ToolCallLLMMessageOptions, -} from "./types.js"; +} from "@llamaindex/core/llms"; import { extractText, streamConverter } from "./utils.js"; export abstract class BaseLLM< diff --git a/packages/llamaindex/src/llm/gemini/base.ts b/packages/llamaindex/src/llm/gemini/base.ts index 458f631cf..994a8d821 100644 --- a/packages/llamaindex/src/llm/gemini/base.ts +++ b/packages/llamaindex/src/llm/gemini/base.ts @@ -7,8 +7,6 @@ import { type GenerateContentStreamResult as GoogleStreamGenerateContentResult, } from "@google/generative-ai"; -import { getEnv, randomUUID } from "@llamaindex/env"; -import { ToolCallLLM } from "../base.js"; import type { CompletionResponse, LLMCompletionParamsNonStreaming, @@ -16,7 +14,9 @@ import type { LLMMetadata, ToolCall, ToolCallLLMMessageOptions, -} from "../types.js"; +} from "@llamaindex/core/llms"; +import { getEnv, randomUUID } from "@llamaindex/env"; +import { ToolCallLLM } from "../base.js"; import { streamConverter, wrapLLMEvent } from "../utils.js"; import { GEMINI_BACKENDS, diff --git a/packages/llamaindex/src/llm/gemini/types.ts b/packages/llamaindex/src/llm/gemini/types.ts index f602ee83b..58bc65648 100644 --- a/packages/llamaindex/src/llm/gemini/types.ts +++ b/packages/llamaindex/src/llm/gemini/types.ts @@ -33,7 +33,7 @@ import type { LLMChatParamsStreaming, ToolCall, ToolCallLLMMessageOptions, -} from "../types.js"; +} from "@llamaindex/core/llms"; export enum GEMINI_BACKENDS { GOOGLE = "google", diff --git a/packages/llamaindex/src/llm/gemini/utils.ts b/packages/llamaindex/src/llm/gemini/utils.ts index fb75cbeab..50ad3b1bc 100644 --- a/packages/llamaindex/src/llm/gemini/utils.ts +++ b/packages/llamaindex/src/llm/gemini/utils.ts @@ -7,14 +7,14 @@ import { } from "@google/generative-ai"; import { type GenerateContentResponse } from "@google-cloud/vertexai"; -import type { BaseTool } from "../../types.js"; import type { + BaseTool, ChatMessage, MessageContentImageDetail, MessageContentTextDetail, MessageType, ToolCallLLMMessageOptions, -} from "../types.js"; +} from "@llamaindex/core/llms"; import { extractDataUrlComponents } from "../utils.js"; import type { ChatContext, diff --git a/packages/llamaindex/src/llm/gemini/vertex.ts b/packages/llamaindex/src/llm/gemini/vertex.ts index 398a9b1e8..96fd6b903 100644 --- a/packages/llamaindex/src/llm/gemini/vertex.ts +++ b/packages/llamaindex/src/llm/gemini/vertex.ts @@ -14,12 +14,12 @@ import type { } from "./types.js"; import type { FunctionCall } from "@google/generative-ai"; -import { getEnv, randomUUID } from "@llamaindex/env"; import type { CompletionResponse, ToolCall, ToolCallLLMMessageOptions, -} from "../types.js"; +} from "@llamaindex/core/llms"; +import { getEnv, randomUUID } from "@llamaindex/env"; import { streamConverter } from "../utils.js"; import { DEFAULT_SAFETY_SETTINGS, getFunctionCalls, getText } from "./utils.js"; diff --git a/packages/llamaindex/src/llm/huggingface.ts b/packages/llamaindex/src/llm/huggingface.ts index 56314e794..5965973c3 100644 --- a/packages/llamaindex/src/llm/huggingface.ts +++ b/packages/llamaindex/src/llm/huggingface.ts @@ -1,11 +1,4 @@ import { HfInference } from "@huggingface/inference"; -import type { - PreTrainedModel, - PreTrainedTokenizer, - Tensor, -} from "@xenova/transformers"; -import { lazyLoadTransformers } from "../internal/deps/transformers.js"; -import { BaseLLM } from "./base.js"; import type { ChatMessage, ChatResponse, @@ -14,7 +7,14 @@ import type { LLMChatParamsStreaming, LLMMetadata, ToolCallLLMMessageOptions, -} from "./types.js"; +} from "@llamaindex/core/llms"; +import type { + PreTrainedModel, + PreTrainedTokenizer, + Tensor, +} from "@xenova/transformers"; +import { lazyLoadTransformers } from "../internal/deps/transformers.js"; +import { BaseLLM } from "./base.js"; import { streamConverter, wrapLLMEvent } from "./utils.js"; // TODO workaround issue with @huggingface/inference@2.7.0 diff --git a/packages/llamaindex/src/llm/mistral.ts b/packages/llamaindex/src/llm/mistral.ts index d933327b5..da7be6751 100644 --- a/packages/llamaindex/src/llm/mistral.ts +++ b/packages/llamaindex/src/llm/mistral.ts @@ -1,14 +1,14 @@ -import { getEnv } from "@llamaindex/env"; -import { Settings } from "../Settings.js"; -import { type StreamCallbackResponse } from "../callbacks/CallbackManager.js"; -import { BaseLLM } from "./base.js"; import type { ChatMessage, ChatResponse, ChatResponseChunk, LLMChatParamsNonStreaming, LLMChatParamsStreaming, -} from "./types.js"; +} from "@llamaindex/core/llms"; +import { getEnv } from "@llamaindex/env"; +import { Settings } from "../Settings.js"; +import { type StreamCallbackResponse } from "../callbacks/CallbackManager.js"; +import { BaseLLM } from "./base.js"; export const ALL_AVAILABLE_MISTRAL_MODELS = { "mistral-tiny": { contextWindow: 32000 }, diff --git a/packages/llamaindex/src/llm/ollama.ts b/packages/llamaindex/src/llm/ollama.ts index 179cb7e58..44e9ede45 100644 --- a/packages/llamaindex/src/llm/ollama.ts +++ b/packages/llamaindex/src/llm/ollama.ts @@ -1,3 +1,14 @@ +import type { + ChatResponse, + ChatResponseChunk, + CompletionResponse, + LLM, + LLMChatParamsNonStreaming, + LLMChatParamsStreaming, + LLMCompletionParamsNonStreaming, + LLMCompletionParamsStreaming, + LLMMetadata, +} from "@llamaindex/core/llms"; import { BaseEmbedding } from "../embeddings/types.js"; import { Ollama as OllamaBase, @@ -19,17 +30,6 @@ import { type ShowResponse, type StatusResponse, } from "../internal/deps/ollama.js"; -import type { - ChatResponse, - ChatResponseChunk, - CompletionResponse, - LLM, - LLMChatParamsNonStreaming, - LLMChatParamsStreaming, - LLMCompletionParamsNonStreaming, - LLMCompletionParamsStreaming, - LLMMetadata, -} from "./types.js"; import { extractText, streamConverter } from "./utils.js"; const messageAccessor = (part: OllamaChatResponse): ChatResponseChunk => { diff --git a/packages/llamaindex/src/llm/openai.ts b/packages/llamaindex/src/llm/openai.ts index 8c0be3ffb..65813b882 100644 --- a/packages/llamaindex/src/llm/openai.ts +++ b/packages/llamaindex/src/llm/openai.ts @@ -7,6 +7,19 @@ import type { } from "openai"; import { AzureOpenAI, OpenAI as OrigOpenAI } from "openai"; +import type { + BaseTool, + ChatMessage, + ChatResponse, + ChatResponseChunk, + LLM, + LLMChatParamsNonStreaming, + LLMChatParamsStreaming, + LLMMetadata, + MessageType, + PartialToolCall, + ToolCallLLMMessageOptions, +} from "@llamaindex/core/llms"; import { Tokenizers } from "@llamaindex/env"; import type { ChatCompletionAssistantMessageParam, @@ -20,7 +33,6 @@ import type { import type { ChatCompletionMessageParam } from "openai/resources/index.js"; import { wrapEventCaller } from "../internal/context/EventCaller.js"; import { getCallbackManager } from "../internal/settings/CallbackManager.js"; -import type { BaseTool } from "../types.js"; import type { AzureOpenAIConfig } from "./azure.js"; import { getAzureConfigFromEnv, @@ -28,18 +40,6 @@ import { shouldUseAzure, } from "./azure.js"; import { ToolCallLLM } from "./base.js"; -import type { - ChatMessage, - ChatResponse, - ChatResponseChunk, - LLM, - LLMChatParamsNonStreaming, - LLMChatParamsStreaming, - LLMMetadata, - MessageType, - PartialToolCall, - ToolCallLLMMessageOptions, -} from "./types.js"; import { extractText, wrapLLMEvent } from "./utils.js"; export class OpenAISession { diff --git a/packages/llamaindex/src/llm/portkey.ts b/packages/llamaindex/src/llm/portkey.ts index bb3f47b12..3ee36bf13 100644 --- a/packages/llamaindex/src/llm/portkey.ts +++ b/packages/llamaindex/src/llm/portkey.ts @@ -1,10 +1,3 @@ -import { getEnv } from "@llamaindex/env"; -import _ from "lodash"; -import type { LLMOptions } from "portkey-ai"; -import { Portkey as OrigPortKey } from "portkey-ai"; -import { type StreamCallbackResponse } from "../callbacks/CallbackManager.js"; -import { getCallbackManager } from "../internal/settings/CallbackManager.js"; -import { BaseLLM } from "./base.js"; import type { ChatMessage, ChatResponse, @@ -13,7 +6,14 @@ import type { LLMChatParamsStreaming, LLMMetadata, MessageType, -} from "./types.js"; +} from "@llamaindex/core/llms"; +import { getEnv } from "@llamaindex/env"; +import _ from "lodash"; +import type { LLMOptions } from "portkey-ai"; +import { Portkey as OrigPortKey } from "portkey-ai"; +import { type StreamCallbackResponse } from "../callbacks/CallbackManager.js"; +import { getCallbackManager } from "../internal/settings/CallbackManager.js"; +import { BaseLLM } from "./base.js"; import { extractText, wrapLLMEvent } from "./utils.js"; interface PortkeyOptions { diff --git a/packages/llamaindex/src/llm/replicate_ai.ts b/packages/llamaindex/src/llm/replicate_ai.ts index 99d5fb332..091abdb78 100644 --- a/packages/llamaindex/src/llm/replicate_ai.ts +++ b/packages/llamaindex/src/llm/replicate_ai.ts @@ -1,6 +1,3 @@ -import { getEnv } from "@llamaindex/env"; -import Replicate from "../internal/deps/replicate.js"; -import { BaseLLM } from "./base.js"; import type { ChatMessage, ChatResponse, @@ -8,7 +5,10 @@ import type { LLMChatParamsNonStreaming, LLMChatParamsStreaming, MessageType, -} from "./types.js"; +} from "@llamaindex/core/llms"; +import { getEnv } from "@llamaindex/env"; +import Replicate from "../internal/deps/replicate.js"; +import { BaseLLM } from "./base.js"; import { extractText, streamCallbacks, diff --git a/packages/llamaindex/src/llm/types.ts b/packages/llamaindex/src/llm/types.ts index a6ad26d9c..eee81169d 100644 --- a/packages/llamaindex/src/llm/types.ts +++ b/packages/llamaindex/src/llm/types.ts @@ -1,7 +1,14 @@ +import type { + ChatMessage, + ChatResponse, + ChatResponseChunk, + MessageContent, + ToolCall, + ToolOutput, +} from "@llamaindex/core/llms"; import type { NodeWithScore } from "@llamaindex/core/schema"; -import type { Tokenizers } from "@llamaindex/env"; import type { BaseEvent } from "../internal/type.js"; -import type { BaseTool, JSONObject, ToolOutput, UUID } from "../types.js"; +import type { UUID } from "../types.js"; export type RetrievalStartEvent = BaseEvent<{ query: MessageContent; @@ -29,197 +36,3 @@ export type LLMStreamEvent = BaseEvent<{ id: UUID; chunk: ChatResponseChunk; }>; - -/** - * @internal - */ -export interface LLMChat< - AdditionalChatOptions extends object = object, - AdditionalMessageOptions extends object = object, -> { - chat( - params: - | LLMChatParamsStreaming<AdditionalChatOptions> - | LLMChatParamsNonStreaming<AdditionalChatOptions>, - ): Promise< - | ChatResponse<AdditionalMessageOptions> - | AsyncIterable<ChatResponseChunk<AdditionalMessageOptions>> - >; -} - -/** - * Unified language model interface - */ -export interface LLM< - AdditionalChatOptions extends object = object, - AdditionalMessageOptions extends object = object, -> extends LLMChat<AdditionalChatOptions> { - metadata: LLMMetadata; - /** - * Get a chat response from the LLM - */ - chat( - params: LLMChatParamsStreaming< - AdditionalChatOptions, - AdditionalMessageOptions - >, - ): Promise<AsyncIterable<ChatResponseChunk>>; - chat( - params: LLMChatParamsNonStreaming< - AdditionalChatOptions, - AdditionalMessageOptions - >, - ): Promise<ChatResponse<AdditionalMessageOptions>>; - - /** - * Get a prompt completion from the LLM - */ - complete( - params: LLMCompletionParamsStreaming, - ): Promise<AsyncIterable<CompletionResponse>>; - complete( - params: LLMCompletionParamsNonStreaming, - ): Promise<CompletionResponse>; -} - -export type MessageType = "user" | "assistant" | "system" | "memory"; - -export type TextChatMessage<AdditionalMessageOptions extends object = object> = - { - content: string; - role: MessageType; - options?: undefined | AdditionalMessageOptions; - }; - -export type ChatMessage<AdditionalMessageOptions extends object = object> = { - content: MessageContent; - role: MessageType; - options?: undefined | AdditionalMessageOptions; -}; - -export interface ChatResponse< - AdditionalMessageOptions extends object = object, -> { - message: ChatMessage<AdditionalMessageOptions>; - /** - * Raw response from the LLM - * - * If LLM response an iterable of chunks, this will be an array of those chunks - */ - raw: object | null; -} - -export type ChatResponseChunk< - AdditionalMessageOptions extends object = object, -> = { - raw: object | null; - delta: string; - options?: undefined | AdditionalMessageOptions; -}; - -export interface CompletionResponse { - text: string; - /** - * Raw response from the LLM - * - * It's possible that this is `null` if the LLM response an iterable of chunks - */ - raw: object | null; -} - -export type LLMMetadata = { - model: string; - temperature: number; - topP: number; - maxTokens?: number; - contextWindow: number; - tokenizer: Tokenizers | undefined; -}; - -export interface LLMChatParamsBase< - AdditionalChatOptions extends object = object, - AdditionalMessageOptions extends object = object, -> { - messages: ChatMessage<AdditionalMessageOptions>[]; - additionalChatOptions?: AdditionalChatOptions; - tools?: BaseTool[]; -} - -export interface LLMChatParamsStreaming< - AdditionalChatOptions extends object = object, - AdditionalMessageOptions extends object = object, -> extends LLMChatParamsBase<AdditionalChatOptions, AdditionalMessageOptions> { - stream: true; -} - -export interface LLMChatParamsNonStreaming< - AdditionalChatOptions extends object = object, - AdditionalMessageOptions extends object = object, -> extends LLMChatParamsBase<AdditionalChatOptions, AdditionalMessageOptions> { - stream?: false; -} - -export interface LLMCompletionParamsBase { - prompt: MessageContent; -} - -export interface LLMCompletionParamsStreaming extends LLMCompletionParamsBase { - stream: true; -} - -export interface LLMCompletionParamsNonStreaming - extends LLMCompletionParamsBase { - stream?: false | null; -} - -export type MessageContentTextDetail = { - type: "text"; - text: string; -}; - -export type MessageContentImageDetail = { - type: "image_url"; - image_url: { url: string }; -}; - -export type MessageContentDetail = - | MessageContentTextDetail - | MessageContentImageDetail; - -/** - * Extended type for the content of a message that allows for multi-modal messages. - */ -export type MessageContent = string | MessageContentDetail[]; - -export type ToolCall = { - name: string; - input: JSONObject; - id: string; -}; - -// happened in streaming response, the tool call is not ready yet -export type PartialToolCall = { - name: string; - id: string; - // input is not ready yet, JSON.parse(input) will throw an error - input: string; -}; - -export type ToolResult = { - id: string; - result: string; - isError: boolean; -}; - -export type ToolCallOptions = { - toolCall: (ToolCall | PartialToolCall)[]; -}; - -export type ToolResultOptions = { - toolResult: ToolResult; -}; - -export type ToolCallLLMMessageOptions = - | ToolResultOptions - | ToolCallOptions - | {}; diff --git a/packages/llamaindex/src/llm/utils.ts b/packages/llamaindex/src/llm/utils.ts index 8c8dabb33..6a640f368 100644 --- a/packages/llamaindex/src/llm/utils.ts +++ b/packages/llamaindex/src/llm/utils.ts @@ -1,6 +1,3 @@ -import type { ImageType } from "@llamaindex/core/schema"; -import { AsyncLocalStorage, randomUUID } from "@llamaindex/env"; -import { getCallbackManager } from "../internal/settings/CallbackManager.js"; import type { ChatResponse, ChatResponseChunk, @@ -9,7 +6,10 @@ import type { MessageContent, MessageContentDetail, MessageContentTextDetail, -} from "./types.js"; +} from "@llamaindex/core/llms"; +import type { ImageType } from "@llamaindex/core/schema"; +import { AsyncLocalStorage, randomUUID } from "@llamaindex/env"; +import { getCallbackManager } from "../internal/settings/CallbackManager.js"; export async function* streamConverter<S, D>( stream: AsyncIterable<S>, diff --git a/packages/llamaindex/src/memory/ChatMemoryBuffer.ts b/packages/llamaindex/src/memory/ChatMemoryBuffer.ts index eda6bbb31..ed4b38760 100644 --- a/packages/llamaindex/src/memory/ChatMemoryBuffer.ts +++ b/packages/llamaindex/src/memory/ChatMemoryBuffer.ts @@ -1,5 +1,5 @@ +import type { ChatMessage, LLM } from "@llamaindex/core/llms"; import type { ChatHistory } from "../ChatHistory.js"; -import type { ChatMessage, LLM } from "../llm/index.js"; import { SimpleChatStore } from "../storage/chatStore/SimpleChatStore.js"; import type { BaseChatStore } from "../storage/chatStore/types.js"; import type { BaseMemory } from "./types.js"; diff --git a/packages/llamaindex/src/memory/types.ts b/packages/llamaindex/src/memory/types.ts index 8af16e5a1..a95e2efea 100644 --- a/packages/llamaindex/src/memory/types.ts +++ b/packages/llamaindex/src/memory/types.ts @@ -1,4 +1,4 @@ -import type { ChatMessage } from "../llm/index.js"; +import type { ChatMessage } from "@llamaindex/core/llms"; export interface BaseMemory<AdditionalMessageOptions extends object = object> { tokenLimit: number; diff --git a/packages/llamaindex/src/objects/base.ts b/packages/llamaindex/src/objects/base.ts index 6ae73d50a..4b962d26b 100644 --- a/packages/llamaindex/src/objects/base.ts +++ b/packages/llamaindex/src/objects/base.ts @@ -1,10 +1,9 @@ +import type { BaseTool, MessageContent } from "@llamaindex/core/llms"; import type { BaseNode, Metadata } from "@llamaindex/core/schema"; import { TextNode } from "@llamaindex/core/schema"; import type { BaseRetriever } from "../Retriever.js"; import type { VectorStoreIndex } from "../indices/vectorStore/index.js"; -import type { MessageContent } from "../llm/index.js"; import { extractText } from "../llm/utils.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 diff --git a/packages/llamaindex/src/postprocessors/rerankers/CohereRerank.ts b/packages/llamaindex/src/postprocessors/rerankers/CohereRerank.ts index 920c0d0e3..8a630e520 100644 --- a/packages/llamaindex/src/postprocessors/rerankers/CohereRerank.ts +++ b/packages/llamaindex/src/postprocessors/rerankers/CohereRerank.ts @@ -1,8 +1,8 @@ import { CohereClient } from "cohere-ai"; +import type { MessageContent } from "@llamaindex/core/llms"; import type { NodeWithScore } from "@llamaindex/core/schema"; import { MetadataMode } from "@llamaindex/core/schema"; -import type { MessageContent } from "../../llm/types.js"; import { extractText } from "../../llm/utils.js"; import type { BaseNodePostprocessor } from "../types.js"; diff --git a/packages/llamaindex/src/postprocessors/rerankers/JinaAIReranker.ts b/packages/llamaindex/src/postprocessors/rerankers/JinaAIReranker.ts index aa0a02e4d..a1ffb334b 100644 --- a/packages/llamaindex/src/postprocessors/rerankers/JinaAIReranker.ts +++ b/packages/llamaindex/src/postprocessors/rerankers/JinaAIReranker.ts @@ -1,7 +1,7 @@ +import type { MessageContent } from "@llamaindex/core/llms"; import type { NodeWithScore } from "@llamaindex/core/schema"; import { MetadataMode } from "@llamaindex/core/schema"; import { getEnv } from "@llamaindex/env"; -import type { MessageContent } from "../../llm/types.js"; import { extractText } from "../../llm/utils.js"; import type { BaseNodePostprocessor } from "../types.js"; diff --git a/packages/llamaindex/src/postprocessors/types.ts b/packages/llamaindex/src/postprocessors/types.ts index 9650d39e0..8fafb4cfe 100644 --- a/packages/llamaindex/src/postprocessors/types.ts +++ b/packages/llamaindex/src/postprocessors/types.ts @@ -1,5 +1,5 @@ +import type { MessageContent } from "@llamaindex/core/llms"; import type { NodeWithScore } from "@llamaindex/core/schema"; -import type { MessageContent } from "../llm/types.js"; export interface BaseNodePostprocessor { /** diff --git a/packages/llamaindex/src/selectors/llmSelectors.ts b/packages/llamaindex/src/selectors/llmSelectors.ts index 5f7349f26..242b9973a 100644 --- a/packages/llamaindex/src/selectors/llmSelectors.ts +++ b/packages/llamaindex/src/selectors/llmSelectors.ts @@ -1,4 +1,4 @@ -import type { LLM } from "../llm/index.js"; +import type { LLM } from "@llamaindex/core/llms"; import type { Answer } from "../outputParsers/selectors.js"; import { SelectionOutputParser } from "../outputParsers/selectors.js"; import type { diff --git a/packages/llamaindex/src/storage/chatStore/SimpleChatStore.ts b/packages/llamaindex/src/storage/chatStore/SimpleChatStore.ts index 4f6df4718..b094a961e 100644 --- a/packages/llamaindex/src/storage/chatStore/SimpleChatStore.ts +++ b/packages/llamaindex/src/storage/chatStore/SimpleChatStore.ts @@ -1,4 +1,4 @@ -import type { ChatMessage } from "../../llm/index.js"; +import type { ChatMessage } from "@llamaindex/core/llms"; import type { BaseChatStore } from "./types.js"; /** diff --git a/packages/llamaindex/src/storage/chatStore/types.ts b/packages/llamaindex/src/storage/chatStore/types.ts index c809f91be..2e467276c 100644 --- a/packages/llamaindex/src/storage/chatStore/types.ts +++ b/packages/llamaindex/src/storage/chatStore/types.ts @@ -1,4 +1,4 @@ -import type { ChatMessage } from "../../llm/index.js"; +import type { ChatMessage } from "@llamaindex/core/llms"; export interface BaseChatStore< AdditionalMessageOptions extends object = object, diff --git a/packages/llamaindex/src/synthesizers/builders.ts b/packages/llamaindex/src/synthesizers/builders.ts index ee0cce07c..cc8147f67 100644 --- a/packages/llamaindex/src/synthesizers/builders.ts +++ b/packages/llamaindex/src/synthesizers/builders.ts @@ -1,4 +1,4 @@ -import type { LLM } from "../llm/index.js"; +import type { LLM } from "@llamaindex/core/llms"; import { streamConverter } from "../llm/utils.js"; import type { RefinePrompt, diff --git a/packages/llamaindex/src/synthesizers/utils.ts b/packages/llamaindex/src/synthesizers/utils.ts index b1e6e1962..79d465ffe 100644 --- a/packages/llamaindex/src/synthesizers/utils.ts +++ b/packages/llamaindex/src/synthesizers/utils.ts @@ -1,3 +1,4 @@ +import type { MessageContentDetail } from "@llamaindex/core/llms"; import { ImageNode, MetadataMode, @@ -7,7 +8,6 @@ import { } from "@llamaindex/core/schema"; import type { SimplePrompt } from "../Prompt.js"; import { imageToDataUrl } from "../embeddings/utils.js"; -import type { MessageContentDetail } from "../llm/types.js"; export async function createMessageContent( prompt: SimplePrompt, diff --git a/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts b/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts index 2500cd89f..aaf6bb7c5 100644 --- a/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts +++ b/packages/llamaindex/src/tools/AzureDynamicSessionTool.node.ts @@ -2,6 +2,7 @@ import { DefaultAzureCredential, getBearerTokenProvider, } from "@azure/identity"; +import type { BaseTool, ToolMetadata } from "@llamaindex/core/llms"; import { Readable, createWriteStream, @@ -11,7 +12,6 @@ import { path, randomUUID, } from "@llamaindex/env"; -import type { BaseTool, ToolMetadata } from "../types.js"; export type InterpreterParameter = { code: string; }; diff --git a/packages/llamaindex/src/tools/QueryEngineTool.ts b/packages/llamaindex/src/tools/QueryEngineTool.ts index d2c03ad93..f1118dd67 100644 --- a/packages/llamaindex/src/tools/QueryEngineTool.ts +++ b/packages/llamaindex/src/tools/QueryEngineTool.ts @@ -1,5 +1,6 @@ +import type { BaseTool, ToolMetadata } from "@llamaindex/core/llms"; import type { JSONSchemaType } from "ajv"; -import type { BaseTool, QueryEngine, ToolMetadata } from "../types.js"; +import type { QueryEngine } from "../types.js"; const DEFAULT_NAME = "query_engine_tool"; const DEFAULT_DESCRIPTION = diff --git a/packages/llamaindex/src/tools/WikipediaTool.ts b/packages/llamaindex/src/tools/WikipediaTool.ts index 6a1ff6904..f625378de 100644 --- a/packages/llamaindex/src/tools/WikipediaTool.ts +++ b/packages/llamaindex/src/tools/WikipediaTool.ts @@ -1,6 +1,6 @@ +import type { BaseTool, ToolMetadata } from "@llamaindex/core/llms"; import type { JSONSchemaType } from "ajv"; import { default as wiki } from "wikipedia"; -import type { BaseTool, ToolMetadata } from "../types.js"; type WikipediaParameter = { query: string; diff --git a/packages/llamaindex/src/tools/functionTool.ts b/packages/llamaindex/src/tools/functionTool.ts index 128d429cd..21ec4995f 100644 --- a/packages/llamaindex/src/tools/functionTool.ts +++ b/packages/llamaindex/src/tools/functionTool.ts @@ -1,5 +1,6 @@ +import type { BaseTool, ToolMetadata } from "@llamaindex/core/llms"; import type { JSONSchemaType } from "ajv"; -import type { BaseTool, JSONValue, ToolMetadata } from "../types.js"; +import type { JSONValue } from "../types.js"; export class FunctionTool<T, R extends JSONValue | Promise<JSONValue>> implements BaseTool<T> diff --git a/packages/llamaindex/src/types.ts b/packages/llamaindex/src/types.ts index c1f129282..d5b28bf8d 100644 --- a/packages/llamaindex/src/types.ts +++ b/packages/llamaindex/src/types.ts @@ -1,7 +1,7 @@ /** * Top level types to avoid circular dependencies */ -import { type JSONSchemaType } from "ajv"; +import type { ToolMetadata } from "@llamaindex/core/llms"; import type { EngineResponse } from "./EngineResponse.js"; /** @@ -33,46 +33,6 @@ export interface QueryEngine { query(params: QueryEngineParamsNonStreaming): Promise<EngineResponse>; } -type Known = - | { [key: string]: Known } - | [Known, ...Known[]] - | Known[] - | number - | string - | boolean - | null; - -export type ToolMetadata< - Parameters extends Record<string, unknown> = Record<string, unknown>, -> = { - description: string; - name: string; - /** - * OpenAI uses JSON Schema to describe the parameters that a tool can take. - * @link https://json-schema.org/understanding-json-schema - */ - parameters?: Parameters; -}; - -/** - * Simple Tool interface. Likely to change. - */ -export interface BaseTool<Input = any> { - /** - * This could be undefined if the implementation is not provided, - * which might be the case when communicating with a llm. - * - * @return {JSONValue | Promise<JSONValue>} The output of the tool. - */ - call?: (input: Input) => JSONValue | Promise<JSONValue>; - metadata: // if user input any, we cannot check the schema - Input extends Known ? ToolMetadata<JSONSchemaType<Input>> : ToolMetadata; -} - -export type BaseToolWithCall<Input = any> = Omit<BaseTool<Input>, "call"> & { - call: NonNullable<Pick<BaseTool<Input>, "call">["call"]>; -}; - /** * An OutputParser is used to extract structured data from the raw output of the LLM. */ @@ -113,11 +73,3 @@ export type JSONObject = { }; type JSONArray = Array<JSONValue>; - -export type ToolOutput = { - tool: BaseTool | undefined; - // all of existing function calling LLMs only support object input - input: JSONObject; - output: JSONValue; - isError: boolean; -}; diff --git a/packages/llamaindex/tests/utility/mockOpenAI.ts b/packages/llamaindex/tests/utility/mockOpenAI.ts index 626f7c901..e2677bb19 100644 --- a/packages/llamaindex/tests/utility/mockOpenAI.ts +++ b/packages/llamaindex/tests/utility/mockOpenAI.ts @@ -1,8 +1,8 @@ +import type { LLMChatParamsBase } from "llamaindex"; import { Settings } from "llamaindex"; import type { CallbackManager } from "llamaindex/callbacks/CallbackManager"; import type { OpenAIEmbedding } from "llamaindex/embeddings/index"; import { OpenAI } from "llamaindex/llm/openai"; -import type { LLMChatParamsBase } from "llamaindex/llm/types"; import { vi } from "vitest"; export const DEFAULT_LLM_TEXT_OUTPUT = "MOCK_TOKEN_1-MOCK_TOKEN_2"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e91f2bbe7..ea7699622 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -383,6 +383,9 @@ importers: specifier: ^3.23.8 version: 3.23.8 devDependencies: + ajv: + specifier: ^8.16.0 + version: 8.16.0 bunchee: specifier: ^5.2.1 version: 5.2.1(patch_hash=or7rmtlcau3uwknbkedxicrvyi)(typescript@5.5.2) @@ -17160,8 +17163,8 @@ snapshots: '@typescript-eslint/parser': 7.2.0(eslint@8.57.0)(typescript@5.5.2) eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.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.5.2))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) eslint-plugin-jsx-a11y: 6.8.0(eslint@8.57.0) eslint-plugin-react: 7.34.1(eslint@8.57.0) eslint-plugin-react-hooks: 4.6.2(eslint@8.57.0) @@ -17206,6 +17209,23 @@ snapshots: transitivePeerDependencies: - supports-color + eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0))(eslint@8.57.0): + dependencies: + debug: 4.3.4 + enhanced-resolve: 5.17.0 + eslint: 8.57.0 + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0))(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.5.2))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) + fast-glob: 3.3.2 + get-tsconfig: 4.7.5 + is-core-module: 2.13.1 + is-glob: 4.0.3 + transitivePeerDependencies: + - '@typescript-eslint/parser' + - eslint-import-resolver-node + - eslint-import-resolver-webpack + - supports-color + eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0): dependencies: debug: 4.3.4 @@ -17223,6 +17243,17 @@ snapshots: - eslint-import-resolver-webpack - supports-color + eslint-module-utils@2.8.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.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.5.2) + eslint: 8.57.0 + eslint-import-resolver-node: 0.3.9 + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0))(eslint@8.57.0) + transitivePeerDependencies: + - supports-color + eslint-module-utils@2.8.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.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 @@ -17234,14 +17265,31 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0): + eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0): dependencies: + array-includes: 3.1.8 + array.prototype.findlastindex: 1.2.5 + array.prototype.flat: 1.3.2 + array.prototype.flatmap: 1.3.2 debug: 3.2.7 - optionalDependencies: - '@typescript-eslint/parser': 7.8.0(eslint@8.57.0)(typescript@5.5.2) + doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) + hasown: 2.0.2 + is-core-module: 2.13.1 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.fromentries: 2.0.8 + object.groupby: 1.0.3 + object.values: 1.2.0 + semver: 6.3.1 + tsconfig-paths: 3.15.0 + optionalDependencies: + '@typescript-eslint/parser': 7.2.0(eslint@8.57.0)(typescript@5.5.2) transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack - supports-color eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint@8.57.0): @@ -17254,7 +17302,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) hasown: 2.0.2 is-core-module: 2.13.1 is-glob: 4.0.3 -- GitLab