genai-lite 0.14.0 → 0.14.1

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.
@@ -208,7 +208,12 @@ class AnthropicClientAdapter {
208
208
  };
209
209
  }
210
210
  prepareMessageRequest(request, apiKey, options) {
211
- // Check if structured output is requested - need beta API
211
+ const hasTemperature = request.settings.temperature !== undefined;
212
+ const hasTopP = request.settings.topP !== undefined;
213
+ if (hasTemperature && hasTopP) {
214
+ throw new Error("Invalid Anthropic settings: temperature and topP cannot both be specified");
215
+ }
216
+ // Check if generally available structured output is requested.
212
217
  const useStructuredOutput = !!(request.settings.structuredOutput?.schema &&
213
218
  request.settings.structuredOutput.enabled !== false);
214
219
  // Initialize Anthropic client
@@ -229,8 +234,8 @@ class AnthropicClientAdapter {
229
234
  model: request.modelId,
230
235
  messages: messages,
231
236
  max_tokens: request.settings.maxTokens,
232
- temperature: request.settings.temperature,
233
- top_p: request.settings.topP,
237
+ ...(hasTemperature && { temperature: request.settings.temperature }),
238
+ ...(hasTopP && { top_p: request.settings.topP }),
234
239
  ...(request.settings.topK !== undefined && {
235
240
  top_k: request.settings.topK,
236
241
  }),
@@ -77,6 +77,11 @@ class RequestValidator {
77
77
  */
78
78
  validateSettings(settings, providerId, modelId) {
79
79
  const settingsValidationErrors = (0, config_1.validateLLMSettings)(settings);
80
+ if (providerId === "anthropic" &&
81
+ settings.temperature !== undefined &&
82
+ settings.topP !== undefined) {
83
+ settingsValidationErrors.push("Anthropic requests cannot specify both temperature and topP; choose one sampler");
84
+ }
80
85
  if (settingsValidationErrors.length > 0) {
81
86
  return {
82
87
  provider: providerId,
@@ -72,6 +72,20 @@ class SettingsManager {
72
72
  }
73
73
  : undefined,
74
74
  };
75
+ if (providerId === "anthropic") {
76
+ const hasExplicitTemperature = requestSettings?.temperature !== undefined;
77
+ const hasExplicitTopP = requestSettings?.topP !== undefined;
78
+ // Anthropic models may reject requests containing both samplers. Preserve
79
+ // the caller-selected sampler; otherwise retain only the temperature
80
+ // default. Explicit conflicts are rejected earlier by RequestValidator,
81
+ // while this precedence keeps direct SettingsManager use transport-safe.
82
+ if (hasExplicitTopP && !hasExplicitTemperature) {
83
+ delete mergedSettings.temperature;
84
+ }
85
+ else {
86
+ delete mergedSettings.topP;
87
+ }
88
+ }
75
89
  // Log the final settings for debugging
76
90
  this.logger.debug(`Merged settings for ${providerId}/${modelId}:`, {
77
91
  temperature: mergedSettings.temperature,
@@ -304,11 +304,17 @@ export interface OpenRouterProviderSettings {
304
304
  * Configurable settings for LLM requests
305
305
  */
306
306
  export interface LLMSettings {
307
- /** Controls randomness in the response (0.0 to 2.0, typically 0.0 to 1.0) */
307
+ /**
308
+ * Controls randomness in the response (0.0 to 2.0, typically 0.0 to 1.0).
309
+ * Mutually exclusive with topP for Anthropic requests.
310
+ */
308
311
  temperature?: number;
309
312
  /** Maximum number of tokens to generate in the response */
310
313
  maxTokens?: number;
311
- /** Controls diversity via nucleus sampling (0.0 to 1.0) */
314
+ /**
315
+ * Controls diversity via nucleus sampling (0.0 to 1.0).
316
+ * Mutually exclusive with temperature for Anthropic requests.
317
+ */
312
318
  topP?: number;
313
319
  /** Sequences where the API will stop generating further tokens */
314
320
  stopSequences?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genai-lite",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "A lightweight, portable toolkit for interacting with various Generative AI APIs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "test:e2e:reasoning": "npm run build && jest --config jest.e2e.config.js reasoning.e2e.test.ts"
47
47
  },
48
48
  "dependencies": {
49
- "@anthropic-ai/sdk": "^0.110.0",
49
+ "@anthropic-ai/sdk": "^0.115.0",
50
50
  "@google/genai": "^2.10.0",
51
51
  "@mistralai/mistralai": "^1.15.1",
52
52
  "js-tiktoken": "^1.0.20",