Compare commits

..

2 Commits

Author SHA1 Message Date
github-actions[bot] 76b925e62a Release 0.7.3 (#1357)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: himself65 <himself65@users.noreply.github.com>
2024-10-20 20:15:51 -07:00
Alex Yang 0493f679a4 fix(core): inline python-format-js (#1356) 2024-10-20 20:07:48 -07:00
53 changed files with 405 additions and 45 deletions
+6
View File
@@ -1,5 +1,11 @@
# docs
## 0.0.95
### Patch Changes
- llamaindex@0.7.3
## 0.0.94
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.94",
"version": "0.0.95",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
-3
View File
@@ -39,9 +39,6 @@
"overrides": {
"trim": "1.0.1",
"protobufjs": "7.2.6"
},
"patchedDependencies": {
"python-format-js@1.4.3": "patches/python-format-js@1.4.3.patch"
}
},
"lint-staged": {
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/autotool
## 4.0.3
### Patch Changes
- llamaindex@0.7.3
## 4.0.2
### Patch Changes
@@ -1,5 +1,12 @@
# @llamaindex/autotool-01-node-example
## 0.0.35
### Patch Changes
- llamaindex@0.7.3
- @llamaindex/autotool@4.0.3
## 0.0.34
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.34"
"version": "0.0.35"
}
@@ -1,5 +1,12 @@
# @llamaindex/autotool-02-next-example
## 0.1.79
### Patch Changes
- llamaindex@0.7.3
- @llamaindex/autotool@4.0.3
## 0.1.78
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.78",
"version": "0.1.79",
"scripts": {
"dev": "next dev",
"build": "next build",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool",
"type": "module",
"version": "4.0.2",
"version": "4.0.3",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/cloud
## 1.0.3
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
## 1.0.2
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "1.0.2",
"version": "1.0.3",
"type": "module",
"license": "MIT",
"scripts": {
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/community
## 0.0.51
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
## 0.0.50
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.50",
"version": "0.0.51",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/core
## 0.3.3
### Patch Changes
- 0493f67: fix(core): inline `python-format-js`
## 0.3.2
### Patch Changes
+2 -3
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.3.2",
"version": "0.3.3",
"description": "LlamaIndex Core Module",
"exports": {
"./agent": {
@@ -336,8 +336,7 @@
"ajv": "^8.17.1",
"bunchee": "5.5.1",
"happy-dom": "^15.7.4",
"natural": "^8.0.1",
"python-format-js": "^1.4.3"
"natural": "^8.0.1"
},
"dependencies": {
"@llamaindex/env": "workspace:*",
+1 -1
View File
@@ -1,7 +1,7 @@
import format from "python-format-js";
import type { ChatMessage } from "../llms";
import type { BaseOutputParser, Metadata } from "../schema";
import { objectEntries } from "../utils";
import { format } from "./format";
import { PromptType } from "./prompt-type";
type MappingFn<TemplatesVar extends string[] = string[]> = (
+207
View File
@@ -0,0 +1,207 @@
/**
* MIT License
*
* Copyright (c) 2019 jhonararipe
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
"use strict";
function formatImpl(this: string, ...args_: any[]) {
// Create variables
let self = this;
const __patterns__ = self.match(/({.*?})/g);
const {
REF,
FILL_CHAR,
MASK_NUMBER,
ALIGN_OP,
CROP_SIZE,
DOT,
FRACTION,
TYPE_VAR,
} = {
REF: 1,
FILL_CHAR: 2,
MASK_NUMBER: 3,
ALIGN_OP: 4,
CROP_SIZE: 5,
DOT: 6,
FRACTION: 7,
TYPE_VAR: 8,
};
const DEFAULT_PLACE = 6;
const ALL_REGEXP =
/{(\w+)?:([^>\^<\d#]|0)?([#%,])?([>^<\.])?(\d+)?(\.)?(\d+)?([eEfFgGdxXobn#%])?}/g;
const regExpBasic = /{\[?(\w+)\]?}/; // it's not best solution
const isObject = typeof args_[0] === "object";
// types/use logic
__patterns__?.map((pattern, patt_index) => {
const kargs = ALL_REGEXP.exec(pattern) || ALL_REGEXP.exec(pattern);
const wargs = regExpBasic.exec(pattern);
// Insert values (one 2 one / array / object)
const INDEX_VAR =
(wargs ? wargs[REF] : kargs ? kargs[REF] : patt_index) || patt_index;
// @ts-expect-error
const NATUAL_VALUE = isObject ? args_[0][INDEX_VAR] : args_[INDEX_VAR];
// @ts-expect-error
let ACTUAL_VALUE = isObject ? args_[0][INDEX_VAR] : args_[INDEX_VAR];
// Verify sintax/semantic
if (ACTUAL_VALUE === null || ACTUAL_VALUE === undefined)
throw new Error(
`Replacement index ${INDEX_VAR} out of range for positional args tuple`,
);
if (kargs) {
// If TYPE_VAR is not defined and the first argument is a number, pad a string should from left, so set TYPE_VAR to "d"
if (kargs[TYPE_VAR] === undefined && typeof ACTUAL_VALUE === "number") {
kargs[TYPE_VAR] = "d";
}
const LETTER =
(!kargs[FILL_CHAR]
? false
: !kargs[ALIGN_OP] &&
[..."FfbefoxXn"].includes(kargs[FILL_CHAR].toLowerCase())
? kargs[FILL_CHAR]
: kargs[TYPE_VAR]) || kargs[TYPE_VAR];
// padronaze
if (LETTER) {
const floatSize = pattern.includes(".")
? Number(kargs[FRACTION] || kargs[CROP_SIZE])
: DEFAULT_PLACE;
switch (LETTER) {
case "E":
ACTUAL_VALUE =
ACTUAL_VALUE.toExponential(DEFAULT_PLACE).toUpperCase();
break;
case "e":
ACTUAL_VALUE = ACTUAL_VALUE.toExponential(DEFAULT_PLACE);
break;
case "X":
ACTUAL_VALUE = ACTUAL_VALUE.toString(16).toUpperCase();
break;
case "x":
ACTUAL_VALUE = ACTUAL_VALUE.toString(16); // Hexadecimal
break;
case "b":
ACTUAL_VALUE = ACTUAL_VALUE.toString(2); // Binary
break;
case "f":
case "F":
ACTUAL_VALUE = ACTUAL_VALUE.toFixed(floatSize);
break;
case "o":
ACTUAL_VALUE = ACTUAL_VALUE.toString(8); // Octal
break;
default:
break;
}
// mask
switch (kargs[MASK_NUMBER]) {
case "#":
const MASK = {
x: "0x",
X: "0X",
o: "0o",
b: "0b",
}[LETTER];
ACTUAL_VALUE = MASK + ACTUAL_VALUE;
break;
}
}
// signal
if (
// @ts-expect-error
[..." +-,%"].includes(kargs[FILL_CHAR]) &&
typeof NATUAL_VALUE === "number"
) {
ACTUAL_VALUE = ACTUAL_VALUE.toString().replace("-", "");
if (NATUAL_VALUE >= 0)
switch (kargs[FILL_CHAR]) {
case "+":
ACTUAL_VALUE = "+" + ACTUAL_VALUE;
break;
case " ":
ACTUAL_VALUE = " " + ACTUAL_VALUE;
break;
case ",":
ACTUAL_VALUE = NATUAL_VALUE.toString()
.split(/(?=(?:...)*$)/)
.join(kargs[FILL_CHAR]);
break;
case "%":
ACTUAL_VALUE =
(NATUAL_VALUE * 100).toFixed(
// @ts-expect-error
kargs[FRACTION] || DEFAULT_PLACE,
) + "%";
break;
}
else ACTUAL_VALUE = "-" + ACTUAL_VALUE;
}
// space / order / trim
if (kargs[CROP_SIZE]) {
ACTUAL_VALUE = ACTUAL_VALUE.toString();
const FILL_ELEMENT = kargs[FILL_CHAR] || " ";
const SIZE_STRING = ACTUAL_VALUE.length;
const SIZE_ARG = kargs[CROP_SIZE];
const FILL_LENGTH = SIZE_STRING > SIZE_ARG ? SIZE_STRING : SIZE_ARG;
const FILL = FILL_ELEMENT.repeat(FILL_LENGTH);
switch (kargs[ALIGN_OP] || kargs[FILL_CHAR]) {
case "<":
ACTUAL_VALUE = ACTUAL_VALUE.padEnd(FILL_LENGTH, FILL_ELEMENT);
break;
case ".":
if (!(LETTER && /[fF]/.test(LETTER)))
ACTUAL_VALUE = ACTUAL_VALUE.slice(0, SIZE_ARG);
break;
case ">":
ACTUAL_VALUE = ACTUAL_VALUE.padStart(FILL_LENGTH, FILL_ELEMENT);
break;
case "^":
const length_start = Math.floor((FILL_LENGTH - SIZE_STRING) / 2);
const string_start =
length_start > 0
? FILL_ELEMENT.repeat(length_start) + ACTUAL_VALUE
: ACTUAL_VALUE;
ACTUAL_VALUE = FILL.replace(
RegExp(`.{${string_start.length}}`),
string_start,
);
break;
default:
ACTUAL_VALUE = LETTER
? ACTUAL_VALUE.padStart(FILL_LENGTH, FILL_ELEMENT)
: ACTUAL_VALUE.padEnd(FILL_LENGTH, FILL_ELEMENT);
break;
}
}
}
// SET Definitive value
self = self.replace(pattern, ACTUAL_VALUE);
});
return self;
}
export const format = (inputString: string, ...param: any[]) =>
formatImpl.apply(inputString, param);
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/experimental
## 0.0.104
### Patch Changes
- llamaindex@0.7.3
## 0.0.103
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.103",
"version": "0.0.104",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+17
View File
@@ -1,5 +1,22 @@
# llamaindex
## 0.7.3
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
- @llamaindex/cloud@1.0.3
- @llamaindex/anthropic@0.0.4
- @llamaindex/clip@0.0.4
- @llamaindex/deepinfra@0.0.4
- @llamaindex/huggingface@0.0.4
- @llamaindex/ollama@0.0.11
- @llamaindex/openai@0.1.20
- @llamaindex/portkey-ai@0.0.4
- @llamaindex/replicate@0.0.4
- @llamaindex/groq@0.0.19
## 0.7.2
### Patch Changes
@@ -1,5 +1,11 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.88
### Patch Changes
- llamaindex@0.7.3
## 0.0.87
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.87",
"version": "0.0.88",
"type": "module",
"private": true,
"scripts": {
@@ -1,5 +1,11 @@
# @llamaindex/llama-parse-browser-test
## 0.0.14
### Patch Changes
- @llamaindex/cloud@1.0.3
## 0.0.13
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.13",
"version": "0.0.14",
"type": "module",
"scripts": {
"dev": "vite",
@@ -1,5 +1,11 @@
# @llamaindex/next-agent-test
## 0.1.88
### Patch Changes
- llamaindex@0.7.3
## 0.1.87
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.87",
"version": "0.1.88",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# test-edge-runtime
## 0.1.87
### Patch Changes
- llamaindex@0.7.3
## 0.1.86
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.86",
"version": "0.1.87",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# @llamaindex/next-node-runtime
## 0.0.69
### Patch Changes
- llamaindex@0.7.3
## 0.0.68
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.0.68",
"version": "0.0.69",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# @llamaindex/waku-query-engine-test
## 0.0.88
### Patch Changes
- llamaindex@0.7.3
## 0.0.87
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.87",
"version": "0.0.88",
"type": "module",
"private": true,
"scripts": {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.7.2",
"version": "0.7.3",
"license": "MIT",
"type": "module",
"keywords": [
@@ -40,7 +40,7 @@
"@llamaindex/ollama": "workspace:*",
"@llamaindex/openai": "workspace:*",
"@llamaindex/portkey-ai": "workspace:*",
"@llamaindex/replicate": "workspace:^0.0.3",
"@llamaindex/replicate": "workspace:^0.0.4",
"@mistralai/mistralai": "^1.0.4",
"@mixedbread-ai/sdk": "^2.2.11",
"@pinecone-database/pinecone": "^3.0.2",
@@ -1,5 +1,12 @@
# @llamaindex/anthropic
## 0.0.4
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
## 0.0.3
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/anthropic",
"description": "Anthropic Adapter for LlamaIndex",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+8
View File
@@ -1,5 +1,13 @@
# @llamaindex/clip
## 0.0.4
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
- @llamaindex/openai@0.1.20
## 0.0.3
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/clip",
"description": "Clip Embedding Adapter for LlamaIndex",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
@@ -1,5 +1,13 @@
# @llamaindex/deepinfra
## 0.0.4
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
- @llamaindex/openai@0.1.20
## 0.0.3
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/deepinfra",
"description": "Deepinfra Adapter for LlamaIndex",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/groq
## 0.0.19
### Patch Changes
- @llamaindex/openai@0.1.20
## 0.0.18
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/groq",
"description": "Groq Adapter for LlamaIndex",
"version": "0.0.18",
"version": "0.0.19",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,13 @@
# @llamaindex/huggingface
## 0.0.4
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
- @llamaindex/openai@0.1.20
## 0.0.3
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/huggingface",
"description": "Huggingface Adapter for LlamaIndex",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/ollama
## 0.0.11
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
## 0.0.10
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/ollama",
"description": "Ollama Adapter for LlamaIndex",
"version": "0.0.10",
"version": "0.0.11",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/openai
## 0.1.20
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
## 0.1.19
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/openai",
"description": "OpenAI Adapter for LlamaIndex",
"version": "0.1.19",
"version": "0.1.20",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/portkey-ai
## 0.0.4
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
## 0.0.3
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/portkey-ai",
"description": "Portkey Adapter for LlamaIndex",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/replicate
## 0.0.4
### Patch Changes
- Updated dependencies [0493f67]
- @llamaindex/core@0.3.3
## 0.0.3
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/replicate",
"description": "Replicate Adapter for LlamaIndex",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+1 -14
View File
@@ -8,11 +8,6 @@ overrides:
trim: 1.0.1
protobufjs: 7.2.6
patchedDependencies:
python-format-js@1.4.3:
hash: 2qoyzwmpaczaj2mabgmoz6ccpy
path: patches/python-format-js@1.4.3.patch
importers:
.:
@@ -420,9 +415,6 @@ importers:
natural:
specifier: ^8.0.1
version: 8.0.1(@aws-sdk/credential-providers@3.675.0)
python-format-js:
specifier: ^1.4.3
version: 1.4.3(patch_hash=2qoyzwmpaczaj2mabgmoz6ccpy)
packages/core/tests:
devDependencies:
@@ -564,7 +556,7 @@ importers:
specifier: workspace:*
version: link:../providers/portkey-ai
'@llamaindex/replicate':
specifier: workspace:^0.0.3
specifier: workspace:^0.0.4
version: link:../providers/replicate
'@mistralai/mistralai':
specifier: ^1.0.4
@@ -10326,9 +10318,6 @@ packages:
resolution: {integrity: sha512-FLpr4flz5xZTSJxSeaheeMKN/EDzMdK7b8PTOC6a5PYFKTucWbdqjgqaEyH0shFiSJrVB1+Qqi4Tk19ccU6Aug==}
engines: {node: '>=12.20'}
python-format-js@1.4.3:
resolution: {integrity: sha512-0iK5zP5HMf4F3Xc3Uo6hggPu4ylEQCKNoLXUYe3S1YfYkFG6DxGDO3KozCrySntAZTPmP9yRI+eMq0MXweHqIw==}
qs@6.11.0:
resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==}
engines: {node: '>=0.6'}
@@ -25286,8 +25275,6 @@ snapshots:
dependencies:
escape-goat: 4.0.0
python-format-js@1.4.3(patch_hash=2qoyzwmpaczaj2mabgmoz6ccpy): {}
qs@6.11.0:
dependencies:
side-channel: 1.0.6