Compare commits

..

3 Commits

Author SHA1 Message Date
github-actions[bot] fc2d5ea1cd Release 0.8.18 (#1506)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-11-18 13:08:32 -08:00
Thuc Pham ef4f63d9f4 refactor: move mockLLM to core (#1493)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-11-18 11:39:46 -08:00
Thuc Pham d17450fdfb fix: next.js 15 compatibility (#1474)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-11-18 11:34:05 -08:00
64 changed files with 383 additions and 69 deletions
+7
View File
@@ -1,5 +1,12 @@
# docs
## 0.0.123
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 0.0.122
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.122",
"version": "0.0.123",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
+13
View File
@@ -1,5 +1,18 @@
# @llamaindex/doc
## 0.0.21
### Patch Changes
- Updated dependencies [d17450f]
- Updated dependencies [ef4f63d]
- llamaindex@0.8.18
- @llamaindex/core@0.4.12
- @llamaindex/cloud@2.0.12
- @llamaindex/node-parser@0.0.13
- @llamaindex/openai@0.1.37
- @llamaindex/readers@1.0.14
## 0.0.20
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/doc",
"version": "0.0.20",
"version": "0.0.21",
"private": true,
"scripts": {
"build": "pnpm run build:docs && next build",
+2 -2
View File
@@ -1,9 +1,9 @@
import { llm } from "@/lib/utils";
import { MockLLM } from "@llamaindex/core/utils";
import { LlamaIndexAdapter, type Message } from "ai";
import { Settings, SimpleChatEngine, type ChatMessage } from "llamaindex";
import { NextResponse, type NextRequest } from "next/server";
Settings.llm = llm;
Settings.llm = new MockLLM(); // config your LLM here
export async function POST(request: NextRequest) {
try {
@@ -1,5 +1,5 @@
import { llm } from "@/lib/utils";
import { Markdown } from "@llamaindex/chat-ui/widgets";
import { MockLLM } from "@llamaindex/core/utils";
import { generateId, Message } from "ai";
import { createAI, createStreamableUI, getMutableAIState } from "ai/rsc";
import { type ChatMessage, Settings, SimpleChatEngine } from "llamaindex";
@@ -11,7 +11,7 @@ type Actions = {
chat: (message: Message) => Promise<Message & { display: ReactNode }>;
};
Settings.llm = llm;
Settings.llm = new MockLLM(); // config your LLM here
export const AI = createAI<ServerState, FrontendState, Actions>({
initialAIState: [],
+2 -30
View File
@@ -1,34 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { LLM, LLMMetadata } from "llamaindex";
import { twMerge } from "tailwind-merge";
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
class MockLLM {
metadata: LLMMetadata = {
model: "MockLLM",
temperature: 0.5,
topP: 0.5,
contextWindow: 1024,
tokenizer: undefined,
};
chat() {
const mockResponse = "Hello! This is a mock response";
return Promise.resolve(
new ReadableStream({
async start(controller) {
for (const char of mockResponse) {
controller.enqueue({ delta: char });
await new Promise((resolve) => setTimeout(resolve, 20));
}
controller.close();
},
}),
);
}
}
export const llm = new MockLLM() as unknown as LLM;
@@ -1,5 +1,12 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.114
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 0.0.113
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.113",
"version": "0.0.114",
"type": "module",
"private": true,
"scripts": {
@@ -1,5 +1,11 @@
# @llamaindex/llama-parse-browser-test
## 0.0.32
### Patch Changes
- @llamaindex/cloud@2.0.12
## 0.0.31
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.31",
"version": "0.0.32",
"type": "module",
"scripts": {
"dev": "vite",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/next-agent-test
## 0.1.114
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 0.1.113
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.113",
"version": "0.1.114",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,12 @@
# test-edge-runtime
## 0.1.113
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 0.1.112
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.112",
"version": "0.1.113",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,12 @@
# @llamaindex/next-node-runtime
## 0.0.95
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 0.0.94
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.0.94",
"version": "0.0.95",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,12 @@
# @llamaindex/waku-query-engine-test
## 0.0.114
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 0.0.113
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.113",
"version": "0.0.114",
"type": "module",
"private": true,
"scripts": {
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/autotool
## 5.0.18
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 5.0.17
### Patch Changes
@@ -1,5 +1,13 @@
# @llamaindex/autotool-01-node-example
## 0.0.61
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
- @llamaindex/autotool@5.0.18
## 0.0.60
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.60"
"version": "0.0.61"
}
@@ -1,5 +1,13 @@
# @llamaindex/autotool-02-next-example
## 0.1.105
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
- @llamaindex/autotool@5.0.18
## 0.1.104
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.104",
"version": "0.1.105",
"scripts": {
"dev": "next dev",
"build": "next build",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool",
"type": "module",
"version": "5.0.17",
"version": "5.0.18",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/cloud
## 2.0.12
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 2.0.11
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "2.0.11",
"version": "2.0.12",
"type": "module",
"license": "MIT",
"scripts": {
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/community
## 0.0.70
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 0.0.69
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.69",
"version": "0.0.70",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/core
## 0.4.12
### Patch Changes
- ef4f63d: refactor: move mockLLM to core
## 0.4.11
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.4.11",
"version": "0.4.12",
"description": "LlamaIndex Core Module",
"exports": {
"./agent": {
+1
View File
@@ -76,6 +76,7 @@ export {
extractText,
imageToDataUrl,
messagesToHistory,
MockLLM,
toToolDescriptions,
} from "./llms";
+88
View File
@@ -2,6 +2,15 @@ import { fs } from "@llamaindex/env";
import { filetypemime } from "magic-bytes.js";
import type {
ChatMessage,
ChatResponse,
ChatResponseChunk,
CompletionResponse,
LLM,
LLMChatParamsNonStreaming,
LLMChatParamsStreaming,
LLMCompletionParamsNonStreaming,
LLMCompletionParamsStreaming,
LLMMetadata,
MessageContent,
MessageContentDetail,
MessageContentTextDetail,
@@ -143,3 +152,82 @@ export async function imageToDataUrl(
}
return await blobToDataUrl(input);
}
export class MockLLM implements LLM {
metadata: LLMMetadata;
options: {
timeBetweenToken: number;
responseMessage: string;
};
constructor(options?: {
timeBetweenToken?: number;
responseMessage?: string;
metadata?: LLMMetadata;
}) {
this.options = {
timeBetweenToken: options?.timeBetweenToken ?? 20,
responseMessage: options?.responseMessage ?? "This is a mock response",
};
this.metadata = options?.metadata ?? {
model: "MockLLM",
temperature: 0.5,
topP: 0.5,
contextWindow: 1024,
tokenizer: undefined,
};
}
chat(
params: LLMChatParamsStreaming<object, object>,
): Promise<AsyncIterable<ChatResponseChunk>>;
chat(
params: LLMChatParamsNonStreaming<object, object>,
): Promise<ChatResponse<object>>;
async chat(
params:
| LLMChatParamsStreaming<object, object>
| LLMChatParamsNonStreaming<object, object>,
): Promise<AsyncIterable<ChatResponseChunk> | ChatResponse<object>> {
const responseMessage = this.options.responseMessage;
const timeBetweenToken = this.options.timeBetweenToken;
if (params.stream) {
return (async function* () {
for (const char of responseMessage) {
yield { delta: char, raw: {} };
await new Promise((resolve) => setTimeout(resolve, timeBetweenToken));
}
})();
}
return {
message: { content: responseMessage, role: "assistant" },
raw: {},
};
}
async complete(
params: LLMCompletionParamsStreaming,
): Promise<AsyncIterable<CompletionResponse>>;
async complete(
params: LLMCompletionParamsNonStreaming,
): Promise<CompletionResponse>;
async complete(
params: LLMCompletionParamsStreaming | LLMCompletionParamsNonStreaming,
): Promise<AsyncIterable<CompletionResponse> | CompletionResponse> {
const responseMessage = this.options.responseMessage;
const timeBetweenToken = this.options.timeBetweenToken;
if (params.stream) {
return (async function* () {
for (const char of responseMessage) {
yield { delta: char, text: char, raw: {} };
await new Promise((resolve) => setTimeout(resolve, timeBetweenToken));
}
})();
}
return { text: responseMessage, raw: {} };
}
}
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/experimental
## 0.0.130
### Patch Changes
- Updated dependencies [d17450f]
- llamaindex@0.8.18
## 0.0.129
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.129",
"version": "0.0.130",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+21
View File
@@ -1,5 +1,26 @@
# llamaindex
## 0.8.18
### Patch Changes
- d17450f: fix: rename from serverComponentsExternalPackages to serverExternalPackages
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
- @llamaindex/cloud@2.0.12
- @llamaindex/node-parser@0.0.13
- @llamaindex/anthropic@0.0.21
- @llamaindex/clip@0.0.21
- @llamaindex/deepinfra@0.0.21
- @llamaindex/huggingface@0.0.21
- @llamaindex/ollama@0.0.28
- @llamaindex/openai@0.1.37
- @llamaindex/portkey-ai@0.0.21
- @llamaindex/replicate@0.0.21
- @llamaindex/readers@1.0.14
- @llamaindex/groq@0.0.36
- @llamaindex/vllm@0.0.7
## 0.8.17
### Patch Changes
+11 -1
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.8.17",
"version": "0.8.18",
"license": "MIT",
"type": "module",
"keywords": [
@@ -125,6 +125,16 @@
"default": "./dist/cjs/index.js"
}
},
"./next": {
"import": {
"types": "./dist/type/next.d.ts",
"default": "./dist/next.js"
},
"require": {
"types": "./dist/type/next.d.ts",
"default": "./dist/cjs/next.js"
}
},
"./register": "./register.js",
"./internal/*": {
"import": "./dist/not-allow.js",
+19 -6
View File
@@ -15,15 +15,28 @@
*
* @module
*/
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const nextJsVersion: string = require("next/package.json").version;
const is14OrLower =
nextJsVersion.startsWith("14.") || nextJsVersion.startsWith("13.");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function withLlamaIndex(config: any) {
config.experimental = config.experimental ?? {};
// needed for transformers, see https://huggingface.co/docs/transformers.js/en/tutorials/next#step-2-install-and-configure-transformersjs
config.experimental.serverComponentsExternalPackages =
config.experimental.serverComponentsExternalPackages ?? [];
config.experimental.serverComponentsExternalPackages.push(
"@huggingface/transformers",
);
if (is14OrLower) {
config.experimental.serverComponentsExternalPackages =
config.experimental.serverComponentsExternalPackages ?? [];
config.experimental.serverComponentsExternalPackages.push(
"@huggingface/transformers",
);
} else {
config.serverExternalPackages = config.serverExternalPackages ?? [];
config.serverExternalPackages.push("@huggingface/transformers");
}
const userWebpack = config.webpack;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config.webpack = function (webpackConfig: any, options: any) {
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/node-parser
## 0.0.13
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 0.0.12
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/node-parser",
"version": "0.0.12",
"version": "0.0.13",
"description": "Node parser for LlamaIndex",
"type": "module",
"exports": {
@@ -1,5 +1,12 @@
# @llamaindex/anthropic
## 0.0.21
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 0.0.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/anthropic",
"description": "Anthropic Adapter for LlamaIndex",
"version": "0.0.20",
"version": "0.0.21",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+8
View File
@@ -1,5 +1,13 @@
# @llamaindex/clip
## 0.0.21
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
- @llamaindex/openai@0.1.37
## 0.0.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/clip",
"description": "Clip Embedding Adapter for LlamaIndex",
"version": "0.0.20",
"version": "0.0.21",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
@@ -1,5 +1,13 @@
# @llamaindex/deepinfra
## 0.0.21
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
- @llamaindex/openai@0.1.37
## 0.0.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/deepinfra",
"description": "Deepinfra Adapter for LlamaIndex",
"version": "0.0.20",
"version": "0.0.21",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/groq
## 0.0.36
### Patch Changes
- @llamaindex/openai@0.1.37
## 0.0.35
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/groq",
"description": "Groq Adapter for LlamaIndex",
"version": "0.0.35",
"version": "0.0.36",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,13 @@
# @llamaindex/huggingface
## 0.0.21
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
- @llamaindex/openai@0.1.37
## 0.0.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/huggingface",
"description": "Huggingface Adapter for LlamaIndex",
"version": "0.0.20",
"version": "0.0.21",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/ollama
## 0.0.28
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 0.0.27
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/ollama",
"description": "Ollama Adapter for LlamaIndex",
"version": "0.0.27",
"version": "0.0.28",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/openai
## 0.1.37
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 0.1.36
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/openai",
"description": "OpenAI Adapter for LlamaIndex",
"version": "0.1.36",
"version": "0.1.37",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/portkey-ai
## 0.0.21
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 0.0.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/portkey-ai",
"description": "Portkey Adapter for LlamaIndex",
"version": "0.0.20",
"version": "0.0.21",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/replicate
## 0.0.21
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 0.0.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/replicate",
"description": "Replicate Adapter for LlamaIndex",
"version": "0.0.20",
"version": "0.0.21",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/vllm
## 0.0.7
### Patch Changes
- @llamaindex/openai@0.1.37
## 0.0.6
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/vllm",
"description": "vLLM Adapter for LlamaIndex",
"version": "0.0.6",
"version": "0.0.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/readers
## 1.0.14
### Patch Changes
- Updated dependencies [ef4f63d]
- @llamaindex/core@0.4.12
## 1.0.13
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/readers",
"description": "LlamaIndex Readers",
"version": "1.0.13",
"version": "1.0.14",
"type": "module",
"exports": {
"./node/hook": "./node/dist/hook.js",
+13
View File
@@ -1,5 +1,18 @@
# @llamaindex/unit-test
## 0.0.28
### Patch Changes
- Updated dependencies [d17450f]
- Updated dependencies [ef4f63d]
- llamaindex@0.8.18
- @llamaindex/core@0.4.12
- @llamaindex/cloud@2.0.12
- @llamaindex/node-parser@0.0.13
- @llamaindex/openai@0.1.37
- @llamaindex/readers@1.0.14
## 0.0.27
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/unit-test",
"private": true,
"version": "0.0.27",
"version": "0.0.28",
"type": "module",
"scripts": {
"test": "vitest run"