Compare commits

...

5 Commits

Author SHA1 Message Date
github-actions[bot] 97e4ecd5b8 Release 0.3.7 (#812)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-05 22:11:54 -05:00
Alex Yang b6a660651b feat: allow to change ollama port (#811) 2024-05-05 19:08:00 -05:00
github-actions[bot] 456d3fb0b3 Release 0.3.6 (#810)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-05 18:40:58 -05:00
Alex Yang efa326a871 chore: update package.json and usage of lodash (#809) 2024-05-05 18:30:46 -05:00
Alex Yang 5765b637ce build: fix jsr release 2024-05-03 18:21:08 -05:00
28 changed files with 254 additions and 127 deletions
+15
View File
@@ -1,5 +1,20 @@
# docs
## 0.0.15
### Patch Changes
- Updated dependencies [b6a6606]
- Updated dependencies [b6a6606]
- llamaindex@0.3.7
## 0.0.14
### Patch Changes
- Updated dependencies [efa326a]
- llamaindex@0.3.6
## 0.0.13
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.13",
"version": "0.0.15",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
+6 -1
View File
@@ -2,7 +2,12 @@ import { OllamaEmbedding } from "llamaindex";
import { Ollama } from "llamaindex/llm/ollama";
(async () => {
const llm = new Ollama({ model: "llama3" });
const llm = new Ollama({
model: "llama3",
config: {
host: "http://localhost:11434",
},
});
const embedModel = new OllamaEmbedding({ model: "nomic-embed-text" });
{
const response = await llm.chat({
+16
View File
@@ -1,5 +1,21 @@
# llamaindex
## 0.3.7
### Patch Changes
- b6a6606: feat: allow change host of ollama
- b6a6606: chore: export ollama in default js runtime
## 0.3.6
### Patch Changes
- efa326a: chore: update package.json
- Updated dependencies [efa326a]
- Updated dependencies [efa326a]
- @llamaindex/env@0.1.2
## 0.3.5
### Patch Changes
@@ -1,5 +1,20 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.8
### Patch Changes
- Updated dependencies [b6a6606]
- Updated dependencies [b6a6606]
- llamaindex@0.3.7
## 0.0.7
### Patch Changes
- Updated dependencies [efa326a]
- llamaindex@0.3.6
## 0.0.6
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.6",
"version": "0.0.8",
"type": "module",
"private": true,
"scripts": {
@@ -1,5 +1,20 @@
# @llamaindex/next-agent-test
## 0.1.8
### Patch Changes
- Updated dependencies [b6a6606]
- Updated dependencies [b6a6606]
- llamaindex@0.3.7
## 0.1.7
### Patch Changes
- Updated dependencies [efa326a]
- llamaindex@0.3.6
## 0.1.6
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.6",
"version": "0.1.8",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# test-edge-runtime
## 0.1.8
### Patch Changes
- @llamaindex/edge@0.3.6
## 0.1.7
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.7",
"version": "0.1.8",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,20 @@
# @llamaindex/waku-query-engine-test
## 0.0.8
### Patch Changes
- Updated dependencies [b6a6606]
- Updated dependencies [b6a6606]
- llamaindex@0.3.7
## 0.0.7
### Patch Changes
- Updated dependencies [efa326a]
- llamaindex@0.3.6
## 0.0.6
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.6",
"version": "0.0.8",
"type": "module",
"private": true,
"scripts": {
+3 -3
View File
@@ -1,11 +1,11 @@
{
"name": "@llamaindex/core",
"version": "0.3.5",
"version": "0.3.7",
"exports": "./src/index.ts",
"imports": {
"@llamaindex/env": "jsr:@llamaindex/env@0.1.1"
"@llamaindex/env": "jsr:@llamaindex/env@0.1.2"
},
"publish": {
"include": ["LICENSE", "README.md", "src/**/*"]
"include": ["LICENSE", "README.md", "src/**/*", "jsr.json"]
}
}
+17 -1
View File
@@ -1,9 +1,25 @@
{
"name": "llamaindex",
"version": "0.3.5",
"version": "0.3.7",
"expectedMinorVersion": "3",
"license": "MIT",
"type": "module",
"keywords": [
"llm",
"llama",
"openai",
"gpt",
"data science",
"prompt",
"prompt engineering",
"chatgpt",
"machine learning",
"ml",
"embedding",
"vectorstore",
"data framework",
"llamaindex"
],
"dependencies": {
"@anthropic-ai/sdk": "^0.20.6",
"@aws-crypto/sha256-js": "^5.2.0",
+1
View File
@@ -2,6 +2,7 @@ export * from "./GeminiEmbedding.js";
export * from "./JinaAIEmbedding.js";
export * from "./MistralAIEmbedding.js";
export * from "./MultiModalEmbedding.js";
export { OllamaEmbedding } from "./OllamaEmbedding.js";
export * from "./OpenAIEmbedding.js";
export { FireworksEmbedding } from "./fireworks.js";
export { TogetherEmbedding } from "./together.js";
-2
View File
@@ -10,5 +10,3 @@ export {
HuggingFaceEmbedding,
HuggingFaceEmbeddingModelType,
} from "./embeddings/HuggingFaceEmbedding.js";
export { OllamaEmbedding } from "./embeddings/OllamaEmbedding.js";
export { Ollama, type OllamaParams } from "./llm/ollama.js";
+1
View File
@@ -17,6 +17,7 @@ export * from "./openai.js";
export { Portkey } from "./portkey.js";
export * from "./replicate_ai.js";
// Note: The type aliases for replicate are to simplify usage for Llama 2 (we're using replicate for Llama 2 support)
export { Ollama, type OllamaParams } from "./ollama.js";
export {
ALL_AVAILABLE_REPLICATE_MODELS,
DeuceChatStrategy,
+78 -100
View File
@@ -1,11 +1,23 @@
import { BaseEmbedding } from "../embeddings/types.js";
import ollama, {
import {
Ollama as OllamaBase,
type Config,
type CopyRequest,
type CreateRequest,
type DeleteRequest,
type EmbeddingsRequest,
type EmbeddingsResponse,
type GenerateRequest,
type ListResponse,
type ChatResponse as OllamaChatResponse,
type GenerateResponse as OllamaGenerateResponse,
type Options,
type ProgressResponse,
type PullRequest,
type PushRequest,
type ShowRequest,
type ShowResponse,
type StatusResponse,
} from "../internal/deps/ollama.js";
import type {
ChatResponse,
@@ -35,15 +47,21 @@ const completionAccessor = (
export type OllamaParams = {
model: string;
config?: Partial<Config>;
options?: Partial<Options>;
};
/**
* This class both implements the LLM and Embedding interfaces.
*/
export class Ollama extends BaseEmbedding implements LLM {
export class Ollama
extends BaseEmbedding
implements LLM, Omit<OllamaBase, "chat">
{
readonly hasStreaming = true;
ollama: OllamaBase;
// https://ollama.ai/library
model: string;
@@ -57,6 +75,7 @@ export class Ollama extends BaseEmbedding implements LLM {
constructor(params: OllamaParams) {
super();
this.model = params.model;
this.ollama = new OllamaBase(params.config);
if (params.options) {
this.options = {
...this.options,
@@ -97,7 +116,7 @@ export class Ollama extends BaseEmbedding implements LLM {
},
};
if (!stream) {
const chatResponse = await ollama.chat({
const chatResponse = await this.ollama.chat({
...payload,
stream: false,
});
@@ -110,7 +129,7 @@ export class Ollama extends BaseEmbedding implements LLM {
raw: chatResponse,
};
} else {
const stream = await ollama.chat({
const stream = await this.ollama.chat({
...payload,
stream: true,
});
@@ -137,7 +156,7 @@ export class Ollama extends BaseEmbedding implements LLM {
},
};
if (!stream) {
const response = await ollama.generate({
const response = await this.ollama.generate({
...payload,
stream: false,
});
@@ -146,7 +165,7 @@ export class Ollama extends BaseEmbedding implements LLM {
raw: response,
};
} else {
const stream = await ollama.generate({
const stream = await this.ollama.generate({
...payload,
stream: true,
});
@@ -162,7 +181,7 @@ export class Ollama extends BaseEmbedding implements LLM {
...this.options,
},
};
const response = await ollama.embeddings({
const response = await this.ollama.embeddings({
...payload,
});
return response.embedding;
@@ -176,104 +195,63 @@ export class Ollama extends BaseEmbedding implements LLM {
return this.getEmbedding(query);
}
// ollama specific methods, inherited from the ollama library
static async list() {
const { models } = await ollama.list();
return models;
}
// Inherited from OllamaBase
static async detail(modelName: string, options?: Omit<ShowRequest, "model">) {
return ollama.show({
model: modelName,
...options,
});
}
static async create(
modelName: string,
options?: Omit<CreateRequest, "model"> & {
stream: false;
},
push(
request: PushRequest & { stream: true },
): Promise<AsyncGenerator<ProgressResponse, any, unknown>>;
push(
request: PushRequest & { stream?: false | undefined },
): Promise<ProgressResponse>;
static async create(
modelName: string,
options: Omit<CreateRequest, "model"> & {
stream: true;
},
push(request: any): any {
return this.ollama.push(request);
}
abort(): void {
return this.ollama.abort();
}
encodeImage(image: string | Uint8Array): Promise<string> {
return this.ollama.encodeImage(image);
}
generate(
request: GenerateRequest & { stream: true },
): Promise<AsyncGenerator<OllamaGenerateResponse>>;
generate(
request: GenerateRequest & { stream?: false | undefined },
): Promise<OllamaGenerateResponse>;
generate(request: any): any {
return this.ollama.generate(request);
}
create(
request: CreateRequest & { stream: true },
): Promise<AsyncGenerator<ProgressResponse>>;
static async create(
modelName: string,
options?: Omit<CreateRequest, "model"> & {
stream: boolean;
},
) {
return ollama.create({
model: modelName,
...options,
stream: (options ? !!options.stream : false) as never,
}) as Promise<ProgressResponse> | Promise<AsyncGenerator<ProgressResponse>>;
}
static async delete(modelName: string) {
return ollama.delete({
model: modelName,
});
}
static async copy(source: string, destination: string) {
return ollama.copy({
source,
destination,
});
}
static async pull(
modelName: string,
options?: Omit<CreateRequest, "model"> & {
stream: false;
},
create(
request: CreateRequest & { stream?: false | undefined },
): Promise<ProgressResponse>;
static async pull(
modelName: string,
options: Omit<CreateRequest, "model"> & {
stream: true;
},
): Promise<AsyncGenerator<ProgressResponse>>;
static async pull(
modelName: string,
options?: Omit<CreateRequest, "model"> & {
stream: boolean;
},
) {
return ollama.pull({
model: modelName,
...options,
stream: (options ? !!options.stream : false) as never,
}) as Promise<ProgressResponse> | Promise<AsyncGenerator<ProgressResponse>>;
create(request: any): any {
return this.ollama.create(request);
}
static async push(
modelName: string,
options?: Omit<CreateRequest, "model"> & {
stream: false;
},
): Promise<ProgressResponse>;
static async push(
modelName: string,
options: Omit<CreateRequest, "model"> & {
stream: true;
},
pull(
request: PullRequest & { stream: true },
): Promise<AsyncGenerator<ProgressResponse>>;
static async push(
modelName: string,
options?: Omit<CreateRequest, "model"> & {
stream: boolean;
},
) {
return ollama.push({
model: modelName,
...options,
stream: (options ? !!options.stream : false) as never,
}) as Promise<ProgressResponse> | Promise<AsyncGenerator<ProgressResponse>>;
pull(
request: PullRequest & { stream?: false | undefined },
): Promise<ProgressResponse>;
pull(request: any): any {
return this.ollama.pull(request);
}
delete(request: DeleteRequest): Promise<StatusResponse> {
return this.ollama.delete(request);
}
copy(request: CopyRequest): Promise<StatusResponse> {
return this.ollama.copy(request);
}
list(): Promise<ListResponse> {
return this.ollama.list();
}
show(request: ShowRequest): Promise<ShowResponse> {
return this.ollama.show(request);
}
embeddings(request: EmbeddingsRequest): Promise<EmbeddingsResponse> {
return this.ollama.embeddings(request);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/edge",
"version": "0.3.5",
"version": "0.3.7",
"license": "MIT",
"type": "module",
"dependencies": {
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/env
## 0.1.2
### Patch Changes
- efa326a: chore: update package.json
- efa326a: refactor: remove usage of lodash
## 0.1.1
### Patch Changes
+7
View File
@@ -0,0 +1,7 @@
# @llamaindex/env
> Environment wrapper, supports all JS environment including node, deno, bun, edge runtime, and cloudflare worker.
## LICENSE
MIT
+2 -2
View File
@@ -1,11 +1,11 @@
{
"name": "@llamaindex/env",
"version": "0.1.1",
"version": "0.1.2",
"exports": {
".": "./src/index.ts",
"./type": "./src/type.ts"
},
"publish": {
"include": ["LICENSE", "README.md", "src/**/*.ts"]
"include": ["LICENSE", "README.md", "src/**/*.ts", "jsr.json"]
}
}
+18 -3
View File
@@ -1,10 +1,26 @@
{
"name": "@llamaindex/env",
"description": "environment wrapper, supports all JS environment including node, deno, bun, edge runtime, and cloudflare worker",
"version": "0.1.1",
"version": "0.1.2",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
"keywords": [
"llm",
"llama",
"openai",
"gpt",
"data science",
"prompt",
"prompt engineering",
"chatgpt",
"machine learning",
"ml",
"embedding",
"vectorstore",
"data framework",
"llamaindex"
],
"exports": {
".": {
"node": {
@@ -67,8 +83,7 @@
},
"dependencies": {
"@types/lodash": "^4.14.202",
"@types/node": "^20.12.7",
"lodash": "^4.17.21"
"@types/node": "^20.12.7"
},
"peerDependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
+7
View File
@@ -1,3 +1,10 @@
/**
* Polyfill implementation some node.js APIs.
*
* The code should be compatible with any JS runtime.
*
* @module
*/
import { Sha256 } from "@aws-crypto/sha256-js";
import pathe from "pathe";
import { InMemoryFileSystem, type CompleteFileSystem } from "./type.js";
+3 -5
View File
@@ -1,5 +1,3 @@
import _ from "lodash";
/**
* A filesystem interface that is meant to be compatible with
* the 'fs' module from Node.js.
@@ -41,14 +39,14 @@ export class InMemoryFileSystem implements CompleteFileSystem {
content: string,
options?: unknown,
): Promise<void> {
this.files[path] = _.cloneDeep(content);
this.files[path] = structuredClone(content);
}
async readFile(path: string): Promise<string> {
if (!(path in this.files)) {
throw new Error(`File ${path} does not exist`);
}
return _.cloneDeep(this.files[path]);
return structuredClone(this.files[path]);
}
async access(path: string): Promise<void> {
@@ -58,7 +56,7 @@ export class InMemoryFileSystem implements CompleteFileSystem {
}
async mkdir(path: string): Promise<undefined> {
this.files[path] = _.get(this.files, path, null);
this.files[path] = this.files[path] ?? null;
}
async readdir(path: string): Promise<string[]> {
+15
View File
@@ -1,5 +1,20 @@
# @llamaindex/experimental
## 0.0.24
### Patch Changes
- Updated dependencies [b6a6606]
- Updated dependencies [b6a6606]
- llamaindex@0.3.7
## 0.0.23
### Patch Changes
- Updated dependencies [efa326a]
- llamaindex@0.3.6
## 0.0.22
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.22",
"version": "0.0.24",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
-3
View File
@@ -628,9 +628,6 @@ importers:
'@types/node':
specifier: ^20.12.7
version: 20.12.7
lodash:
specifier: ^4.17.21
version: 4.17.21
devDependencies:
'@aws-crypto/sha256-js':
specifier: ^5.2.0