graphlit-client 1.0.20260601001 → 1.0.20260602001
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/client.js
CHANGED
|
@@ -7,7 +7,7 @@ import gql from "graphql-tag";
|
|
|
7
7
|
import { attachPartialErrors } from "./partial-errors.js";
|
|
8
8
|
import * as Types from "./generated/graphql-types.js";
|
|
9
9
|
import * as Documents from "./generated/graphql-documents.js";
|
|
10
|
-
import { getServiceType, getModelName, getModelEnum, isOpenAIResponsesEligibleModel, } from "./model-mapping.js";
|
|
10
|
+
import { getServiceType, getModelName, getModelEnum, isAnthropicAdaptiveThinkingOnlyModel, isOpenAIResponsesEligibleModel, } from "./model-mapping.js";
|
|
11
11
|
import { StuckDetector } from "./helpers/stuck-detector.js";
|
|
12
12
|
import { TurnEvaluator } from "./helpers/turn-evaluator.js";
|
|
13
13
|
import { TokenBudgetTracker, truncateToolResult, windowToolRounds, estimateTokens, DEFAULT_CONTEXT_STRATEGY, } from "./helpers/context-management.js";
|
|
@@ -362,7 +362,7 @@ function isValidGuid(guid) {
|
|
|
362
362
|
/**
|
|
363
363
|
* Map Graphlit AnthropicEffortLevels to the string values accepted by the
|
|
364
364
|
* Anthropic Messages API `output_config.effort` parameter (adaptive thinking).
|
|
365
|
-
* Used for Claude 4.7
|
|
365
|
+
* Used for Claude Opus 4.7/4.8, which replace `thinking.budget_tokens` with
|
|
366
366
|
* `thinking.type = "adaptive"` + `output_config.effort`.
|
|
367
367
|
*/
|
|
368
368
|
function mapAnthropicEffort(effort) {
|
|
@@ -382,6 +382,19 @@ function mapAnthropicEffort(effort) {
|
|
|
382
382
|
return undefined;
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
+
function supportsAnthropicThinkingDisplay(specification) {
|
|
386
|
+
if (specification.serviceType !== Types.ModelServiceTypes.Anthropic) {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
const modelName = getModelName(specification);
|
|
390
|
+
if (!modelName) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
return (modelName.startsWith("claude-opus-4") ||
|
|
394
|
+
modelName.startsWith("claude-sonnet-4") ||
|
|
395
|
+
modelName.startsWith("claude-haiku-4") ||
|
|
396
|
+
modelName === "claude-mythos-preview");
|
|
397
|
+
}
|
|
385
398
|
// Define the Graphlit class
|
|
386
399
|
class Graphlit {
|
|
387
400
|
client;
|
|
@@ -8335,16 +8348,21 @@ class Graphlit {
|
|
|
8335
8348
|
if (specification.serviceType === Types.ModelServiceTypes.Anthropic) {
|
|
8336
8349
|
const anthropic = specification.anthropic;
|
|
8337
8350
|
if (anthropic?.enableThinking) {
|
|
8338
|
-
|
|
8339
|
-
|
|
8351
|
+
const display = supportsAnthropicThinkingDisplay(specification)
|
|
8352
|
+
? "summarized"
|
|
8353
|
+
: undefined;
|
|
8354
|
+
// Claude Opus 4.7/4.8 only support adaptive thinking with output_config.effort
|
|
8355
|
+
if (isAnthropicAdaptiveThinkingOnlyModel(specification)) {
|
|
8340
8356
|
return {
|
|
8341
8357
|
type: "adaptive",
|
|
8342
8358
|
effort: mapAnthropicEffort(anthropic.effort),
|
|
8359
|
+
display,
|
|
8343
8360
|
};
|
|
8344
8361
|
}
|
|
8345
8362
|
return {
|
|
8346
8363
|
type: "enabled",
|
|
8347
8364
|
budget_tokens: anthropic.thinkingTokenLimit || 10000,
|
|
8365
|
+
display,
|
|
8348
8366
|
};
|
|
8349
8367
|
}
|
|
8350
8368
|
}
|
package/dist/model-mapping.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export declare function getServiceType(specification: any): string | undefined;
|
|
|
22
22
|
* @returns The model enum value
|
|
23
23
|
*/
|
|
24
24
|
export declare function getModelEnum(specification: any): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Check whether an Anthropic specification targets an Opus model that only
|
|
27
|
+
* supports adaptive thinking and rejects non-default sampling parameters.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isAnthropicAdaptiveThinkingOnlyModel(specification: any): boolean;
|
|
25
30
|
/**
|
|
26
31
|
* Check whether an OpenAI specification should use the Responses API path.
|
|
27
32
|
* Eligible models are GPT-5.4 and newer.
|
package/dist/model-mapping.js
CHANGED
|
@@ -120,8 +120,9 @@ const ANTHROPIC_MODEL_MAP = {
|
|
|
120
120
|
[Types.AnthropicModels.Claude_4_6Sonnet_20260217]: "claude-sonnet-4-6-20260217",
|
|
121
121
|
[Types.AnthropicModels.Claude_4_6Sonnet_1M]: "claude-sonnet-4-6",
|
|
122
122
|
[Types.AnthropicModels.Claude_4_6Sonnet_1M_20260217]: "claude-sonnet-4-6-20260217",
|
|
123
|
-
// Claude 4.7 models (1M context is native to the model, no beta header required)
|
|
123
|
+
// Claude 4.7+ models (1M context is native to the model, no beta header required)
|
|
124
124
|
[Types.AnthropicModels.Claude_4_7Opus]: "claude-opus-4-7",
|
|
125
|
+
[Types.AnthropicModels.Claude_4_8Opus]: "claude-opus-4-8",
|
|
125
126
|
};
|
|
126
127
|
// Google model mappings
|
|
127
128
|
const GOOGLE_MODEL_MAP = {
|
|
@@ -357,6 +358,22 @@ export function getModelEnum(specification) {
|
|
|
357
358
|
return undefined;
|
|
358
359
|
}
|
|
359
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Check whether an Anthropic specification targets an Opus model that only
|
|
363
|
+
* supports adaptive thinking and rejects non-default sampling parameters.
|
|
364
|
+
*/
|
|
365
|
+
export function isAnthropicAdaptiveThinkingOnlyModel(specification) {
|
|
366
|
+
if (specification?.serviceType !== Types.ModelServiceTypes.Anthropic) {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
const modelEnum = getModelEnum(specification);
|
|
370
|
+
if (modelEnum === Types.AnthropicModels.Claude_4_7Opus ||
|
|
371
|
+
modelEnum === Types.AnthropicModels.Claude_4_8Opus) {
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
const modelName = getModelName(specification);
|
|
375
|
+
return modelName === "claude-opus-4-7" || modelName === "claude-opus-4-8";
|
|
376
|
+
}
|
|
360
377
|
/**
|
|
361
378
|
* Check whether an OpenAI specification should use the Responses API path.
|
|
362
379
|
* Eligible models are GPT-5.4 and newer.
|
|
@@ -19,9 +19,11 @@ export declare function streamWithAnthropic(specification: Specification, messag
|
|
|
19
19
|
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[], usage?: any, reasoning?: ReasoningMetadata) => void, abortSignal?: AbortSignal, thinkingConfig?: {
|
|
20
20
|
type: "enabled";
|
|
21
21
|
budget_tokens: number;
|
|
22
|
+
display?: "summarized";
|
|
22
23
|
} | {
|
|
23
24
|
type: "adaptive";
|
|
24
25
|
effort?: "low" | "medium" | "high" | "xhigh";
|
|
26
|
+
display?: "summarized";
|
|
25
27
|
}): Promise<void>;
|
|
26
28
|
/**
|
|
27
29
|
* Stream with Google SDK
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Types from "../generated/graphql-types.js";
|
|
2
|
-
import { getModelName } from "../model-mapping.js";
|
|
2
|
+
import { getModelName, isAnthropicAdaptiveThinkingOnlyModel, } from "../model-mapping.js";
|
|
3
3
|
import { ProviderError, isRetryableServerError, isRateLimitError, isNetworkError, extractRequestId, } from "../types/internal.js";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
/**
|
|
@@ -509,17 +509,17 @@ onEvent, onComplete, abortSignal, thinkingConfig) {
|
|
|
509
509
|
stream: true,
|
|
510
510
|
max_tokens: specification.anthropic?.completionTokenLimit || defaultMaxTokens,
|
|
511
511
|
};
|
|
512
|
-
//
|
|
513
|
-
// Claude 4.7 Opus (adaptive thinking) does not accept sampling parameters at all.
|
|
512
|
+
// Claude Opus 4.7/4.8 do not accept non-default sampling parameters at all.
|
|
514
513
|
const isAdaptiveThinking = thinkingConfig?.type === "adaptive";
|
|
515
|
-
|
|
514
|
+
const isAdaptiveThinkingOnlyModel = isAnthropicAdaptiveThinkingOnlyModel(specification);
|
|
515
|
+
if (thinkingConfig && !isAdaptiveThinking && !isAdaptiveThinkingOnlyModel) {
|
|
516
516
|
// When legacy thinking budget is enabled, temperature must be 1
|
|
517
517
|
streamConfig.temperature = 1;
|
|
518
518
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
519
519
|
console.log(`🧠 [Anthropic] Setting temperature to 1 (required for extended thinking)`);
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
else if (!isAdaptiveThinking) {
|
|
522
|
+
else if (!isAdaptiveThinkingOnlyModel && !isAdaptiveThinking) {
|
|
523
523
|
// Only add temperature if it's defined and valid for non-thinking requests
|
|
524
524
|
if (specification.anthropic?.temperature !== undefined &&
|
|
525
525
|
specification.anthropic?.temperature !== null &&
|
|
@@ -550,8 +550,10 @@ onEvent, onComplete, abortSignal, thinkingConfig) {
|
|
|
550
550
|
// Add thinking config if provided
|
|
551
551
|
if (thinkingConfig) {
|
|
552
552
|
if (thinkingConfig.type === "adaptive") {
|
|
553
|
-
// Claude 4.7
|
|
554
|
-
streamConfig.thinking =
|
|
553
|
+
// Claude Opus 4.7/4.8: adaptive thinking, effort controls depth via output_config
|
|
554
|
+
streamConfig.thinking = thinkingConfig.display
|
|
555
|
+
? { type: "adaptive", display: thinkingConfig.display }
|
|
556
|
+
: { type: "adaptive" };
|
|
555
557
|
if (thinkingConfig.effort) {
|
|
556
558
|
streamConfig.output_config = { effort: thinkingConfig.effort };
|
|
557
559
|
}
|