@flutchai/flutch-sdk 0.6.5 → 0.6.6
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/index.cjs +94 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -55
- package/dist/index.d.ts +78 -55
- package/dist/index.js +91 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1031,6 +1031,76 @@ declare function flutchHeaders(): Record<string, string>;
|
|
|
1031
1031
|
declare function flutchMistralHook(req: Request): Request;
|
|
1032
1032
|
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1033
1033
|
|
|
1034
|
+
interface IAgentToolConfig {
|
|
1035
|
+
toolName: string;
|
|
1036
|
+
enabled: boolean;
|
|
1037
|
+
config?: Record<string, any>;
|
|
1038
|
+
}
|
|
1039
|
+
interface IAgentToolConfiguration {
|
|
1040
|
+
toolName: string;
|
|
1041
|
+
enabled: boolean;
|
|
1042
|
+
config?: Record<string, any>;
|
|
1043
|
+
credentials?: Record<string, string>;
|
|
1044
|
+
useGlobalCredentials?: boolean;
|
|
1045
|
+
}
|
|
1046
|
+
interface ISystemToolCredentials {
|
|
1047
|
+
toolName: string;
|
|
1048
|
+
credentials: Record<string, string>;
|
|
1049
|
+
createdBy: string;
|
|
1050
|
+
createdAt: Date;
|
|
1051
|
+
updatedAt: Date;
|
|
1052
|
+
}
|
|
1053
|
+
interface IToolExecutionContext {
|
|
1054
|
+
toolName: string;
|
|
1055
|
+
config: Record<string, any>;
|
|
1056
|
+
credentials: Record<string, string>;
|
|
1057
|
+
agentId: string;
|
|
1058
|
+
userId: string;
|
|
1059
|
+
threadId?: string;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
declare function isReasoningModel(modelName: string): boolean;
|
|
1063
|
+
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1064
|
+
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1065
|
+
major: number;
|
|
1066
|
+
minor: number;
|
|
1067
|
+
}>;
|
|
1068
|
+
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1069
|
+
declare const PROMPT_CACHE_MIN_VERSIONS: Record<string, {
|
|
1070
|
+
major: number;
|
|
1071
|
+
minor: number;
|
|
1072
|
+
}>;
|
|
1073
|
+
type PromptCacheTtl = "5m" | "1h";
|
|
1074
|
+
interface PromptCacheControl {
|
|
1075
|
+
type: "ephemeral";
|
|
1076
|
+
ttl?: PromptCacheTtl;
|
|
1077
|
+
}
|
|
1078
|
+
declare function modelSupportsPromptCache(modelIdentifier?: string): boolean;
|
|
1079
|
+
declare function resolvePromptCacheControl(modelIdentifiers: (string | undefined)[], promptCache?: boolean, ttl?: PromptCacheTtl): PromptCacheControl | undefined;
|
|
1080
|
+
type ReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
1081
|
+
declare function buildEffortRequestFields(effort?: ReasoningEffort): {
|
|
1082
|
+
output_config: {
|
|
1083
|
+
effort: ReasoningEffort;
|
|
1084
|
+
};
|
|
1085
|
+
} | undefined;
|
|
1086
|
+
interface SamplingParams {
|
|
1087
|
+
temperature?: number;
|
|
1088
|
+
topP?: number;
|
|
1089
|
+
topK?: number;
|
|
1090
|
+
}
|
|
1091
|
+
interface ResolvedSamplingParams {
|
|
1092
|
+
params: SamplingParams;
|
|
1093
|
+
dropped: string[];
|
|
1094
|
+
accepted: boolean;
|
|
1095
|
+
}
|
|
1096
|
+
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1097
|
+
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1098
|
+
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1099
|
+
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1100
|
+
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1101
|
+
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1102
|
+
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1103
|
+
|
|
1034
1104
|
type ToolConfig = string | {
|
|
1035
1105
|
name: string;
|
|
1036
1106
|
enabled?: boolean;
|
|
@@ -1057,6 +1127,9 @@ interface ModelByIdConfig {
|
|
|
1057
1127
|
customTools?: DynamicStructuredTool[];
|
|
1058
1128
|
mcpServers?: Record<string, any>[];
|
|
1059
1129
|
mcpContext?: Record<string, any>;
|
|
1130
|
+
promptCache?: boolean;
|
|
1131
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1132
|
+
effort?: ReasoningEffort;
|
|
1060
1133
|
}
|
|
1061
1134
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1062
1135
|
interface ModelConfigWithToken {
|
|
@@ -1070,6 +1143,9 @@ interface ModelConfigWithToken {
|
|
|
1070
1143
|
supportsSamplingParams?: boolean;
|
|
1071
1144
|
useBedrock?: boolean;
|
|
1072
1145
|
bedrockModelId?: string;
|
|
1146
|
+
promptCache?: boolean;
|
|
1147
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1148
|
+
defaultEffort?: ReasoningEffort;
|
|
1073
1149
|
baseURL?: string;
|
|
1074
1150
|
}
|
|
1075
1151
|
type ApiKeyResolver = (provider: ModelProvider) => string | undefined;
|
|
@@ -1100,7 +1176,7 @@ interface IModelInitializer {
|
|
|
1100
1176
|
isModelTypeSupported(modelType: ModelType): boolean;
|
|
1101
1177
|
getSupportedModelTypes(): ModelType[];
|
|
1102
1178
|
}
|
|
1103
|
-
type ChatModelCreator = (config: ModelConfigWithTokenAndType) => BaseChatModel;
|
|
1179
|
+
type ChatModelCreator = (config: ModelConfigWithTokenAndType, promptCacheControl?: PromptCacheControl) => BaseChatModel;
|
|
1104
1180
|
type RerankModelCreator = (config: ModelConfigWithTokenAndType) => BaseDocumentCompressor;
|
|
1105
1181
|
type EmbeddingModelCreator = (config: ModelConfigWithTokenAndType) => Embeddings;
|
|
1106
1182
|
interface ModelCreators {
|
|
@@ -1152,59 +1228,6 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1152
1228
|
private fetchFromApi;
|
|
1153
1229
|
}
|
|
1154
1230
|
|
|
1155
|
-
interface IAgentToolConfig {
|
|
1156
|
-
toolName: string;
|
|
1157
|
-
enabled: boolean;
|
|
1158
|
-
config?: Record<string, any>;
|
|
1159
|
-
}
|
|
1160
|
-
interface IAgentToolConfiguration {
|
|
1161
|
-
toolName: string;
|
|
1162
|
-
enabled: boolean;
|
|
1163
|
-
config?: Record<string, any>;
|
|
1164
|
-
credentials?: Record<string, string>;
|
|
1165
|
-
useGlobalCredentials?: boolean;
|
|
1166
|
-
}
|
|
1167
|
-
interface ISystemToolCredentials {
|
|
1168
|
-
toolName: string;
|
|
1169
|
-
credentials: Record<string, string>;
|
|
1170
|
-
createdBy: string;
|
|
1171
|
-
createdAt: Date;
|
|
1172
|
-
updatedAt: Date;
|
|
1173
|
-
}
|
|
1174
|
-
interface IToolExecutionContext {
|
|
1175
|
-
toolName: string;
|
|
1176
|
-
config: Record<string, any>;
|
|
1177
|
-
credentials: Record<string, string>;
|
|
1178
|
-
agentId: string;
|
|
1179
|
-
userId: string;
|
|
1180
|
-
threadId?: string;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
declare function isReasoningModel(modelName: string): boolean;
|
|
1184
|
-
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1185
|
-
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1186
|
-
major: number;
|
|
1187
|
-
minor: number;
|
|
1188
|
-
}>;
|
|
1189
|
-
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1190
|
-
interface SamplingParams {
|
|
1191
|
-
temperature?: number;
|
|
1192
|
-
topP?: number;
|
|
1193
|
-
topK?: number;
|
|
1194
|
-
}
|
|
1195
|
-
interface ResolvedSamplingParams {
|
|
1196
|
-
params: SamplingParams;
|
|
1197
|
-
dropped: string[];
|
|
1198
|
-
accepted: boolean;
|
|
1199
|
-
}
|
|
1200
|
-
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1201
|
-
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1202
|
-
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1203
|
-
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1204
|
-
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1205
|
-
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1206
|
-
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1207
|
-
|
|
1208
1231
|
interface LangchainReasoningBlock {
|
|
1209
1232
|
type: "reasoning_content";
|
|
1210
1233
|
reasoningText?: {
|
|
@@ -1854,4 +1877,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1854
1877
|
private ensureIndex;
|
|
1855
1878
|
}
|
|
1856
1879
|
|
|
1857
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, type PostgresConfig, type RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
1880
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, PROMPT_CACHE_MIN_VERSIONS, type PostgresConfig, type PromptCacheControl, type PromptCacheTtl, type RateLimitConfig, type RateLimitResult, type ReasoningEffort, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildEffortRequestFields, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, modelSupportsPromptCache, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolvePromptCacheControl, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
package/dist/index.d.ts
CHANGED
|
@@ -1031,6 +1031,76 @@ declare function flutchHeaders(): Record<string, string>;
|
|
|
1031
1031
|
declare function flutchMistralHook(req: Request): Request;
|
|
1032
1032
|
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1033
1033
|
|
|
1034
|
+
interface IAgentToolConfig {
|
|
1035
|
+
toolName: string;
|
|
1036
|
+
enabled: boolean;
|
|
1037
|
+
config?: Record<string, any>;
|
|
1038
|
+
}
|
|
1039
|
+
interface IAgentToolConfiguration {
|
|
1040
|
+
toolName: string;
|
|
1041
|
+
enabled: boolean;
|
|
1042
|
+
config?: Record<string, any>;
|
|
1043
|
+
credentials?: Record<string, string>;
|
|
1044
|
+
useGlobalCredentials?: boolean;
|
|
1045
|
+
}
|
|
1046
|
+
interface ISystemToolCredentials {
|
|
1047
|
+
toolName: string;
|
|
1048
|
+
credentials: Record<string, string>;
|
|
1049
|
+
createdBy: string;
|
|
1050
|
+
createdAt: Date;
|
|
1051
|
+
updatedAt: Date;
|
|
1052
|
+
}
|
|
1053
|
+
interface IToolExecutionContext {
|
|
1054
|
+
toolName: string;
|
|
1055
|
+
config: Record<string, any>;
|
|
1056
|
+
credentials: Record<string, string>;
|
|
1057
|
+
agentId: string;
|
|
1058
|
+
userId: string;
|
|
1059
|
+
threadId?: string;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
declare function isReasoningModel(modelName: string): boolean;
|
|
1063
|
+
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1064
|
+
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1065
|
+
major: number;
|
|
1066
|
+
minor: number;
|
|
1067
|
+
}>;
|
|
1068
|
+
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1069
|
+
declare const PROMPT_CACHE_MIN_VERSIONS: Record<string, {
|
|
1070
|
+
major: number;
|
|
1071
|
+
minor: number;
|
|
1072
|
+
}>;
|
|
1073
|
+
type PromptCacheTtl = "5m" | "1h";
|
|
1074
|
+
interface PromptCacheControl {
|
|
1075
|
+
type: "ephemeral";
|
|
1076
|
+
ttl?: PromptCacheTtl;
|
|
1077
|
+
}
|
|
1078
|
+
declare function modelSupportsPromptCache(modelIdentifier?: string): boolean;
|
|
1079
|
+
declare function resolvePromptCacheControl(modelIdentifiers: (string | undefined)[], promptCache?: boolean, ttl?: PromptCacheTtl): PromptCacheControl | undefined;
|
|
1080
|
+
type ReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
1081
|
+
declare function buildEffortRequestFields(effort?: ReasoningEffort): {
|
|
1082
|
+
output_config: {
|
|
1083
|
+
effort: ReasoningEffort;
|
|
1084
|
+
};
|
|
1085
|
+
} | undefined;
|
|
1086
|
+
interface SamplingParams {
|
|
1087
|
+
temperature?: number;
|
|
1088
|
+
topP?: number;
|
|
1089
|
+
topK?: number;
|
|
1090
|
+
}
|
|
1091
|
+
interface ResolvedSamplingParams {
|
|
1092
|
+
params: SamplingParams;
|
|
1093
|
+
dropped: string[];
|
|
1094
|
+
accepted: boolean;
|
|
1095
|
+
}
|
|
1096
|
+
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1097
|
+
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1098
|
+
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1099
|
+
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1100
|
+
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1101
|
+
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1102
|
+
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1103
|
+
|
|
1034
1104
|
type ToolConfig = string | {
|
|
1035
1105
|
name: string;
|
|
1036
1106
|
enabled?: boolean;
|
|
@@ -1057,6 +1127,9 @@ interface ModelByIdConfig {
|
|
|
1057
1127
|
customTools?: DynamicStructuredTool[];
|
|
1058
1128
|
mcpServers?: Record<string, any>[];
|
|
1059
1129
|
mcpContext?: Record<string, any>;
|
|
1130
|
+
promptCache?: boolean;
|
|
1131
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1132
|
+
effort?: ReasoningEffort;
|
|
1060
1133
|
}
|
|
1061
1134
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1062
1135
|
interface ModelConfigWithToken {
|
|
@@ -1070,6 +1143,9 @@ interface ModelConfigWithToken {
|
|
|
1070
1143
|
supportsSamplingParams?: boolean;
|
|
1071
1144
|
useBedrock?: boolean;
|
|
1072
1145
|
bedrockModelId?: string;
|
|
1146
|
+
promptCache?: boolean;
|
|
1147
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1148
|
+
defaultEffort?: ReasoningEffort;
|
|
1073
1149
|
baseURL?: string;
|
|
1074
1150
|
}
|
|
1075
1151
|
type ApiKeyResolver = (provider: ModelProvider) => string | undefined;
|
|
@@ -1100,7 +1176,7 @@ interface IModelInitializer {
|
|
|
1100
1176
|
isModelTypeSupported(modelType: ModelType): boolean;
|
|
1101
1177
|
getSupportedModelTypes(): ModelType[];
|
|
1102
1178
|
}
|
|
1103
|
-
type ChatModelCreator = (config: ModelConfigWithTokenAndType) => BaseChatModel;
|
|
1179
|
+
type ChatModelCreator = (config: ModelConfigWithTokenAndType, promptCacheControl?: PromptCacheControl) => BaseChatModel;
|
|
1104
1180
|
type RerankModelCreator = (config: ModelConfigWithTokenAndType) => BaseDocumentCompressor;
|
|
1105
1181
|
type EmbeddingModelCreator = (config: ModelConfigWithTokenAndType) => Embeddings;
|
|
1106
1182
|
interface ModelCreators {
|
|
@@ -1152,59 +1228,6 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1152
1228
|
private fetchFromApi;
|
|
1153
1229
|
}
|
|
1154
1230
|
|
|
1155
|
-
interface IAgentToolConfig {
|
|
1156
|
-
toolName: string;
|
|
1157
|
-
enabled: boolean;
|
|
1158
|
-
config?: Record<string, any>;
|
|
1159
|
-
}
|
|
1160
|
-
interface IAgentToolConfiguration {
|
|
1161
|
-
toolName: string;
|
|
1162
|
-
enabled: boolean;
|
|
1163
|
-
config?: Record<string, any>;
|
|
1164
|
-
credentials?: Record<string, string>;
|
|
1165
|
-
useGlobalCredentials?: boolean;
|
|
1166
|
-
}
|
|
1167
|
-
interface ISystemToolCredentials {
|
|
1168
|
-
toolName: string;
|
|
1169
|
-
credentials: Record<string, string>;
|
|
1170
|
-
createdBy: string;
|
|
1171
|
-
createdAt: Date;
|
|
1172
|
-
updatedAt: Date;
|
|
1173
|
-
}
|
|
1174
|
-
interface IToolExecutionContext {
|
|
1175
|
-
toolName: string;
|
|
1176
|
-
config: Record<string, any>;
|
|
1177
|
-
credentials: Record<string, string>;
|
|
1178
|
-
agentId: string;
|
|
1179
|
-
userId: string;
|
|
1180
|
-
threadId?: string;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
declare function isReasoningModel(modelName: string): boolean;
|
|
1184
|
-
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1185
|
-
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1186
|
-
major: number;
|
|
1187
|
-
minor: number;
|
|
1188
|
-
}>;
|
|
1189
|
-
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1190
|
-
interface SamplingParams {
|
|
1191
|
-
temperature?: number;
|
|
1192
|
-
topP?: number;
|
|
1193
|
-
topK?: number;
|
|
1194
|
-
}
|
|
1195
|
-
interface ResolvedSamplingParams {
|
|
1196
|
-
params: SamplingParams;
|
|
1197
|
-
dropped: string[];
|
|
1198
|
-
accepted: boolean;
|
|
1199
|
-
}
|
|
1200
|
-
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1201
|
-
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1202
|
-
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1203
|
-
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1204
|
-
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1205
|
-
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1206
|
-
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1207
|
-
|
|
1208
1231
|
interface LangchainReasoningBlock {
|
|
1209
1232
|
type: "reasoning_content";
|
|
1210
1233
|
reasoningText?: {
|
|
@@ -1854,4 +1877,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1854
1877
|
private ensureIndex;
|
|
1855
1878
|
}
|
|
1856
1879
|
|
|
1857
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, type PostgresConfig, type RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
1880
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, PROMPT_CACHE_MIN_VERSIONS, type PostgresConfig, type PromptCacheControl, type PromptCacheTtl, type RateLimitConfig, type RateLimitResult, type ReasoningEffort, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildEffortRequestFields, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, modelSupportsPromptCache, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolvePromptCacheControl, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
package/dist/index.js
CHANGED
|
@@ -7083,6 +7083,48 @@ function modelAcceptsSamplingParams(modelIdentifier) {
|
|
|
7083
7083
|
return !atOrAboveThreshold;
|
|
7084
7084
|
}
|
|
7085
7085
|
__name(modelAcceptsSamplingParams, "modelAcceptsSamplingParams");
|
|
7086
|
+
var PROMPT_CACHE_MIN_VERSIONS = {
|
|
7087
|
+
opus: {
|
|
7088
|
+
major: 4,
|
|
7089
|
+
minor: 0
|
|
7090
|
+
},
|
|
7091
|
+
sonnet: {
|
|
7092
|
+
major: 4,
|
|
7093
|
+
minor: 0
|
|
7094
|
+
},
|
|
7095
|
+
haiku: {
|
|
7096
|
+
major: 4,
|
|
7097
|
+
minor: 5
|
|
7098
|
+
}
|
|
7099
|
+
};
|
|
7100
|
+
function modelSupportsPromptCache(modelIdentifier) {
|
|
7101
|
+
if (!modelIdentifier) return false;
|
|
7102
|
+
const match = CLAUDE_FAMILY_VERSION.exec(modelIdentifier.toLowerCase());
|
|
7103
|
+
if (!match) return false;
|
|
7104
|
+
const [, family, majorRaw, minorRaw] = match;
|
|
7105
|
+
const threshold = PROMPT_CACHE_MIN_VERSIONS[family];
|
|
7106
|
+
if (!threshold) return false;
|
|
7107
|
+
const major = Number(majorRaw);
|
|
7108
|
+
const minor = minorRaw === void 0 ? 0 : Number(minorRaw);
|
|
7109
|
+
return major > threshold.major || major === threshold.major && minor >= threshold.minor;
|
|
7110
|
+
}
|
|
7111
|
+
__name(modelSupportsPromptCache, "modelSupportsPromptCache");
|
|
7112
|
+
function resolvePromptCacheControl(modelIdentifiers, promptCache, ttl) {
|
|
7113
|
+
const enabled = promptCache ?? modelIdentifiers.some((id) => modelSupportsPromptCache(id));
|
|
7114
|
+
return enabled ? {
|
|
7115
|
+
type: "ephemeral",
|
|
7116
|
+
ttl: ttl ?? "5m"
|
|
7117
|
+
} : void 0;
|
|
7118
|
+
}
|
|
7119
|
+
__name(resolvePromptCacheControl, "resolvePromptCacheControl");
|
|
7120
|
+
function buildEffortRequestFields(effort) {
|
|
7121
|
+
return effort ? {
|
|
7122
|
+
output_config: {
|
|
7123
|
+
effort
|
|
7124
|
+
}
|
|
7125
|
+
} : void 0;
|
|
7126
|
+
}
|
|
7127
|
+
__name(buildEffortRequestFields, "buildEffortRequestFields");
|
|
7086
7128
|
function resolveSamplingParams(modelIdentifiers, requested, supportsSamplingParams) {
|
|
7087
7129
|
const accepted = supportsSamplingParams ?? modelIdentifiers.every((id) => modelAcceptsSamplingParams(id));
|
|
7088
7130
|
if (accepted) {
|
|
@@ -7413,7 +7455,9 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7413
7455
|
generateModelCacheKey(config) {
|
|
7414
7456
|
const base = generateModelCacheKey(config.modelId, config.temperature, config.maxTokens, config.toolsConfig, config.baseURL);
|
|
7415
7457
|
const withMcp = config.mcpServers && config.mcpServers.length > 0 ? `${base}:mcp:${JSON.stringify(config.mcpServers)}` : base;
|
|
7416
|
-
|
|
7458
|
+
const withSampling = config.supportsSamplingParams === void 0 ? withMcp : `${withMcp}:sp:${config.supportsSamplingParams}`;
|
|
7459
|
+
const withCache = config.promptCache === void 0 && config.promptCacheTtl === void 0 ? withSampling : `${withSampling}:pc:${config.promptCache ?? "auto"}:${config.promptCacheTtl ?? "default"}`;
|
|
7460
|
+
return config.effort === void 0 ? withCache : `${withCache}:eff:${config.effort}`;
|
|
7417
7461
|
}
|
|
7418
7462
|
// Chat model creators
|
|
7419
7463
|
chatModelCreators = {
|
|
@@ -7428,7 +7472,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7428
7472
|
}
|
|
7429
7473
|
return new ChatOpenAI(config);
|
|
7430
7474
|
},
|
|
7431
|
-
[ModelProvider.ANTHROPIC]: ({ modelName, defaultTemperature, defaultMaxTokens, apiToken, baseURL }) => {
|
|
7475
|
+
[ModelProvider.ANTHROPIC]: ({ modelName, defaultTemperature, defaultMaxTokens, apiToken, baseURL }, promptCacheControl) => {
|
|
7432
7476
|
const routerURL = resolveRouterURL(baseURL);
|
|
7433
7477
|
return new ChatAnthropic({
|
|
7434
7478
|
modelName,
|
|
@@ -7438,6 +7482,13 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7438
7482
|
temperature: defaultTemperature
|
|
7439
7483
|
},
|
|
7440
7484
|
maxTokens: defaultMaxTokens,
|
|
7485
|
+
// Top-level prompt caching: one breakpoint on the last cacheable block,
|
|
7486
|
+
// advanced automatically as the conversation grows. Survives the router
|
|
7487
|
+
// (which forwards the Anthropic body untouched) and is accepted by
|
|
7488
|
+
// Bedrock's InvokeModel schema behind it.
|
|
7489
|
+
...promptCacheControl && {
|
|
7490
|
+
cache_control: promptCacheControl
|
|
7491
|
+
},
|
|
7441
7492
|
anthropicApiKey: apiToken || this.resolveApiKey(ModelProvider.ANTHROPIC),
|
|
7442
7493
|
...routerURL && {
|
|
7443
7494
|
anthropicApiUrl: routerURL,
|
|
@@ -7642,9 +7693,17 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7642
7693
|
defaultMaxTokens: toOptionalNumber(config.maxTokens) ?? toOptionalNumber(modelConfig.defaultMaxTokens),
|
|
7643
7694
|
baseURL: config.baseURL ?? modelConfig.baseURL
|
|
7644
7695
|
};
|
|
7696
|
+
const promptCacheControl = resolvePromptCacheControl([
|
|
7697
|
+
finalConfig.bedrockModelId,
|
|
7698
|
+
finalConfig.modelName
|
|
7699
|
+
], config.promptCache ?? modelConfig.promptCache, config.promptCacheTtl ?? modelConfig.promptCacheTtl);
|
|
7700
|
+
if (promptCacheControl) {
|
|
7701
|
+
this.logger.debug(`Prompt caching enabled for ${finalConfig.bedrockModelId ?? finalConfig.modelName} (ttl=${promptCacheControl.ttl})`);
|
|
7702
|
+
}
|
|
7645
7703
|
this.logger.debug(`Creating new chat model instance: ${cacheKey}`);
|
|
7646
7704
|
let model;
|
|
7647
7705
|
if (finalConfig.useBedrock && finalConfig.bedrockModelId) {
|
|
7706
|
+
const effortFields = buildEffortRequestFields(config.effort ?? modelConfig.defaultEffort);
|
|
7648
7707
|
model = new FlutchChatBedrockConverse({
|
|
7649
7708
|
model: finalConfig.bedrockModelId,
|
|
7650
7709
|
region: this.resolveBedrockRegion(),
|
|
@@ -7652,6 +7711,9 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7652
7711
|
...finalConfig.defaultTemperature !== void 0 && {
|
|
7653
7712
|
temperature: finalConfig.defaultTemperature
|
|
7654
7713
|
},
|
|
7714
|
+
...effortFields && {
|
|
7715
|
+
additionalModelRequestFields: effortFields
|
|
7716
|
+
},
|
|
7655
7717
|
maxTokens: finalConfig.defaultMaxTokens,
|
|
7656
7718
|
streaming: true
|
|
7657
7719
|
});
|
|
@@ -7660,14 +7722,24 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7660
7722
|
if (!creator) {
|
|
7661
7723
|
throw new Error(`Chat models not supported for provider: ${modelConfig.provider}`);
|
|
7662
7724
|
}
|
|
7663
|
-
model = creator(finalConfig);
|
|
7725
|
+
model = creator(finalConfig, promptCacheControl);
|
|
7664
7726
|
}
|
|
7665
7727
|
model.metadata = {
|
|
7666
7728
|
...model.metadata,
|
|
7667
7729
|
modelId: config.modelId
|
|
7668
7730
|
};
|
|
7669
7731
|
if (config.toolsConfig || config.customTools || config.mcpServers && config.mcpServers.length > 0) {
|
|
7670
|
-
const boundModel = await this.bindToolsToModel(
|
|
7732
|
+
const boundModel = await this.bindToolsToModel(
|
|
7733
|
+
model,
|
|
7734
|
+
config.toolsConfig,
|
|
7735
|
+
config.customTools,
|
|
7736
|
+
config.mcpServers,
|
|
7737
|
+
config.mcpContext,
|
|
7738
|
+
// Converse takes cache control as a per-call option; the Anthropic
|
|
7739
|
+
// client already got it as a constructor field, and handing it the
|
|
7740
|
+
// same value twice would put an unknown key in its call options.
|
|
7741
|
+
finalConfig.useBedrock ? promptCacheControl : void 0
|
|
7742
|
+
);
|
|
7671
7743
|
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
7672
7744
|
return boundModel;
|
|
7673
7745
|
}
|
|
@@ -7679,11 +7751,20 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7679
7751
|
* For toolsConfig: fetch tool executors from MCP Runtime
|
|
7680
7752
|
* For customTools: use as-is (already prepared DynamicStructuredTool)
|
|
7681
7753
|
*
|
|
7754
|
+
* `promptCacheControl` is the **Bedrock-only** half of prompt caching: it is
|
|
7755
|
+
* bound alongside the tools as a default call option, and `ChatBedrockConverse`
|
|
7756
|
+
* turns it into `cachePoint` blocks after the tool schemas, the system prompt
|
|
7757
|
+
* and the last message. Tool schemas dominate the request, so this is the one
|
|
7758
|
+
* place worth caching — a model with no tools keeps its plain `BaseChatModel`
|
|
7759
|
+
* type and no cache points (callers there rely on `withStructuredOutput` and
|
|
7760
|
+
* friends). The Anthropic client takes its cache settings in the constructor
|
|
7761
|
+
* instead and must not be handed them again here.
|
|
7762
|
+
*
|
|
7682
7763
|
* Returns:
|
|
7683
7764
|
* - Runnable when tools are bound (model.bindTools returns Runnable)
|
|
7684
7765
|
* - BaseChatModel when no tools
|
|
7685
7766
|
*/
|
|
7686
|
-
async bindToolsToModel(model, toolsConfig, customTools, mcpServers, mcpContext) {
|
|
7767
|
+
async bindToolsToModel(model, toolsConfig, customTools, mcpServers, mcpContext, promptCacheControl) {
|
|
7687
7768
|
const allTools = [];
|
|
7688
7769
|
const enabledToolsConfig = (toolsConfig || []).filter((tc) => tc.enabled !== false);
|
|
7689
7770
|
const hasInlineServers = !!(mcpServers && mcpServers.length > 0);
|
|
@@ -7704,7 +7785,10 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7704
7785
|
}
|
|
7705
7786
|
if (allTools.length > 0) {
|
|
7706
7787
|
this.logger.debug(`Binding ${allTools.length} tools to model`);
|
|
7707
|
-
const
|
|
7788
|
+
const boundOptions = {
|
|
7789
|
+
cache_control: promptCacheControl
|
|
7790
|
+
};
|
|
7791
|
+
const modelWithTools = promptCacheControl ? model.bindTools(allTools, boundOptions) : model.bindTools(allTools);
|
|
7708
7792
|
return modelWithTools;
|
|
7709
7793
|
}
|
|
7710
7794
|
return model;
|
|
@@ -8497,6 +8581,6 @@ var MongoTokenStore = class {
|
|
|
8497
8581
|
}
|
|
8498
8582
|
};
|
|
8499
8583
|
|
|
8500
|
-
export { AbstractGraphBuilder, AttachmentType, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, CallbackController, CallbackMetrics, CallbackPatchService, CallbackRateLimiter, CallbackRegistry, CallbackStore, CallbackTokenGuard, ChatFeature, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, ENDPOINT_METADATA_KEY, Endpoint, EndpointRegistry, EventProcessor, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, RetrieverSearchType, RetrieverService, SAMPLING_PARAM_FREE_THRESHOLDS, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
8584
|
+
export { AbstractGraphBuilder, AttachmentType, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, CallbackController, CallbackMetrics, CallbackPatchService, CallbackRateLimiter, CallbackRegistry, CallbackStore, CallbackTokenGuard, ChatFeature, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, ENDPOINT_METADATA_KEY, Endpoint, EndpointRegistry, EventProcessor, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, PROMPT_CACHE_MIN_VERSIONS, RetrieverSearchType, RetrieverService, SAMPLING_PARAM_FREE_THRESHOLDS, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildEffortRequestFields, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, modelSupportsPromptCache, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolvePromptCacheControl, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
8501
8585
|
//# sourceMappingURL=index.js.map
|
|
8502
8586
|
//# sourceMappingURL=index.js.map
|