@flutchai/flutch-sdk 0.2.15 → 0.2.16
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 +120 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -31
- package/dist/index.d.ts +57 -31
- package/dist/index.js +114 -32
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1011,6 +1011,21 @@ declare enum ChatFeature {
|
|
|
1011
1011
|
JSON_MODE = "json_mode"
|
|
1012
1012
|
}
|
|
1013
1013
|
|
|
1014
|
+
type ToolConfig = string | {
|
|
1015
|
+
name: string;
|
|
1016
|
+
enabled?: boolean;
|
|
1017
|
+
config?: Record<string, any>;
|
|
1018
|
+
};
|
|
1019
|
+
interface ModelConfig {
|
|
1020
|
+
provider: ModelProvider;
|
|
1021
|
+
modelName: string;
|
|
1022
|
+
temperature?: number;
|
|
1023
|
+
maxTokens?: number;
|
|
1024
|
+
topP?: number;
|
|
1025
|
+
tools?: ToolConfig[];
|
|
1026
|
+
baseURL?: string;
|
|
1027
|
+
providerConfig?: Record<string, any>;
|
|
1028
|
+
}
|
|
1014
1029
|
interface ModelByIdConfig {
|
|
1015
1030
|
modelId: string;
|
|
1016
1031
|
temperature?: number;
|
|
@@ -1048,11 +1063,11 @@ interface ModelConfigWithTokenAndType extends ModelConfigWithToken {
|
|
|
1048
1063
|
supportedFormats?: string[];
|
|
1049
1064
|
}
|
|
1050
1065
|
interface IModelInitializer {
|
|
1066
|
+
initializeChatModel(config: ModelConfig | ModelByIdConfig, customTools?: DynamicStructuredTool[]): Promise<ChatModelOrRunnable>;
|
|
1051
1067
|
createChatModelById(modelId: string): Promise<ChatModelOrRunnable>;
|
|
1052
1068
|
createRerankModelById(modelId: string): Promise<BaseDocumentCompressor>;
|
|
1053
1069
|
createEmbeddingModelById(modelId: string): Promise<Embeddings>;
|
|
1054
1070
|
createModelById(modelId: string, expectedType?: ModelType): Promise<Model>;
|
|
1055
|
-
initializeChatModel(config: ModelByIdConfig): Promise<ChatModelOrRunnable>;
|
|
1056
1071
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1057
1072
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
1058
1073
|
initializeModelByType(config: ModelByIdWithTypeConfig): Promise<Model>;
|
|
@@ -1086,7 +1101,9 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1086
1101
|
private readonly chatModelCreators;
|
|
1087
1102
|
private readonly rerankModelCreators;
|
|
1088
1103
|
private readonly embeddingModelCreators;
|
|
1089
|
-
initializeChatModel(config: ModelByIdConfig): Promise<
|
|
1104
|
+
initializeChatModel(config: ModelConfig | ModelByIdConfig, customTools?: DynamicStructuredTool[]): Promise<ChatModelOrRunnable>;
|
|
1105
|
+
private initializeChatModelDirect;
|
|
1106
|
+
private initializeChatModelByIdInternal;
|
|
1090
1107
|
private bindToolsToModel;
|
|
1091
1108
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1092
1109
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
@@ -1109,11 +1126,48 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1109
1126
|
private fetchFromApi;
|
|
1110
1127
|
}
|
|
1111
1128
|
|
|
1129
|
+
interface IAgentToolConfig {
|
|
1130
|
+
toolName: string;
|
|
1131
|
+
enabled: boolean;
|
|
1132
|
+
config?: Record<string, any>;
|
|
1133
|
+
}
|
|
1134
|
+
interface IAgentToolConfiguration {
|
|
1135
|
+
toolName: string;
|
|
1136
|
+
enabled: boolean;
|
|
1137
|
+
config?: Record<string, any>;
|
|
1138
|
+
credentials?: Record<string, string>;
|
|
1139
|
+
useGlobalCredentials?: boolean;
|
|
1140
|
+
}
|
|
1141
|
+
interface ISystemToolCredentials {
|
|
1142
|
+
toolName: string;
|
|
1143
|
+
credentials: Record<string, string>;
|
|
1144
|
+
createdBy: string;
|
|
1145
|
+
createdAt: Date;
|
|
1146
|
+
updatedAt: Date;
|
|
1147
|
+
}
|
|
1148
|
+
interface IToolExecutionContext {
|
|
1149
|
+
toolName: string;
|
|
1150
|
+
config: Record<string, any>;
|
|
1151
|
+
credentials: Record<string, string>;
|
|
1152
|
+
agentId: string;
|
|
1153
|
+
userId: string;
|
|
1154
|
+
threadId?: string;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
declare function isReasoningModel(modelName: string): boolean;
|
|
1158
|
+
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1159
|
+
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1160
|
+
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1161
|
+
declare function resolveRouterURL(baseURL?: string): string;
|
|
1162
|
+
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1163
|
+
declare function buildOpenAIModelConfig(modelName: string, temperature: number, maxTokens: number, apiToken: string): Record<string, any>;
|
|
1164
|
+
|
|
1112
1165
|
interface VoyageAIRerankConfig {
|
|
1113
1166
|
apiKey?: string;
|
|
1114
1167
|
model?: string;
|
|
1115
1168
|
topN?: number;
|
|
1116
1169
|
truncation?: boolean;
|
|
1170
|
+
baseUrl?: string;
|
|
1117
1171
|
}
|
|
1118
1172
|
declare class VoyageAIRerank extends BaseDocumentCompressor {
|
|
1119
1173
|
private apiKey;
|
|
@@ -1159,34 +1213,6 @@ interface IToolConfigOption {
|
|
|
1159
1213
|
includeInSchema?: boolean;
|
|
1160
1214
|
}
|
|
1161
1215
|
|
|
1162
|
-
interface IAgentToolConfig {
|
|
1163
|
-
toolName: string;
|
|
1164
|
-
enabled: boolean;
|
|
1165
|
-
config?: Record<string, any>;
|
|
1166
|
-
}
|
|
1167
|
-
interface IAgentToolConfiguration {
|
|
1168
|
-
toolName: string;
|
|
1169
|
-
enabled: boolean;
|
|
1170
|
-
config?: Record<string, any>;
|
|
1171
|
-
credentials?: Record<string, string>;
|
|
1172
|
-
useGlobalCredentials?: boolean;
|
|
1173
|
-
}
|
|
1174
|
-
interface ISystemToolCredentials {
|
|
1175
|
-
toolName: string;
|
|
1176
|
-
credentials: Record<string, string>;
|
|
1177
|
-
createdBy: string;
|
|
1178
|
-
createdAt: Date;
|
|
1179
|
-
updatedAt: Date;
|
|
1180
|
-
}
|
|
1181
|
-
interface IToolExecutionContext {
|
|
1182
|
-
toolName: string;
|
|
1183
|
-
config: Record<string, any>;
|
|
1184
|
-
credentials: Record<string, string>;
|
|
1185
|
-
agentId: string;
|
|
1186
|
-
userId: string;
|
|
1187
|
-
threadId?: string;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
1216
|
interface McpTool {
|
|
1191
1217
|
name: string;
|
|
1192
1218
|
description: string;
|
|
@@ -1749,4 +1775,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1749
1775
|
private ensureIndex;
|
|
1750
1776
|
}
|
|
1751
1777
|
|
|
1752
|
-
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_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, 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 MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, type RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, 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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, loadOAuthProviders, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
1778
|
+
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, 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 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 RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, 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, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
package/dist/index.d.ts
CHANGED
|
@@ -1011,6 +1011,21 @@ declare enum ChatFeature {
|
|
|
1011
1011
|
JSON_MODE = "json_mode"
|
|
1012
1012
|
}
|
|
1013
1013
|
|
|
1014
|
+
type ToolConfig = string | {
|
|
1015
|
+
name: string;
|
|
1016
|
+
enabled?: boolean;
|
|
1017
|
+
config?: Record<string, any>;
|
|
1018
|
+
};
|
|
1019
|
+
interface ModelConfig {
|
|
1020
|
+
provider: ModelProvider;
|
|
1021
|
+
modelName: string;
|
|
1022
|
+
temperature?: number;
|
|
1023
|
+
maxTokens?: number;
|
|
1024
|
+
topP?: number;
|
|
1025
|
+
tools?: ToolConfig[];
|
|
1026
|
+
baseURL?: string;
|
|
1027
|
+
providerConfig?: Record<string, any>;
|
|
1028
|
+
}
|
|
1014
1029
|
interface ModelByIdConfig {
|
|
1015
1030
|
modelId: string;
|
|
1016
1031
|
temperature?: number;
|
|
@@ -1048,11 +1063,11 @@ interface ModelConfigWithTokenAndType extends ModelConfigWithToken {
|
|
|
1048
1063
|
supportedFormats?: string[];
|
|
1049
1064
|
}
|
|
1050
1065
|
interface IModelInitializer {
|
|
1066
|
+
initializeChatModel(config: ModelConfig | ModelByIdConfig, customTools?: DynamicStructuredTool[]): Promise<ChatModelOrRunnable>;
|
|
1051
1067
|
createChatModelById(modelId: string): Promise<ChatModelOrRunnable>;
|
|
1052
1068
|
createRerankModelById(modelId: string): Promise<BaseDocumentCompressor>;
|
|
1053
1069
|
createEmbeddingModelById(modelId: string): Promise<Embeddings>;
|
|
1054
1070
|
createModelById(modelId: string, expectedType?: ModelType): Promise<Model>;
|
|
1055
|
-
initializeChatModel(config: ModelByIdConfig): Promise<ChatModelOrRunnable>;
|
|
1056
1071
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1057
1072
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
1058
1073
|
initializeModelByType(config: ModelByIdWithTypeConfig): Promise<Model>;
|
|
@@ -1086,7 +1101,9 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1086
1101
|
private readonly chatModelCreators;
|
|
1087
1102
|
private readonly rerankModelCreators;
|
|
1088
1103
|
private readonly embeddingModelCreators;
|
|
1089
|
-
initializeChatModel(config: ModelByIdConfig): Promise<
|
|
1104
|
+
initializeChatModel(config: ModelConfig | ModelByIdConfig, customTools?: DynamicStructuredTool[]): Promise<ChatModelOrRunnable>;
|
|
1105
|
+
private initializeChatModelDirect;
|
|
1106
|
+
private initializeChatModelByIdInternal;
|
|
1090
1107
|
private bindToolsToModel;
|
|
1091
1108
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1092
1109
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
@@ -1109,11 +1126,48 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1109
1126
|
private fetchFromApi;
|
|
1110
1127
|
}
|
|
1111
1128
|
|
|
1129
|
+
interface IAgentToolConfig {
|
|
1130
|
+
toolName: string;
|
|
1131
|
+
enabled: boolean;
|
|
1132
|
+
config?: Record<string, any>;
|
|
1133
|
+
}
|
|
1134
|
+
interface IAgentToolConfiguration {
|
|
1135
|
+
toolName: string;
|
|
1136
|
+
enabled: boolean;
|
|
1137
|
+
config?: Record<string, any>;
|
|
1138
|
+
credentials?: Record<string, string>;
|
|
1139
|
+
useGlobalCredentials?: boolean;
|
|
1140
|
+
}
|
|
1141
|
+
interface ISystemToolCredentials {
|
|
1142
|
+
toolName: string;
|
|
1143
|
+
credentials: Record<string, string>;
|
|
1144
|
+
createdBy: string;
|
|
1145
|
+
createdAt: Date;
|
|
1146
|
+
updatedAt: Date;
|
|
1147
|
+
}
|
|
1148
|
+
interface IToolExecutionContext {
|
|
1149
|
+
toolName: string;
|
|
1150
|
+
config: Record<string, any>;
|
|
1151
|
+
credentials: Record<string, string>;
|
|
1152
|
+
agentId: string;
|
|
1153
|
+
userId: string;
|
|
1154
|
+
threadId?: string;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
declare function isReasoningModel(modelName: string): boolean;
|
|
1158
|
+
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1159
|
+
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1160
|
+
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1161
|
+
declare function resolveRouterURL(baseURL?: string): string;
|
|
1162
|
+
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1163
|
+
declare function buildOpenAIModelConfig(modelName: string, temperature: number, maxTokens: number, apiToken: string): Record<string, any>;
|
|
1164
|
+
|
|
1112
1165
|
interface VoyageAIRerankConfig {
|
|
1113
1166
|
apiKey?: string;
|
|
1114
1167
|
model?: string;
|
|
1115
1168
|
topN?: number;
|
|
1116
1169
|
truncation?: boolean;
|
|
1170
|
+
baseUrl?: string;
|
|
1117
1171
|
}
|
|
1118
1172
|
declare class VoyageAIRerank extends BaseDocumentCompressor {
|
|
1119
1173
|
private apiKey;
|
|
@@ -1159,34 +1213,6 @@ interface IToolConfigOption {
|
|
|
1159
1213
|
includeInSchema?: boolean;
|
|
1160
1214
|
}
|
|
1161
1215
|
|
|
1162
|
-
interface IAgentToolConfig {
|
|
1163
|
-
toolName: string;
|
|
1164
|
-
enabled: boolean;
|
|
1165
|
-
config?: Record<string, any>;
|
|
1166
|
-
}
|
|
1167
|
-
interface IAgentToolConfiguration {
|
|
1168
|
-
toolName: string;
|
|
1169
|
-
enabled: boolean;
|
|
1170
|
-
config?: Record<string, any>;
|
|
1171
|
-
credentials?: Record<string, string>;
|
|
1172
|
-
useGlobalCredentials?: boolean;
|
|
1173
|
-
}
|
|
1174
|
-
interface ISystemToolCredentials {
|
|
1175
|
-
toolName: string;
|
|
1176
|
-
credentials: Record<string, string>;
|
|
1177
|
-
createdBy: string;
|
|
1178
|
-
createdAt: Date;
|
|
1179
|
-
updatedAt: Date;
|
|
1180
|
-
}
|
|
1181
|
-
interface IToolExecutionContext {
|
|
1182
|
-
toolName: string;
|
|
1183
|
-
config: Record<string, any>;
|
|
1184
|
-
credentials: Record<string, string>;
|
|
1185
|
-
agentId: string;
|
|
1186
|
-
userId: string;
|
|
1187
|
-
threadId?: string;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
1216
|
interface McpTool {
|
|
1191
1217
|
name: string;
|
|
1192
1218
|
description: string;
|
|
@@ -1749,4 +1775,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1749
1775
|
private ensureIndex;
|
|
1750
1776
|
}
|
|
1751
1777
|
|
|
1752
|
-
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_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, 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 MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, type RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, 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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, loadOAuthProviders, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
1778
|
+
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, 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 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 RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, 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, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai';
|
|
|
24
24
|
import { ChatBedrockConverse } from '@langchain/aws';
|
|
25
25
|
import { ChatAnthropic } from '@langchain/anthropic';
|
|
26
26
|
import { ChatCohere, CohereRerank } from '@langchain/cohere';
|
|
27
|
+
import { CohereClient } from 'cohere-ai';
|
|
27
28
|
import { BaseDocumentCompressor } from '@langchain/core/retrievers/document_compressors';
|
|
28
29
|
import { ChatMistralAI } from '@langchain/mistralai';
|
|
29
30
|
|
|
@@ -6436,6 +6437,12 @@ function hashToolsConfig(toolsConfig) {
|
|
|
6436
6437
|
const sorted = toolsConfig.map((t) => `${t.toolName}:${t.enabled}:${JSON.stringify(t.config || {})}`).sort().join("|");
|
|
6437
6438
|
return createHash("md5").update(sorted).digest("hex").slice(0, 16);
|
|
6438
6439
|
}
|
|
6440
|
+
function normalizeToolConfigs(tools) {
|
|
6441
|
+
if (!tools || tools.length === 0) return void 0;
|
|
6442
|
+
return tools.map(
|
|
6443
|
+
(t) => typeof t === "string" ? { toolName: t, enabled: true } : { toolName: t.name, enabled: t.enabled !== false, config: t.config }
|
|
6444
|
+
);
|
|
6445
|
+
}
|
|
6439
6446
|
var DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
6440
6447
|
function resolveRouterURL(baseURL) {
|
|
6441
6448
|
return baseURL ?? process.env.FLUTCH_ROUTER_URL ?? DEFAULT_ROUTER_URL;
|
|
@@ -6478,13 +6485,14 @@ var VoyageAIRerank = class extends BaseDocumentCompressor {
|
|
|
6478
6485
|
model;
|
|
6479
6486
|
topN;
|
|
6480
6487
|
truncation;
|
|
6481
|
-
baseUrl
|
|
6488
|
+
baseUrl;
|
|
6482
6489
|
constructor(config) {
|
|
6483
6490
|
super();
|
|
6484
6491
|
this.apiKey = config.apiKey || process.env.VOYAGEAI_API_KEY || "";
|
|
6485
6492
|
this.model = config.model || "rerank-2";
|
|
6486
6493
|
this.topN = config.topN || 20;
|
|
6487
6494
|
this.truncation = config.truncation ?? true;
|
|
6495
|
+
this.baseUrl = config.baseUrl ? `${config.baseUrl}/v1/rerank` : "https://api.voyageai.com/v1/rerank";
|
|
6488
6496
|
if (!this.apiKey) {
|
|
6489
6497
|
throw new Error(
|
|
6490
6498
|
"VoyageAI API key is required. Set VOYAGEAI_API_KEY environment variable or pass apiKey in config."
|
|
@@ -6615,11 +6623,15 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6615
6623
|
modelName,
|
|
6616
6624
|
defaultTemperature,
|
|
6617
6625
|
defaultMaxTokens,
|
|
6618
|
-
apiToken
|
|
6626
|
+
apiToken,
|
|
6627
|
+
baseURL
|
|
6619
6628
|
}) => new ChatCohere({
|
|
6620
6629
|
model: modelName,
|
|
6621
6630
|
temperature: defaultTemperature,
|
|
6622
|
-
|
|
6631
|
+
client: new CohereClient({
|
|
6632
|
+
token: apiToken || this.resolveApiKey("cohere" /* COHERE */),
|
|
6633
|
+
baseUrl: resolveRouterURL(baseURL)
|
|
6634
|
+
})
|
|
6623
6635
|
}),
|
|
6624
6636
|
["mistral" /* MISTRAL */]: ({
|
|
6625
6637
|
modelName,
|
|
@@ -6643,18 +6655,32 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6643
6655
|
};
|
|
6644
6656
|
// Rerank model creators
|
|
6645
6657
|
rerankModelCreators = {
|
|
6646
|
-
["cohere" /* COHERE */]: ({
|
|
6658
|
+
["cohere" /* COHERE */]: ({
|
|
6659
|
+
modelName,
|
|
6660
|
+
apiToken,
|
|
6661
|
+
maxDocuments,
|
|
6662
|
+
baseURL
|
|
6663
|
+
}) => {
|
|
6647
6664
|
return new CohereRerank({
|
|
6648
|
-
apiKey: apiToken || this.resolveApiKey("cohere" /* COHERE */),
|
|
6649
6665
|
model: modelName,
|
|
6650
|
-
topN: maxDocuments || 20
|
|
6666
|
+
topN: maxDocuments || 20,
|
|
6667
|
+
client: new CohereClient({
|
|
6668
|
+
token: apiToken || this.resolveApiKey("cohere" /* COHERE */),
|
|
6669
|
+
baseUrl: resolveRouterURL(baseURL)
|
|
6670
|
+
})
|
|
6651
6671
|
});
|
|
6652
6672
|
},
|
|
6653
|
-
["voyageai" /* VOYAGEAI */]: ({
|
|
6673
|
+
["voyageai" /* VOYAGEAI */]: ({
|
|
6674
|
+
modelName,
|
|
6675
|
+
apiToken,
|
|
6676
|
+
maxDocuments,
|
|
6677
|
+
baseURL
|
|
6678
|
+
}) => {
|
|
6654
6679
|
return new VoyageAIRerank({
|
|
6655
6680
|
apiKey: apiToken || this.resolveApiKey("voyageai" /* VOYAGEAI */),
|
|
6656
6681
|
model: modelName,
|
|
6657
|
-
topN: maxDocuments || 20
|
|
6682
|
+
topN: maxDocuments || 20,
|
|
6683
|
+
baseUrl: resolveRouterURL(baseURL)
|
|
6658
6684
|
});
|
|
6659
6685
|
},
|
|
6660
6686
|
// Other providers don't support rerank yet
|
|
@@ -6665,9 +6691,10 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6665
6691
|
};
|
|
6666
6692
|
// Embedding model creators
|
|
6667
6693
|
embeddingModelCreators = {
|
|
6668
|
-
["openai" /* OPENAI */]: ({ modelName, apiToken }) => new OpenAIEmbeddings({
|
|
6694
|
+
["openai" /* OPENAI */]: ({ modelName, apiToken, baseURL }) => new OpenAIEmbeddings({
|
|
6669
6695
|
model: modelName,
|
|
6670
|
-
apiKey: apiToken || this.resolveApiKey("openai" /* OPENAI */)
|
|
6696
|
+
apiKey: apiToken || this.resolveApiKey("openai" /* OPENAI */),
|
|
6697
|
+
configuration: { baseURL: `${resolveRouterURL(baseURL)}/v1` }
|
|
6671
6698
|
}),
|
|
6672
6699
|
// Other providers not yet implemented for embeddings
|
|
6673
6700
|
["anthropic" /* ANTHROPIC */]: void 0,
|
|
@@ -6676,7 +6703,82 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6676
6703
|
["aws" /* AWS */]: void 0,
|
|
6677
6704
|
["voyageai" /* VOYAGEAI */]: void 0
|
|
6678
6705
|
};
|
|
6679
|
-
|
|
6706
|
+
// ══════════════════════════════════════════════════════════════
|
|
6707
|
+
// initializeChatModel — overloaded: ModelConfig | ModelByIdConfig
|
|
6708
|
+
// ══════════════════════════════════════════════════════════════
|
|
6709
|
+
async initializeChatModel(config, customTools) {
|
|
6710
|
+
if ("provider" in config && "modelName" in config) {
|
|
6711
|
+
return this.initializeChatModelDirect(config, customTools);
|
|
6712
|
+
}
|
|
6713
|
+
return this.initializeChatModelByIdInternal(config);
|
|
6714
|
+
}
|
|
6715
|
+
/**
|
|
6716
|
+
* Direct initialization by provider + modelName (no DB lookup).
|
|
6717
|
+
*/
|
|
6718
|
+
async initializeChatModelDirect(config, customTools) {
|
|
6719
|
+
const toolsConfig = normalizeToolConfigs(config.tools);
|
|
6720
|
+
const modelIdentifier = `${config.provider}:${config.modelName}`;
|
|
6721
|
+
const cacheKey = generateModelCacheKey(
|
|
6722
|
+
modelIdentifier,
|
|
6723
|
+
config.temperature,
|
|
6724
|
+
config.maxTokens,
|
|
6725
|
+
toolsConfig,
|
|
6726
|
+
config.baseURL
|
|
6727
|
+
);
|
|
6728
|
+
const cached = this.modelInstanceCache.get(cacheKey);
|
|
6729
|
+
if (cached) {
|
|
6730
|
+
this.logger.debug(`Using cached chat model instance: ${cacheKey}`);
|
|
6731
|
+
return cached;
|
|
6732
|
+
}
|
|
6733
|
+
const provider = config.provider;
|
|
6734
|
+
if (!Object.values(ModelProvider).includes(provider)) {
|
|
6735
|
+
throw new Error(
|
|
6736
|
+
`Unknown provider "${provider}". Valid: ${Object.values(ModelProvider).join(", ")}`
|
|
6737
|
+
);
|
|
6738
|
+
}
|
|
6739
|
+
const apiToken = this.resolveApiKey(provider);
|
|
6740
|
+
const temperature = config.temperature ?? 0.7;
|
|
6741
|
+
const maxTokens = config.maxTokens ?? 4096;
|
|
6742
|
+
const modelConfig = {
|
|
6743
|
+
modelId: modelIdentifier,
|
|
6744
|
+
modelName: config.modelName,
|
|
6745
|
+
provider,
|
|
6746
|
+
modelType: "chat" /* CHAT */,
|
|
6747
|
+
defaultTemperature: Number(temperature),
|
|
6748
|
+
defaultMaxTokens: Number(maxTokens),
|
|
6749
|
+
apiToken,
|
|
6750
|
+
requiresApiKey: true,
|
|
6751
|
+
baseURL: config.baseURL
|
|
6752
|
+
};
|
|
6753
|
+
this.logger.debug(
|
|
6754
|
+
`Creating chat model: ${modelIdentifier} (apiKeyResolved=${!!apiToken})`
|
|
6755
|
+
);
|
|
6756
|
+
const creator = this.chatModelCreators[provider];
|
|
6757
|
+
if (!creator) {
|
|
6758
|
+
throw new Error(`Chat models not supported for provider: ${provider}`);
|
|
6759
|
+
}
|
|
6760
|
+
const model = creator(modelConfig);
|
|
6761
|
+
model.metadata = {
|
|
6762
|
+
...model.metadata,
|
|
6763
|
+
modelId: modelIdentifier
|
|
6764
|
+
};
|
|
6765
|
+
if (toolsConfig || customTools) {
|
|
6766
|
+
const boundModel = await this.bindToolsToModel(
|
|
6767
|
+
model,
|
|
6768
|
+
toolsConfig,
|
|
6769
|
+
customTools
|
|
6770
|
+
);
|
|
6771
|
+
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
6772
|
+
return boundModel;
|
|
6773
|
+
}
|
|
6774
|
+
this.modelInstanceCache.set(cacheKey, model);
|
|
6775
|
+
return model;
|
|
6776
|
+
}
|
|
6777
|
+
/**
|
|
6778
|
+
* Legacy initialization by model ID (DB lookup via configFetcher).
|
|
6779
|
+
* @deprecated Pass ModelConfig with provider + modelName instead.
|
|
6780
|
+
*/
|
|
6781
|
+
async initializeChatModelByIdInternal(config) {
|
|
6680
6782
|
const cacheKey = this.generateModelCacheKey(config);
|
|
6681
6783
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6682
6784
|
if (cachedModel) {
|
|
@@ -6702,9 +6804,6 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6702
6804
|
this.logger.debug(`Creating new chat model instance: ${cacheKey}`);
|
|
6703
6805
|
let model;
|
|
6704
6806
|
if (finalConfig.useBedrock && finalConfig.bedrockModelId) {
|
|
6705
|
-
this.logger.debug(
|
|
6706
|
-
`Using Bedrock for model ${finalConfig.modelName}, bedrockModelId: ${finalConfig.bedrockModelId}`
|
|
6707
|
-
);
|
|
6708
6807
|
model = new ChatBedrockConverse({
|
|
6709
6808
|
model: finalConfig.bedrockModelId,
|
|
6710
6809
|
region: this.resolveBedrockRegion(),
|
|
@@ -6725,29 +6824,12 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6725
6824
|
...model.metadata,
|
|
6726
6825
|
modelId: config.modelId
|
|
6727
6826
|
};
|
|
6728
|
-
this.logger.debug("\u{1F527} Model initialized with metadata", {
|
|
6729
|
-
modelId: config.modelId,
|
|
6730
|
-
metadataKeys: Object.keys(model.metadata || {}),
|
|
6731
|
-
hasModelId: !!model.metadata?.modelId
|
|
6732
|
-
});
|
|
6733
|
-
this.logger.debug(
|
|
6734
|
-
`[TOOLS CHECK] toolsConfig exists: ${!!config.toolsConfig}, customTools exists: ${!!config.customTools}`
|
|
6735
|
-
);
|
|
6736
|
-
if (config.toolsConfig) {
|
|
6737
|
-
this.logger.debug(
|
|
6738
|
-
`[TOOLS CHECK] toolsConfig length: ${config.toolsConfig.length}, content: ${JSON.stringify(config.toolsConfig)}`
|
|
6739
|
-
);
|
|
6740
|
-
}
|
|
6741
6827
|
if (config.toolsConfig || config.customTools) {
|
|
6742
|
-
this.logger.debug(
|
|
6743
|
-
`[TOOLS] Calling bindToolsToModel with toolsConfig: ${JSON.stringify(config.toolsConfig)}`
|
|
6744
|
-
);
|
|
6745
6828
|
const boundModel = await this.bindToolsToModel(
|
|
6746
6829
|
model,
|
|
6747
6830
|
config.toolsConfig,
|
|
6748
6831
|
config.customTools
|
|
6749
6832
|
);
|
|
6750
|
-
this.logger.debug(`[TOOLS] bindToolsToModel returned successfully`);
|
|
6751
6833
|
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
6752
6834
|
return boundModel;
|
|
6753
6835
|
}
|
|
@@ -7573,6 +7655,6 @@ var MongoTokenStore = class {
|
|
|
7573
7655
|
}
|
|
7574
7656
|
};
|
|
7575
7657
|
|
|
7576
|
-
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_TRACER_OPTIONS, ENDPOINT_METADATA_KEY, Endpoint, EndpointRegistry, EventProcessor, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, RetrieverSearchType, RetrieverService, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildOAuthAuthorizationUrl, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, loadOAuthProviders, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
7658
|
+
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, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, RetrieverSearchType, RetrieverService, 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, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
7577
7659
|
//# sourceMappingURL=index.js.map
|
|
7578
7660
|
//# sourceMappingURL=index.js.map
|