llm-exe 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-exe",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "Simplify building LLM-powered apps with easy-to-use base components, supporting text and chat-based prompts with handlebars template engine, output parsers, and flexible function calling capabilities.",
5
5
  "keywords": [
6
6
  "ai",
@@ -38,7 +38,7 @@
38
38
  "typecheck": "tsc --noEmit",
39
39
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.ts --detectOpenHandles --coverage --forceExit",
40
40
  "test-examples": "eval $(cat .env) NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.examples.ts --detectOpenHandles --coverage --forceExit",
41
- "test-one": "eval $(cat .env) NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --coverage --forceExit --config jest.config.examples.ts examples/intentBot.test.ts",
41
+ "test-one": "eval $(cat .env) NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --coverage --forceExit --config jest.config.examples.ts examples/helloWorld.test.ts",
42
42
  "run-one": "eval $(cat .env) ts-node ./examples/chains/self-refinement/usage.ts",
43
43
  "build": "(concurrently \"tsc --p ./tsconfig.json -w\" \"tsc-alias -p tsconfig.json -w\")",
44
44
  "build:ci": "tsup src/index.ts --format cjs,esm --dts --clean",
@@ -46,9 +46,10 @@
46
46
  "build:package": "tsup src/index.ts --format cjs,esm --dts --clean --external jsonschema,json-schema-to-ts,exponential-backoff,@aws-sdk/credential-providers,@aws-crypto/sha256-js,@smithy/protocol-http,@smithy/signature-v4",
47
47
  "build:docs-examples": "./node_modules/.bin/esbuild examples/prompt/index.ts examples/state/index.ts --bundle --outdir=docs/.vitepress/components/examples --platform=node --target=es6 --format=esm",
48
48
  "build:watch:docs-examples": "./node_modules/.bin/esbuild examples/prompt/index.ts examples/state/index.ts --watch --bundle --outdir=docs/.vitepress/components/examples --platform=node --target=es6 --format=esm",
49
- "predocs:build": "npm run build:docs-examples",
49
+ "predocs:build": "npm run build:docs-examples && bash scripts/generate-llms-txt.sh",
50
50
  "docs:dev": "eval $(cat docs/.env) && concurrently \"vitepress dev docs\" \"npm run build:watch:docs-examples\"",
51
51
  "docs:build": "eval $(cat docs/.env) && vitepress build docs",
52
+ "docs:update-providers": "node docs/.vitepress/scripts/updateProviders.js",
52
53
  "lint": "eslint .",
53
54
  "format:check": "prettier --check \"src\"",
54
55
  "format:write": "prettier --write \"src\"",
@@ -65,6 +66,7 @@
65
66
  "handlebars": "4.7.8",
66
67
  "json-schema-to-ts": "3.1.1",
67
68
  "jsonschema": "1.5.0",
69
+ "shiki": "^3.8.1",
68
70
  "uuid": "10.0.0"
69
71
  },
70
72
  "devDependencies": {
package/readme.md CHANGED
@@ -41,6 +41,8 @@ const llmExe = require("llm-exe");
41
41
  ## Overview
42
42
 
43
43
  ```ts
44
+ import { useLlm, createChatPrompt, createParser, createLlmExecutor, defineSchema } from "llm-exe";
45
+
44
46
  // Prompt
45
47
  const prompt = createChatPrompt("You are a support agent. Help the user.");
46
48
  prompt.addUserMessage("I need help with my order.");
@@ -48,8 +50,16 @@ prompt.addUserMessage("I need help with my order.");
48
50
  // LLM
49
51
  const llm = useLlm("openai.gpt-4o");
50
52
 
51
- // Parser
52
- const parser = createParser("json", { schema: mySchema });
53
+ // Parser — schema uses JSON Schema (via defineSchema)
54
+ const schema = defineSchema({
55
+ type: "object",
56
+ properties: {
57
+ answer: { type: "string" },
58
+ action: { type: "string" },
59
+ },
60
+ required: ["answer", "action"],
61
+ } as const);
62
+ const parser = createParser("json", { schema });
53
63
 
54
64
  // Executor
55
65
  const executor = createLlmExecutor({ llm, prompt, parser });
@@ -71,11 +81,17 @@ Welcome back!
71
81
  #### Built-In Parsers
72
82
 
73
83
  ```ts
74
- createParser("stringExtract", { enum: ["yes", "no"] });
75
- createParser("listToJson");
76
- createParser("listToArray");
77
- createParser("markdownCodeBlock");
78
- // ...etc
84
+ createParser("string"); // pass-through, returns string
85
+ createParser("json", { schema }); // JSON with optional schema validation
86
+ createParser("boolean"); // extracts boolean from response
87
+ createParser("number"); // extracts number from response
88
+ createParser("stringExtract", { enum: ["yes", "no"] }); // match one of the enum values
89
+ createParser("listToArray"); // newline-separated list → string[]
90
+ createParser("listToJson"); // key: value list → object (with optional schema)
91
+ createParser("listToKeyValue"); // key: value list → Array<{ key, value }>
92
+ createParser("markdownCodeBlock"); // single code block → { code, language }
93
+ createParser("markdownCodeBlocks"); // multiple code blocks → Array<{ code, language }>
94
+ createParser("replaceStringTemplate"); // handlebars-based output templating
79
95
  ```
80
96
 
81
97
  #### Custom Parsers