@jaypie/llm 1.2.25 → 1.2.27

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.
@@ -5,7 +5,7 @@ export declare const PROVIDER: {
5
5
  };
6
6
  readonly MODEL: {
7
7
  readonly DEFAULT: "claude-sonnet-4-6";
8
- readonly LARGE: "claude-opus-4-6";
8
+ readonly LARGE: "claude-opus-4-7";
9
9
  readonly SMALL: "claude-sonnet-4-6";
10
10
  readonly TINY: "claude-haiku-4-5";
11
11
  };
@@ -51,7 +51,7 @@ export declare const PROVIDER: {
51
51
  readonly OPENROUTER: {
52
52
  readonly MODEL: {
53
53
  readonly DEFAULT: "anthropic/claude-sonnet-4-6";
54
- readonly LARGE: "anthropic/claude-opus-4-6";
54
+ readonly LARGE: "anthropic/claude-opus-4-7";
55
55
  readonly SMALL: "anthropic/claude-sonnet-4-6";
56
56
  readonly TINY: "anthropic/claude-haiku-4-5";
57
57
  };
@@ -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-6" | "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-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.4", "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
  };
@@ -17,7 +17,7 @@ const FIRST_CLASS_PROVIDER = {
17
17
  // https://docs.anthropic.com/en/docs/about-claude/models/overview
18
18
  ANTHROPIC: {
19
19
  DEFAULT: "claude-sonnet-4-6",
20
- LARGE: "claude-opus-4-6",
20
+ LARGE: "claude-opus-4-7",
21
21
  SMALL: "claude-sonnet-4-6",
22
22
  TINY: "claude-haiku-4-5",
23
23
  },
@@ -1065,6 +1065,24 @@ const NOT_RETRYABLE_ERROR_NAMES = [
1065
1065
  "NotFoundError",
1066
1066
  "PermissionDeniedError",
1067
1067
  ];
1068
+ // Models known not to accept `temperature`.
1069
+ // Patterns (not exact names) so dated variants and future releases are covered
1070
+ // without code changes — Anthropic is trending toward removing temperature on
1071
+ // newer Claude models.
1072
+ const MODELS_WITHOUT_TEMPERATURE = [
1073
+ /^claude-opus-4-[789]/,
1074
+ /^claude-opus-[5-9]/,
1075
+ ];
1076
+ function isTemperatureDeprecationError(error) {
1077
+ if (!error || typeof error !== "object")
1078
+ return false;
1079
+ const err = error;
1080
+ const name = error?.constructor?.name;
1081
+ if (name !== "BadRequestError" && err.status !== 400)
1082
+ return false;
1083
+ const messages = [err.message, err.error?.message].filter((m) => typeof m === "string");
1084
+ return messages.some((m) => m.toLowerCase().includes("temperature"));
1085
+ }
1068
1086
  //
1069
1087
  //
1070
1088
  // Main
@@ -1079,6 +1097,20 @@ class AnthropicAdapter extends BaseProviderAdapter {
1079
1097
  super(...arguments);
1080
1098
  this.name = PROVIDER.ANTHROPIC.NAME;
1081
1099
  this.defaultModel = PROVIDER.ANTHROPIC.MODEL.DEFAULT;
1100
+ // Session-level cache of models observed to reject `temperature` at runtime.
1101
+ // Populated by executeRequest on 400 errors so repeat calls skip the param.
1102
+ this.runtimeNoTemperatureModels = new Set();
1103
+ }
1104
+ rememberModelRejectsTemperature(model) {
1105
+ this.runtimeNoTemperatureModels.add(model);
1106
+ }
1107
+ clearRuntimeNoTemperatureModels() {
1108
+ this.runtimeNoTemperatureModels.clear();
1109
+ }
1110
+ supportsTemperature(model) {
1111
+ if (this.runtimeNoTemperatureModels.has(model))
1112
+ return false;
1113
+ return !MODELS_WITHOUT_TEMPERATURE.some((pattern) => pattern.test(model));
1082
1114
  }
1083
1115
  //
1084
1116
  // Request Building
@@ -1170,6 +1202,11 @@ class AnthropicAdapter extends BaseProviderAdapter {
1170
1202
  if (request.temperature !== undefined) {
1171
1203
  anthropicRequest.temperature = request.temperature;
1172
1204
  }
1205
+ // Strip temperature for models that don't support it (denylist + runtime cache)
1206
+ if (anthropicRequest.temperature !== undefined &&
1207
+ !this.supportsTemperature(anthropicRequest.model)) {
1208
+ delete anthropicRequest.temperature;
1209
+ }
1173
1210
  return anthropicRequest;
1174
1211
  }
1175
1212
  formatTools(toolkit, outputSchema) {
@@ -1220,22 +1257,48 @@ class AnthropicAdapter extends BaseProviderAdapter {
1220
1257
  //
1221
1258
  async executeRequest(client, request, signal) {
1222
1259
  const anthropic = client;
1260
+ const anthropicRequest = request;
1223
1261
  try {
1224
- return (await anthropic.messages.create(request, signal ? { signal } : undefined));
1262
+ return (await anthropic.messages.create(anthropicRequest, signal ? { signal } : undefined));
1225
1263
  }
1226
1264
  catch (error) {
1227
1265
  if (signal?.aborted)
1228
1266
  return undefined;
1267
+ // If the model rejected `temperature`, cache it and retry without the param
1268
+ if (anthropicRequest.temperature !== undefined &&
1269
+ isTemperatureDeprecationError(error)) {
1270
+ this.rememberModelRejectsTemperature(anthropicRequest.model);
1271
+ const retryRequest = { ...anthropicRequest };
1272
+ delete retryRequest.temperature;
1273
+ return (await anthropic.messages.create(retryRequest, signal ? { signal } : undefined));
1274
+ }
1229
1275
  throw error;
1230
1276
  }
1231
1277
  }
1232
1278
  async *executeStreamRequest(client, request, signal) {
1233
1279
  const anthropic = client;
1234
- const streamRequest = {
1280
+ let streamRequest = {
1235
1281
  ...request,
1236
1282
  stream: true,
1237
1283
  };
1238
- const stream = await anthropic.messages.create(streamRequest, signal ? { signal } : undefined);
1284
+ let stream;
1285
+ try {
1286
+ stream = await anthropic.messages.create(streamRequest, signal ? { signal } : undefined);
1287
+ }
1288
+ catch (error) {
1289
+ if (streamRequest.temperature !== undefined &&
1290
+ isTemperatureDeprecationError(error)) {
1291
+ this.rememberModelRejectsTemperature(streamRequest.model);
1292
+ streamRequest = {
1293
+ ...streamRequest,
1294
+ };
1295
+ delete streamRequest.temperature;
1296
+ stream = await anthropic.messages.create(streamRequest, signal ? { signal } : undefined);
1297
+ }
1298
+ else {
1299
+ throw error;
1300
+ }
1301
+ }
1239
1302
  // Track current tool call being built
1240
1303
  let currentToolCall = null;
1241
1304
  // Track usage for final chunk