@llamaindex/env
Advanced tools
Comparing version 0.1.0 to 0.1.1
# @llamaindex/env | ||
## 0.1.1 | ||
### Patch Changes | ||
- 5596e31: feat: improve `@llamaindex/env` | ||
## 0.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,14 @@ | ||
"use strict"; | ||
/** | ||
* This module is under Node.js environment. | ||
* It provides a set of APIs to interact with the file system, streams, and other Node.js built-in modules. | ||
* | ||
* Use this under "node" condition, | ||
* | ||
* For example: | ||
* ```shell | ||
* node -e "const env = require('@llamaindex/env');" | ||
* ``` | ||
* | ||
* @module | ||
*/ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -3,0 +15,0 @@ value: true |
@@ -1,2 +0,8 @@ | ||
"use strict"; | ||
/** | ||
* This module is under Cloudflare Workers environment. | ||
* | ||
* Most of Node.js APIs are not available in Cloudflare Workers environment. | ||
* | ||
* @module | ||
*/ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -3,0 +9,0 @@ value: true |
@@ -1,2 +0,14 @@ | ||
import { ok } from "node:assert"; | ||
/** | ||
* This module is under Node.js environment. | ||
* It provides a set of APIs to interact with the file system, streams, and other Node.js built-in modules. | ||
* | ||
* Use this under "node" condition, | ||
* | ||
* For example: | ||
* ```shell | ||
* node -e "const env = require('@llamaindex/env');" | ||
* ``` | ||
* | ||
* @module | ||
*/ import { ok } from "node:assert"; | ||
import { createHash, randomUUID } from "node:crypto"; | ||
@@ -3,0 +15,0 @@ import fs from "node:fs/promises"; |
@@ -1,2 +0,8 @@ | ||
import { INTERNAL_ENV } from "./utils.js"; | ||
/** | ||
* This module is under Cloudflare Workers environment. | ||
* | ||
* Most of Node.js APIs are not available in Cloudflare Workers environment. | ||
* | ||
* @module | ||
*/ import { INTERNAL_ENV } from "./utils.js"; | ||
export * from "./index.polyfill.js"; | ||
@@ -3,0 +9,0 @@ export function getEnv(name) { |
@@ -7,2 +7,15 @@ /// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
/** | ||
* This module is under Node.js environment. | ||
* It provides a set of APIs to interact with the file system, streams, and other Node.js built-in modules. | ||
* | ||
* Use this under "node" condition, | ||
* | ||
* For example: | ||
* ```shell | ||
* node -e "const env = require('@llamaindex/env');" | ||
* ``` | ||
* | ||
* @module | ||
*/ | ||
import { ok } from "node:assert"; | ||
@@ -9,0 +22,0 @@ import { randomUUID } from "node:crypto"; |
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
export declare const INTERNAL_ENV: Record<string, string>; | ||
/** | ||
* Set environment variables before using llamaindex, because some LLM need to access API key before running. | ||
* | ||
* You have to set the environment variables in Cloudflare Worker environment, | ||
* because it doesn't have any global environment variables. | ||
* | ||
* @example | ||
* ```ts | ||
* export default { | ||
* async fetch( | ||
* request: Request, | ||
* env: Env, | ||
* ctx: ExecutionContext, | ||
* ): Promise<Response> { | ||
* const { setEnvs } = await import("@llamaindex/env"); | ||
* setEnvs(env); | ||
* // ... | ||
* return new Response("Hello, World!"); | ||
* }, | ||
* }; | ||
* ``` | ||
* | ||
* @param envs Environment variables | ||
*/ | ||
export declare function setEnvs(envs: object): void; | ||
@@ -5,0 +29,0 @@ export declare function getEnv(name: string): string | undefined; |
// DO NOT EXPOSE THIS VARIABLE TO PUBLIC, IT IS USED INTERNALLY FOR CLOUDFLARE WORKER | ||
export const INTERNAL_ENV = {}; | ||
export function setEnvs(envs) { | ||
/** | ||
* Set environment variables before using llamaindex, because some LLM need to access API key before running. | ||
* | ||
* You have to set the environment variables in Cloudflare Worker environment, | ||
* because it doesn't have any global environment variables. | ||
* | ||
* @example | ||
* ```ts | ||
* export default { | ||
* async fetch( | ||
* request: Request, | ||
* env: Env, | ||
* ctx: ExecutionContext, | ||
* ): Promise<Response> { | ||
* const { setEnvs } = await import("@llamaindex/env"); | ||
* setEnvs(env); | ||
* // ... | ||
* return new Response("Hello, World!"); | ||
* }, | ||
* }; | ||
* ``` | ||
* | ||
* @param envs Environment variables | ||
*/ export function setEnvs(envs) { | ||
Object.assign(INTERNAL_ENV, envs); | ||
@@ -5,0 +28,0 @@ } |
{ | ||
"name": "@llamaindex/env", | ||
"description": "environment wrapper", | ||
"version": "0.1.0", | ||
"description": "environment wrapper, supports all JS environment including node, deno, bun, edge runtime, and cloudflare worker", | ||
"version": "0.1.1", | ||
"type": "module", | ||
@@ -70,2 +70,13 @@ "types": "dist/type/index.d.ts", | ||
}, | ||
"peerDependenciesMeta": { | ||
"@aws-crypto/sha256-js": { | ||
"optional": true | ||
}, | ||
"pathe": { | ||
"optional": true | ||
}, | ||
"readable-stream": { | ||
"optional": true | ||
} | ||
}, | ||
"scripts": { | ||
@@ -72,0 +83,0 @@ "build": "rm -rf ./dist && pnpm run build:esm && pnpm run build:cjs && pnpm run build:type", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86632
694