@jaypie/llm 1.3.9 → 1.3.10
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 +53 -4
- package/dist/cjs/index.cjs +351 -122
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +65 -6
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/operate/adapters/AnthropicAdapter.d.ts +3 -2
- package/dist/cjs/operate/adapters/BedrockAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/GoogleAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/OpenAiAdapter.d.ts +7 -1
- package/dist/cjs/operate/adapters/OpenRouterAdapter.d.ts +5 -1
- package/dist/cjs/operate/adapters/XaiAdapter.d.ts +11 -1
- package/dist/cjs/operate/types.d.ts +3 -0
- package/dist/cjs/providers/google/types.d.ts +5 -0
- package/dist/cjs/types/LlmProvider.interface.d.ts +9 -0
- package/dist/cjs/util/effort.d.ts +42 -0
- package/dist/esm/constants.d.ts +53 -4
- package/dist/esm/index.d.ts +65 -6
- package/dist/esm/index.js +351 -122
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/AnthropicAdapter.d.ts +3 -2
- package/dist/esm/operate/adapters/BedrockAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/GoogleAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/OpenAiAdapter.d.ts +7 -1
- package/dist/esm/operate/adapters/OpenRouterAdapter.d.ts +5 -1
- package/dist/esm/operate/adapters/XaiAdapter.d.ts +11 -1
- package/dist/esm/operate/types.d.ts +3 -0
- package/dist/esm/providers/google/types.d.ts +5 -0
- package/dist/esm/types/LlmProvider.interface.d.ts +9 -0
- package/dist/esm/util/effort.d.ts +42 -0
- package/package.json +1 -1
|
@@ -16,7 +16,8 @@ import { BaseProviderAdapter } from "./ProviderAdapter.interface.js";
|
|
|
16
16
|
*/
|
|
17
17
|
type AnthropicRequestParams = Anthropic.MessageCreateParams & {
|
|
18
18
|
output_config?: {
|
|
19
|
-
|
|
19
|
+
effort?: string;
|
|
20
|
+
format?: {
|
|
20
21
|
type: "json_schema";
|
|
21
22
|
schema: JsonObject;
|
|
22
23
|
};
|
|
@@ -29,7 +30,7 @@ type AnthropicRequestParams = Anthropic.MessageCreateParams & {
|
|
|
29
30
|
*/
|
|
30
31
|
export declare class AnthropicAdapter extends BaseProviderAdapter {
|
|
31
32
|
readonly name: "anthropic";
|
|
32
|
-
readonly defaultModel:
|
|
33
|
+
readonly defaultModel: string;
|
|
33
34
|
private runtimeNoTemperatureModels;
|
|
34
35
|
private runtimeNoStructuredOutputModels;
|
|
35
36
|
rememberModelRejectsTemperature(model: string): void;
|
|
@@ -49,7 +49,7 @@ type AnnotatedBedrockResponse = ConverseCommandOutput & {
|
|
|
49
49
|
};
|
|
50
50
|
export declare class BedrockAdapter extends BaseProviderAdapter {
|
|
51
51
|
readonly name: "bedrock";
|
|
52
|
-
readonly defaultModel: "amazon.nova-
|
|
52
|
+
readonly defaultModel: "amazon.nova-pro-v1:0";
|
|
53
53
|
private _modelsFallbackToStructuredOutputTool;
|
|
54
54
|
private _modelsWithoutTemperature;
|
|
55
55
|
private rememberModelRejectsOutputConfig;
|
|
@@ -13,7 +13,7 @@ import { GeminiPart, GeminiRawResponse, GeminiRequest } from "../../providers/go
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class GoogleAdapter extends BaseProviderAdapter {
|
|
15
15
|
readonly name: "google";
|
|
16
|
-
readonly defaultModel:
|
|
16
|
+
readonly defaultModel: string;
|
|
17
17
|
private runtimeNoStructuredOutputComboModels;
|
|
18
18
|
rememberModelRejectsStructuredOutputCombo(model: string): void;
|
|
19
19
|
clearRuntimeNoStructuredOutputComboModels(): void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { JsonObject, NaturalSchema } from "@jaypie/types";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
+
import { type LlmEffort } from "../../constants.js";
|
|
4
|
+
import { type LlmEffortMapping } from "../../util/effort.js";
|
|
3
5
|
import { Toolkit } from "../../tools/Toolkit.class.js";
|
|
4
6
|
import { LlmHistory, LlmOperateOptions, LlmToolResult, LlmUsageItem } from "../../types/LlmProvider.interface.js";
|
|
5
7
|
import { LlmStreamChunk } from "../../types/LlmStreamChunk.interface.js";
|
|
@@ -12,11 +14,15 @@ import { BaseProviderAdapter } from "./ProviderAdapter.interface.js";
|
|
|
12
14
|
*/
|
|
13
15
|
export declare class OpenAiAdapter extends BaseProviderAdapter {
|
|
14
16
|
readonly name: "openai";
|
|
15
|
-
readonly defaultModel:
|
|
17
|
+
readonly defaultModel: string;
|
|
16
18
|
private runtimeNoTemperatureModels;
|
|
17
19
|
rememberModelRejectsTemperature(model: string): void;
|
|
18
20
|
clearRuntimeNoTemperatureModels(): void;
|
|
19
21
|
private supportsTemperature;
|
|
22
|
+
/** Whether `reasoning.effort` may be sent for this model. Overridden by xAI. */
|
|
23
|
+
protected supportsReasoningEffort(model: string): boolean;
|
|
24
|
+
/** Translate a normalized effort to this provider's `reasoning.effort` value. */
|
|
25
|
+
protected mapReasoningEffort(effort: LlmEffort, model: string): LlmEffortMapping;
|
|
20
26
|
buildRequest(request: OperateRequest): unknown;
|
|
21
27
|
formatTools(toolkit: Toolkit, _outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
22
28
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -79,6 +79,10 @@ interface OpenRouterRequest {
|
|
|
79
79
|
tools?: OpenRouterTool[];
|
|
80
80
|
tool_choice?: "auto" | "none" | "required";
|
|
81
81
|
response_format?: OpenRouterResponseFormat;
|
|
82
|
+
reasoning?: {
|
|
83
|
+
effort?: string;
|
|
84
|
+
max_tokens?: number;
|
|
85
|
+
};
|
|
82
86
|
user?: string;
|
|
83
87
|
}
|
|
84
88
|
/**
|
|
@@ -111,7 +115,7 @@ type OpenRouterContentPart = {
|
|
|
111
115
|
*/
|
|
112
116
|
export declare class OpenRouterAdapter extends BaseProviderAdapter {
|
|
113
117
|
readonly name: "openrouter";
|
|
114
|
-
readonly defaultModel:
|
|
118
|
+
readonly defaultModel: string;
|
|
115
119
|
private runtimeNoStructuredOutputModels;
|
|
116
120
|
rememberModelRejectsStructuredOutput(model: string): void;
|
|
117
121
|
clearRuntimeNoStructuredOutputModels(): void;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type LlmEffort } from "../../constants.js";
|
|
2
|
+
import { type LlmEffortMapping } from "../../util/effort.js";
|
|
1
3
|
import { ClassifiedError } from "../types.js";
|
|
2
4
|
import { OpenAiAdapter } from "./OpenAiAdapter.js";
|
|
3
5
|
/**
|
|
@@ -8,7 +10,15 @@ import { OpenAiAdapter } from "./OpenAiAdapter.js";
|
|
|
8
10
|
*/
|
|
9
11
|
export declare class XaiAdapter extends OpenAiAdapter {
|
|
10
12
|
readonly name: "xai";
|
|
11
|
-
readonly defaultModel:
|
|
13
|
+
readonly defaultModel: string;
|
|
14
|
+
/**
|
|
15
|
+
* Grok gates reasoning effort by model, not by the OpenAI `gpt-*`/`o*`
|
|
16
|
+
* patterns. Only explicit `*-reasoning` models accept `reasoning_effort`;
|
|
17
|
+
* bare grok-4 reasons implicitly and rejects it, so we stay conservative and
|
|
18
|
+
* only opt in models whose name advertises reasoning.
|
|
19
|
+
*/
|
|
20
|
+
protected supportsReasoningEffort(model: string): boolean;
|
|
21
|
+
protected mapReasoningEffort(effort: LlmEffort): LlmEffortMapping;
|
|
12
22
|
classifyError(error: unknown): ClassifiedError;
|
|
13
23
|
}
|
|
14
24
|
export declare const xaiAdapter: XaiAdapter;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JsonObject } from "@jaypie/types";
|
|
2
|
+
import { type LlmEffort } from "../constants.js";
|
|
2
3
|
import { LlmHistory, LlmMessageType, LlmOperateOptions, LlmUsageItem } from "../types/LlmProvider.interface.js";
|
|
3
4
|
import { Toolkit } from "../tools/Toolkit.class.js";
|
|
4
5
|
/**
|
|
@@ -68,6 +69,8 @@ export interface OperateRequest {
|
|
|
68
69
|
tools?: ProviderToolDefinition[];
|
|
69
70
|
/** Structured output format */
|
|
70
71
|
format?: JsonObject;
|
|
72
|
+
/** Normalized reasoning effort; adapters translate to provider-native control */
|
|
73
|
+
effort?: LlmEffort;
|
|
71
74
|
/** Provider-specific options */
|
|
72
75
|
providerOptions?: JsonObject;
|
|
73
76
|
/** Whether the request will execute over a streaming transport */
|
|
@@ -73,6 +73,11 @@ export interface GeminiGenerateContentConfig {
|
|
|
73
73
|
responseMimeType?: string;
|
|
74
74
|
responseJsonSchema?: JsonObject;
|
|
75
75
|
responseSchema?: JsonObject;
|
|
76
|
+
thinkingConfig?: {
|
|
77
|
+
thinkingLevel?: string;
|
|
78
|
+
thinkingBudget?: number;
|
|
79
|
+
includeThoughts?: boolean;
|
|
80
|
+
};
|
|
76
81
|
temperature?: number;
|
|
77
82
|
topP?: number;
|
|
78
83
|
topK?: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnyValue, JsonObject, JsonReturn, NaturalMap, NaturalSchema } from "@jaypie/types";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
+
import { type LlmEffort } from "../constants.js";
|
|
3
4
|
import { LlmTool } from "./LlmTool.interface.js";
|
|
4
5
|
import { LlmStreamChunk } from "./LlmStreamChunk.interface.js";
|
|
5
6
|
import { Toolkit } from "../tools/Toolkit.class.js";
|
|
@@ -213,6 +214,14 @@ export interface LlmProgressEvent {
|
|
|
213
214
|
export type LlmProgressCallback = (event: LlmProgressEvent) => unknown | Promise<unknown>;
|
|
214
215
|
export interface LlmOperateOptions {
|
|
215
216
|
data?: NaturalMap;
|
|
217
|
+
/**
|
|
218
|
+
* Provider-neutral reasoning effort (lowest | low | medium | high | highest).
|
|
219
|
+
* Each provider translates it to its native control, spreading the scale
|
|
220
|
+
* across the provider's range; omitting it leaves the provider default
|
|
221
|
+
* untouched, so it is safe across a fallback chain. Providers without
|
|
222
|
+
* reasoning control ignore it.
|
|
223
|
+
*/
|
|
224
|
+
effort?: LlmEffort;
|
|
216
225
|
explain?: boolean;
|
|
217
226
|
/** Chain of fallback providers to try if primary fails. Set to false to disable instance-level fallback. */
|
|
218
227
|
fallback?: LlmFallbackConfig[] | false;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type LlmEffort } from "../constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* Result of translating the provider-neutral {@link LlmEffort} scale to a
|
|
4
|
+
* provider's native reasoning control.
|
|
5
|
+
*/
|
|
6
|
+
export interface LlmEffortMapping<T extends string | number = string> {
|
|
7
|
+
/**
|
|
8
|
+
* True when the requested neutral level had no distinct native rung and was
|
|
9
|
+
* collapsed or clamped onto a neighbor (e.g. `highest` -> Grok `high`, or
|
|
10
|
+
* `highest` -> OpenAI `high` on a model predating `xhigh`). Adapters log
|
|
11
|
+
* these at debug so a papered-over request stays on the record.
|
|
12
|
+
*/
|
|
13
|
+
papered: boolean;
|
|
14
|
+
/** Native effort value for the target provider. */
|
|
15
|
+
value: T;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Per-provider translation of the provider-neutral {@link LlmEffort} scale.
|
|
19
|
+
*
|
|
20
|
+
* The neutral enum (lowest → low → medium → high → highest) is a relative
|
|
21
|
+
* five-point scale. Each table below maps it onto the target provider's native
|
|
22
|
+
* effort control, keeping `medium`/`high` semantically aligned across providers
|
|
23
|
+
* and using each provider's extra bottom (`minimal`) or top (`xhigh`/`max`)
|
|
24
|
+
* rung where one exists. Providers with fewer levels collapse the ends and mark
|
|
25
|
+
* the result `papered`. A single `effort` value is therefore safe to reuse
|
|
26
|
+
* across providers and fallback chains.
|
|
27
|
+
*/
|
|
28
|
+
/** Consistent debug message for a papered-over effort level. */
|
|
29
|
+
export declare function paperedEffortMessage({ model, provider, requested, value, }: {
|
|
30
|
+
model: string;
|
|
31
|
+
provider: string;
|
|
32
|
+
requested: LlmEffort;
|
|
33
|
+
value: string | number;
|
|
34
|
+
}): string;
|
|
35
|
+
export declare function toOpenAiEffort(effort: LlmEffort, { model }: {
|
|
36
|
+
model: string;
|
|
37
|
+
}): LlmEffortMapping;
|
|
38
|
+
export declare function toXaiEffort(effort: LlmEffort): LlmEffortMapping;
|
|
39
|
+
export declare function toAnthropicEffort(effort: LlmEffort): LlmEffortMapping;
|
|
40
|
+
export declare function toGeminiThinkingLevel(effort: LlmEffort): LlmEffortMapping;
|
|
41
|
+
export declare function toGeminiThinkingBudget(effort: LlmEffort): LlmEffortMapping<number>;
|
|
42
|
+
export declare function toOpenRouterEffort(effort: LlmEffort): LlmEffortMapping;
|