@jaypie/llm 1.2.28 → 1.2.31
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/constants.d.ts +5 -5
- package/dist/cjs/index.cjs +668 -126
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/operate/adapters/AnthropicAdapter.d.ts +29 -2
- package/dist/cjs/operate/adapters/GeminiAdapter.d.ts +11 -1
- package/dist/cjs/operate/adapters/OpenRouterAdapter.d.ts +32 -4
- package/dist/cjs/operate/adapters/XaiAdapter.d.ts +5 -2
- package/dist/esm/constants.d.ts +5 -5
- package/dist/esm/index.js +668 -126
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/AnthropicAdapter.d.ts +29 -2
- package/dist/esm/operate/adapters/GeminiAdapter.d.ts +11 -1
- package/dist/esm/operate/adapters/OpenRouterAdapter.d.ts +32 -4
- package/dist/esm/operate/adapters/XaiAdapter.d.ts +5 -2
- package/package.json +2 -1
|
@@ -6,6 +6,22 @@ import { LlmHistory, LlmOperateOptions, LlmUsageItem } from "../../types/LlmProv
|
|
|
6
6
|
import { LlmStreamChunk } from "../../types/LlmStreamChunk.interface.js";
|
|
7
7
|
import { ClassifiedError, OperateRequest, ParsedResponse, ProviderToolDefinition, StandardToolCall, StandardToolResult } from "../types.js";
|
|
8
8
|
import { BaseProviderAdapter } from "./ProviderAdapter.interface.js";
|
|
9
|
+
/**
|
|
10
|
+
* Local extension of the SDK's `MessageCreateParams` to carry
|
|
11
|
+
* `output_config.format` (Anthropic native structured outputs). The SDK 0.71
|
|
12
|
+
* shipped with the older `output_format` field which the API has since
|
|
13
|
+
* deprecated in favor of `output_config.format`. We send the new shape via
|
|
14
|
+
* an untyped passthrough so callers don't need a newer SDK; remove this
|
|
15
|
+
* extension once the SDK types `output_config` directly.
|
|
16
|
+
*/
|
|
17
|
+
type AnthropicRequestParams = Anthropic.MessageCreateParams & {
|
|
18
|
+
output_config?: {
|
|
19
|
+
format: {
|
|
20
|
+
type: "json_schema";
|
|
21
|
+
schema: JsonObject;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
9
25
|
/**
|
|
10
26
|
* AnthropicAdapter implements the ProviderAdapter interface for Anthropic's API.
|
|
11
27
|
* It handles request building, response parsing, and error classification
|
|
@@ -15,13 +31,23 @@ export declare class AnthropicAdapter extends BaseProviderAdapter {
|
|
|
15
31
|
readonly name: "anthropic";
|
|
16
32
|
readonly defaultModel: "claude-sonnet-4-6";
|
|
17
33
|
private runtimeNoTemperatureModels;
|
|
34
|
+
private runtimeNoStructuredOutputModels;
|
|
18
35
|
rememberModelRejectsTemperature(model: string): void;
|
|
19
36
|
clearRuntimeNoTemperatureModels(): void;
|
|
37
|
+
rememberModelRejectsStructuredOutput(model: string): void;
|
|
38
|
+
clearRuntimeNoStructuredOutputModels(): void;
|
|
20
39
|
private supportsTemperature;
|
|
21
|
-
|
|
22
|
-
|
|
40
|
+
private supportsStructuredOutput;
|
|
41
|
+
buildRequest(request: OperateRequest): AnthropicRequestParams;
|
|
42
|
+
formatTools(toolkit: Toolkit, _outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
23
43
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
24
44
|
executeRequest(client: unknown, request: unknown, signal?: AbortSignal): Promise<Anthropic.Message>;
|
|
45
|
+
/**
|
|
46
|
+
* Rebuild a structured-output request without `output_format`, swapping in
|
|
47
|
+
* the legacy fake-tool emulation. Used as a runtime fallback when a model
|
|
48
|
+
* rejects native `output_config.format`.
|
|
49
|
+
*/
|
|
50
|
+
private toFallbackStructuredOutputRequest;
|
|
25
51
|
executeStreamRequest(client: unknown, request: unknown, signal?: AbortSignal): AsyncIterable<LlmStreamChunk>;
|
|
26
52
|
parseResponse(response: unknown, _options?: LlmOperateOptions): ParsedResponse;
|
|
27
53
|
extractToolCalls(response: unknown): StandardToolCall[];
|
|
@@ -36,3 +62,4 @@ export declare class AnthropicAdapter extends BaseProviderAdapter {
|
|
|
36
62
|
private extractContent;
|
|
37
63
|
}
|
|
38
64
|
export declare const anthropicAdapter: AnthropicAdapter;
|
|
65
|
+
export {};
|
|
@@ -14,10 +14,20 @@ import { GeminiPart, GeminiRawResponse, GeminiRequest } from "../../providers/ge
|
|
|
14
14
|
export declare class GeminiAdapter extends BaseProviderAdapter {
|
|
15
15
|
readonly name: "google";
|
|
16
16
|
readonly defaultModel: "gemini-3.1-pro-preview";
|
|
17
|
+
private runtimeNoStructuredOutputComboModels;
|
|
18
|
+
rememberModelRejectsStructuredOutputCombo(model: string): void;
|
|
19
|
+
clearRuntimeNoStructuredOutputComboModels(): void;
|
|
20
|
+
private supportsStructuredOutputCombo;
|
|
17
21
|
buildRequest(request: OperateRequest): GeminiRequest;
|
|
18
|
-
formatTools(toolkit: Toolkit,
|
|
22
|
+
formatTools(toolkit: Toolkit, _outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
19
23
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
20
24
|
executeRequest(client: unknown, request: unknown, signal?: AbortSignal): Promise<GeminiRawResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Rebuild a Gemini 3 native-combo request without `responseJsonSchema`/
|
|
27
|
+
* `responseMimeType`, swapping in the legacy fake-tool emulation. Used as
|
|
28
|
+
* a runtime fallback when a Gemini 3 model rejects the combo.
|
|
29
|
+
*/
|
|
30
|
+
private toFallbackStructuredOutputRequest;
|
|
21
31
|
executeStreamRequest(client: unknown, request: unknown, signal?: AbortSignal): AsyncIterable<LlmStreamChunk>;
|
|
22
32
|
parseResponse(response: unknown, options?: LlmOperateOptions): ParsedResponse;
|
|
23
33
|
extractToolCalls(response: unknown): StandardToolCall[];
|
|
@@ -59,14 +59,26 @@ interface OpenRouterTool {
|
|
|
59
59
|
parameters: JsonObject;
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
interface OpenRouterJsonSchemaConfig {
|
|
63
|
+
name: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
schema: JsonObject;
|
|
66
|
+
strict?: boolean;
|
|
67
|
+
}
|
|
68
|
+
type OpenRouterResponseFormat = {
|
|
69
|
+
type: "json_schema";
|
|
70
|
+
json_schema: OpenRouterJsonSchemaConfig;
|
|
71
|
+
} | {
|
|
72
|
+
type: "json_object";
|
|
73
|
+
} | {
|
|
74
|
+
type: "text";
|
|
75
|
+
};
|
|
62
76
|
interface OpenRouterRequest {
|
|
63
77
|
model: string;
|
|
64
78
|
messages: OpenRouterMessage[];
|
|
65
79
|
tools?: OpenRouterTool[];
|
|
66
80
|
tool_choice?: "auto" | "none" | "required";
|
|
67
|
-
response_format?:
|
|
68
|
-
type: "json_object" | "text";
|
|
69
|
-
};
|
|
81
|
+
response_format?: OpenRouterResponseFormat;
|
|
70
82
|
user?: string;
|
|
71
83
|
}
|
|
72
84
|
/**
|
|
@@ -85,10 +97,26 @@ type OpenRouterContentPart = {
|
|
|
85
97
|
export declare class OpenRouterAdapter extends BaseProviderAdapter {
|
|
86
98
|
readonly name: "openrouter";
|
|
87
99
|
readonly defaultModel: "anthropic/claude-sonnet-4-6";
|
|
100
|
+
private runtimeNoStructuredOutputModels;
|
|
101
|
+
rememberModelRejectsStructuredOutput(model: string): void;
|
|
102
|
+
clearRuntimeNoStructuredOutputModels(): void;
|
|
103
|
+
private supportsStructuredOutput;
|
|
88
104
|
buildRequest(request: OperateRequest): OpenRouterRequest;
|
|
89
|
-
formatTools(toolkit: Toolkit,
|
|
105
|
+
formatTools(toolkit: Toolkit, _outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
90
106
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
91
107
|
executeRequest(client: unknown, request: unknown, signal?: AbortSignal): Promise<OpenRouterResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* Translate our internal snake_case `OpenRouterRequest` into the SDK's
|
|
110
|
+
* camelCase shape, forwarding only the fields we care about (the SDK
|
|
111
|
+
* silently strips unknown fields).
|
|
112
|
+
*/
|
|
113
|
+
private toSdkChatParams;
|
|
114
|
+
/**
|
|
115
|
+
* Rebuild a structured-output request without `response_format`, swapping in
|
|
116
|
+
* the legacy fake-tool emulation. Used as a runtime fallback when a model
|
|
117
|
+
* rejects native json_schema.
|
|
118
|
+
*/
|
|
119
|
+
private toFallbackStructuredOutputRequest;
|
|
92
120
|
executeStreamRequest(client: unknown, request: unknown, signal?: AbortSignal): AsyncIterable<LlmStreamChunk>;
|
|
93
121
|
parseResponse(response: unknown, _options?: LlmOperateOptions): ParsedResponse;
|
|
94
122
|
extractToolCalls(response: unknown): StandardToolCall[];
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { ClassifiedError } from "../types.js";
|
|
1
2
|
import { OpenAiAdapter } from "./OpenAiAdapter.js";
|
|
2
3
|
/**
|
|
3
4
|
* XaiAdapter extends OpenAiAdapter since xAI (Grok) uses an OpenAI-compatible API.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Name, default model, and transient-ingest-error detection are overridden;
|
|
6
|
+
* all request building, response parsing, tool handling, and streaming are
|
|
7
|
+
* inherited.
|
|
6
8
|
*/
|
|
7
9
|
export declare class XaiAdapter extends OpenAiAdapter {
|
|
8
10
|
readonly name: "xai";
|
|
9
11
|
readonly defaultModel: "grok-4.20-0309-reasoning";
|
|
12
|
+
classifyError(error: unknown): ClassifiedError;
|
|
10
13
|
}
|
|
11
14
|
export declare const xaiAdapter: XaiAdapter;
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare const PROVIDER: {
|
|
|
41
41
|
readonly OPENAI: {
|
|
42
42
|
readonly MODEL: {
|
|
43
43
|
readonly DEFAULT: "gpt-5.4";
|
|
44
|
-
readonly LARGE: "gpt-5.
|
|
44
|
+
readonly LARGE: "gpt-5.5";
|
|
45
45
|
readonly SMALL: "gpt-5.4-mini";
|
|
46
46
|
readonly TINY: "gpt-5.4-nano";
|
|
47
47
|
};
|
|
@@ -81,14 +81,14 @@ export type LlmProviderName = typeof PROVIDER.ANTHROPIC.NAME | typeof PROVIDER.G
|
|
|
81
81
|
export declare const DEFAULT: {
|
|
82
82
|
readonly MODEL: {
|
|
83
83
|
readonly BASE: "gpt-5.4";
|
|
84
|
-
readonly LARGE: "gpt-5.
|
|
84
|
+
readonly LARGE: "gpt-5.5";
|
|
85
85
|
readonly SMALL: "gpt-5.4-mini";
|
|
86
86
|
readonly TINY: "gpt-5.4-nano";
|
|
87
87
|
};
|
|
88
88
|
readonly PROVIDER: {
|
|
89
89
|
readonly MODEL: {
|
|
90
90
|
readonly DEFAULT: "gpt-5.4";
|
|
91
|
-
readonly LARGE: "gpt-5.
|
|
91
|
+
readonly LARGE: "gpt-5.5";
|
|
92
92
|
readonly SMALL: "gpt-5.4-mini";
|
|
93
93
|
readonly TINY: "gpt-5.4-nano";
|
|
94
94
|
};
|
|
@@ -98,8 +98,8 @@ export declare const DEFAULT: {
|
|
|
98
98
|
};
|
|
99
99
|
export declare const ALL: {
|
|
100
100
|
readonly BASE: readonly ["claude-sonnet-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-4.20-0309-reasoning"];
|
|
101
|
-
readonly COMBINED: readonly ("claude-sonnet-4-6" | "claude-opus-4-7" | "claude-haiku-4-5" | "gemini-3.1-pro-preview" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite-preview" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-nano" | "grok-4.20-0309-reasoning" | "grok-4.20-0309-non-reasoning" | "grok-4-1-fast-non-reasoning")[];
|
|
102
|
-
readonly LARGE: readonly ["claude-opus-4-7", "gemini-3.1-pro-preview", "gpt-5.
|
|
101
|
+
readonly COMBINED: readonly ("claude-sonnet-4-6" | "claude-opus-4-7" | "claude-haiku-4-5" | "gemini-3.1-pro-preview" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite-preview" | "gpt-5.4" | "gpt-5.5" | "gpt-5.4-mini" | "gpt-5.4-nano" | "grok-4.20-0309-reasoning" | "grok-4.20-0309-non-reasoning" | "grok-4-1-fast-non-reasoning")[];
|
|
102
|
+
readonly LARGE: readonly ["claude-opus-4-7", "gemini-3.1-pro-preview", "gpt-5.5", "grok-4.20-0309-reasoning"];
|
|
103
103
|
readonly SMALL: readonly ["claude-sonnet-4-6", "gemini-3-flash-preview", "gpt-5.4-mini", "grok-4.20-0309-non-reasoning"];
|
|
104
104
|
readonly TINY: readonly ["claude-haiku-4-5", "gemini-3.1-flash-lite-preview", "gpt-5.4-nano", "grok-4-1-fast-non-reasoning"];
|
|
105
105
|
};
|