@jaypie/llm 1.3.1 → 1.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/dist/cjs/index.cjs +136 -13
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +661 -0
- package/dist/cjs/operate/OperateLoop.d.ts +6 -3
- package/dist/cjs/providers/anthropic/utils.d.ts +2 -1
- package/dist/cjs/providers/bedrock/utils.d.ts +2 -1
- package/dist/cjs/providers/google/utils.d.ts +2 -1
- package/dist/cjs/providers/openai/utils.d.ts +2 -1
- package/dist/cjs/providers/openrouter/utils.d.ts +2 -1
- package/dist/cjs/providers/xai/utils.d.ts +2 -1
- package/dist/cjs/util/index.d.ts +1 -0
- package/dist/cjs/util/logger.d.ts +2 -1
- package/dist/cjs/util/repairFormatKeys.d.ts +19 -0
- package/dist/esm/index.d.ts +661 -16
- package/dist/esm/index.js +136 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/OperateLoop.d.ts +6 -3
- package/dist/esm/providers/anthropic/utils.d.ts +2 -1
- package/dist/esm/providers/bedrock/utils.d.ts +2 -1
- package/dist/esm/providers/google/utils.d.ts +2 -1
- package/dist/esm/providers/openai/utils.d.ts +2 -1
- package/dist/esm/providers/openrouter/utils.d.ts +2 -1
- package/dist/esm/providers/xai/utils.d.ts +2 -1
- package/dist/esm/util/index.d.ts +1 -0
- package/dist/esm/util/logger.d.ts +2 -1
- package/dist/esm/util/repairFormatKeys.d.ts +19 -0
- package/package.json +11 -5
|
@@ -35,9 +35,12 @@ export declare class OperateLoop {
|
|
|
35
35
|
private buildInitialRequest;
|
|
36
36
|
private executeOneTurn;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
* `format` is a schema contract:
|
|
40
|
-
*
|
|
38
|
+
* Reconcile structured output against the declared `format` contract. A
|
|
39
|
+
* declared `format` is a schema contract: returned keys should match the
|
|
40
|
+
* declared names exactly and every declared array field should be present.
|
|
41
|
+
* First repairs keys a provider/model corrupted by wrapping them in literal
|
|
42
|
+
* double quotes (observed on OpenAI for multi-word keys), then backfills any
|
|
43
|
+
* declared array field a provider/model omitted, surfacing it as `[]`.
|
|
41
44
|
*/
|
|
42
45
|
private applyFormatArrayDefaults;
|
|
43
46
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { createLogger } from "@jaypie/logger";
|
|
1
2
|
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
3
|
import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
|
|
3
4
|
import { z } from "zod/v4";
|
|
4
5
|
import { JsonObject, NaturalSchema } from "@jaypie/types";
|
|
5
6
|
export declare function loadSdk(): Promise<typeof import("@anthropic-ai/sdk")>;
|
|
6
|
-
export declare const getLogger: () =>
|
|
7
|
+
export declare const getLogger: () => ReturnType<typeof createLogger>;
|
|
7
8
|
export declare function initializeClient({ apiKey, }?: {
|
|
8
9
|
apiKey?: string;
|
|
9
10
|
}): Promise<Anthropic>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { createLogger } from "@jaypie/logger";
|
|
1
2
|
import type { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
|
|
2
3
|
export declare function loadSdk(): Promise<typeof import("@aws-sdk/client-bedrock-runtime")>;
|
|
3
|
-
export declare const getLogger: () =>
|
|
4
|
+
export declare const getLogger: () => ReturnType<typeof createLogger>;
|
|
4
5
|
export declare function initializeClient({ region, }?: {
|
|
5
6
|
region?: string;
|
|
6
7
|
}): Promise<BedrockRuntimeClient>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { createLogger } from "@jaypie/logger";
|
|
1
2
|
import type { GoogleGenAI } from "@google/genai";
|
|
2
3
|
import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
|
|
3
4
|
export declare function loadSdk(): Promise<typeof import("@google/genai")>;
|
|
4
|
-
export declare const getLogger: () =>
|
|
5
|
+
export declare const getLogger: () => ReturnType<typeof createLogger>;
|
|
5
6
|
export declare function initializeClient({ apiKey, }?: {
|
|
6
7
|
apiKey?: string;
|
|
7
8
|
}): Promise<GoogleGenAI>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { createLogger } from "@jaypie/logger";
|
|
1
2
|
import { JsonObject, NaturalSchema } from "@jaypie/types";
|
|
2
3
|
import { OpenAI } from "openai";
|
|
3
4
|
import { z } from "zod/v4";
|
|
4
5
|
import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
|
|
5
|
-
export declare const getLogger: () =>
|
|
6
|
+
export declare const getLogger: () => ReturnType<typeof createLogger>;
|
|
6
7
|
export declare function initializeClient({ apiKey, }?: {
|
|
7
8
|
apiKey?: string;
|
|
8
9
|
}): Promise<OpenAI>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { createLogger } from "@jaypie/logger";
|
|
1
2
|
import type { OpenRouter } from "@openrouter/sdk";
|
|
2
3
|
import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
|
|
3
4
|
export declare function loadSdk(): Promise<typeof import("@openrouter/sdk")>;
|
|
4
|
-
export declare const getLogger: () =>
|
|
5
|
+
export declare const getLogger: () => ReturnType<typeof createLogger>;
|
|
5
6
|
export declare function initializeClient({ apiKey, }?: {
|
|
6
7
|
apiKey?: string;
|
|
7
8
|
}): Promise<OpenRouter>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { createLogger } from "@jaypie/logger";
|
|
1
2
|
import { OpenAI } from "openai";
|
|
2
|
-
export declare const getLogger: () =>
|
|
3
|
+
export declare const getLogger: () => ReturnType<typeof createLogger>;
|
|
3
4
|
export declare function initializeClient({ apiKey, }?: {
|
|
4
5
|
apiKey?: string;
|
|
5
6
|
}): Promise<OpenAI>;
|
package/dist/esm/util/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { createLogger } from "@jaypie/logger";
|
|
2
|
+
export declare const getLogger: () => ReturnType<typeof createLogger>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { JsonObject, NaturalSchema } from "@jaypie/types";
|
|
3
|
+
type Format = JsonObject | NaturalSchema | z.ZodType;
|
|
4
|
+
/**
|
|
5
|
+
* Repair structured-output keys that a provider/model corrupted by wrapping
|
|
6
|
+
* them in literal double quotes (observed on OpenAI for multi-word `format`
|
|
7
|
+
* keys: `Merchant Request` returned as `"Merchant Request"`). A declared
|
|
8
|
+
* `format` is a schema contract: returned keys should match the declared names
|
|
9
|
+
* exactly. Any returned key whose de-quoted form matches a declared key is
|
|
10
|
+
* renamed back to the declared key.
|
|
11
|
+
*
|
|
12
|
+
* Only mutates a (cloned) structured object; strings and non-objects pass
|
|
13
|
+
* through untouched.
|
|
14
|
+
*/
|
|
15
|
+
export declare function repairFormatKeys({ content, format, }: {
|
|
16
|
+
content: JsonObject;
|
|
17
|
+
format: Format;
|
|
18
|
+
}): JsonObject;
|
|
19
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaypie/llm",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Large language model utilities",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/esm/index.d.ts",
|
|
17
|
+
"default": "./dist/esm/index.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/cjs/index.d.cts",
|
|
21
|
+
"default": "./dist/cjs/index.cjs"
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -48,7 +53,8 @@
|
|
|
48
53
|
"@aws-sdk/client-bedrock-runtime": "^3.1045.0",
|
|
49
54
|
"@google/genai": "^1.30.0",
|
|
50
55
|
"@jaypie/types": "*",
|
|
51
|
-
"@openrouter/sdk": "^0.1.27"
|
|
56
|
+
"@openrouter/sdk": "^0.1.27",
|
|
57
|
+
"rollup-plugin-dts": "^6.1.1"
|
|
52
58
|
},
|
|
53
59
|
"peerDependencies": {
|
|
54
60
|
"@anthropic-ai/sdk": "^0.71.0",
|