@flutchai/flutch-sdk 0.2.15 → 0.2.17
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 +166 -52
- 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 +160 -53
- 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 | undefined;
|
|
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 | undefined;
|
|
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,9 +6437,18 @@ 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
|
+
if (baseURL) return baseURL;
|
|
6449
|
+
if (process.env.FLUTCH_ROUTER_URL) return process.env.FLUTCH_ROUTER_URL;
|
|
6450
|
+
if (process.env.FLUTCH_API_TOKEN) return DEFAULT_ROUTER_URL;
|
|
6451
|
+
return void 0;
|
|
6442
6452
|
}
|
|
6443
6453
|
function generateModelCacheKey(modelId, temperature, maxTokens, toolsConfig, baseURL) {
|
|
6444
6454
|
const parts = [
|
|
@@ -6478,13 +6488,14 @@ var VoyageAIRerank = class extends BaseDocumentCompressor {
|
|
|
6478
6488
|
model;
|
|
6479
6489
|
topN;
|
|
6480
6490
|
truncation;
|
|
6481
|
-
baseUrl
|
|
6491
|
+
baseUrl;
|
|
6482
6492
|
constructor(config) {
|
|
6483
6493
|
super();
|
|
6484
6494
|
this.apiKey = config.apiKey || process.env.VOYAGEAI_API_KEY || "";
|
|
6485
6495
|
this.model = config.model || "rerank-2";
|
|
6486
6496
|
this.topN = config.topN || 20;
|
|
6487
6497
|
this.truncation = config.truncation ?? true;
|
|
6498
|
+
this.baseUrl = config.baseUrl ? `${config.baseUrl}/v1/rerank` : "https://api.voyageai.com/v1/rerank";
|
|
6488
6499
|
if (!this.apiKey) {
|
|
6489
6500
|
throw new Error(
|
|
6490
6501
|
"VoyageAI API key is required. Set VOYAGEAI_API_KEY environment variable or pass apiKey in config."
|
|
@@ -6544,12 +6555,15 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6544
6555
|
};
|
|
6545
6556
|
/**
|
|
6546
6557
|
* Resolve API key for a provider.
|
|
6547
|
-
*
|
|
6558
|
+
* Priority: custom resolver > FLUTCH_API_TOKEN > provider-specific env var.
|
|
6548
6559
|
*/
|
|
6549
6560
|
resolveApiKey(provider) {
|
|
6550
6561
|
if (this.apiKeyResolver) {
|
|
6551
6562
|
return this.apiKeyResolver(provider);
|
|
6552
6563
|
}
|
|
6564
|
+
if (process.env.FLUTCH_API_TOKEN) {
|
|
6565
|
+
return process.env.FLUTCH_API_TOKEN;
|
|
6566
|
+
}
|
|
6553
6567
|
const envVar = _ModelInitializer.DEFAULT_ENV_MAP[provider];
|
|
6554
6568
|
return envVar ? process.env[envVar] : void 0;
|
|
6555
6569
|
}
|
|
@@ -6595,7 +6609,10 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6595
6609
|
defaultMaxTokens,
|
|
6596
6610
|
apiToken || this.resolveApiKey("openai" /* OPENAI */) || ""
|
|
6597
6611
|
);
|
|
6598
|
-
|
|
6612
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6613
|
+
if (routerURL) {
|
|
6614
|
+
config.configuration = { baseURL: `${routerURL}/v1` };
|
|
6615
|
+
}
|
|
6599
6616
|
return new ChatOpenAI(config);
|
|
6600
6617
|
},
|
|
6601
6618
|
["anthropic" /* ANTHROPIC */]: ({
|
|
@@ -6609,52 +6626,81 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6609
6626
|
temperature: defaultTemperature,
|
|
6610
6627
|
maxTokens: defaultMaxTokens,
|
|
6611
6628
|
anthropicApiKey: apiToken || this.resolveApiKey("anthropic" /* ANTHROPIC */),
|
|
6612
|
-
|
|
6629
|
+
...resolveRouterURL(baseURL) && {
|
|
6630
|
+
anthropicApiUrl: resolveRouterURL(baseURL)
|
|
6631
|
+
}
|
|
6613
6632
|
}),
|
|
6614
6633
|
["cohere" /* COHERE */]: ({
|
|
6615
6634
|
modelName,
|
|
6616
6635
|
defaultTemperature,
|
|
6617
6636
|
defaultMaxTokens,
|
|
6618
|
-
apiToken
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6637
|
+
apiToken,
|
|
6638
|
+
baseURL
|
|
6639
|
+
}) => {
|
|
6640
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6641
|
+
const token = apiToken || this.resolveApiKey("cohere" /* COHERE */);
|
|
6642
|
+
return routerURL ? new ChatCohere({
|
|
6643
|
+
model: modelName,
|
|
6644
|
+
temperature: defaultTemperature,
|
|
6645
|
+
client: new CohereClient({ token, baseUrl: routerURL })
|
|
6646
|
+
}) : new ChatCohere({
|
|
6647
|
+
model: modelName,
|
|
6648
|
+
temperature: defaultTemperature,
|
|
6649
|
+
apiKey: token
|
|
6650
|
+
});
|
|
6651
|
+
},
|
|
6624
6652
|
["mistral" /* MISTRAL */]: ({
|
|
6625
6653
|
modelName,
|
|
6626
6654
|
defaultTemperature,
|
|
6627
6655
|
defaultMaxTokens,
|
|
6628
6656
|
apiToken,
|
|
6629
6657
|
baseURL
|
|
6630
|
-
}) =>
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
}
|
|
6658
|
+
}) => {
|
|
6659
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6660
|
+
return new ChatMistralAI({
|
|
6661
|
+
model: modelName,
|
|
6662
|
+
temperature: defaultTemperature,
|
|
6663
|
+
maxTokens: defaultMaxTokens,
|
|
6664
|
+
apiKey: apiToken || this.resolveApiKey("mistral" /* MISTRAL */),
|
|
6665
|
+
...routerURL && { serverURL: `${routerURL}/v1` }
|
|
6666
|
+
});
|
|
6667
|
+
},
|
|
6640
6668
|
["voyageai" /* VOYAGEAI */]: () => {
|
|
6641
6669
|
throw new Error("VoyageAI chat models not implemented");
|
|
6642
6670
|
}
|
|
6643
6671
|
};
|
|
6644
6672
|
// Rerank model creators
|
|
6645
6673
|
rerankModelCreators = {
|
|
6646
|
-
["cohere" /* COHERE */]: ({
|
|
6647
|
-
|
|
6648
|
-
|
|
6674
|
+
["cohere" /* COHERE */]: ({
|
|
6675
|
+
modelName,
|
|
6676
|
+
apiToken,
|
|
6677
|
+
maxDocuments,
|
|
6678
|
+
baseURL
|
|
6679
|
+
}) => {
|
|
6680
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6681
|
+
const token = apiToken || this.resolveApiKey("cohere" /* COHERE */);
|
|
6682
|
+
return routerURL ? new CohereRerank({
|
|
6683
|
+
model: modelName,
|
|
6684
|
+
topN: maxDocuments || 20,
|
|
6685
|
+
client: new CohereClient({ token, baseUrl: routerURL })
|
|
6686
|
+
}) : new CohereRerank({
|
|
6649
6687
|
model: modelName,
|
|
6650
|
-
topN: maxDocuments || 20
|
|
6688
|
+
topN: maxDocuments || 20,
|
|
6689
|
+
apiKey: token
|
|
6651
6690
|
});
|
|
6652
6691
|
},
|
|
6653
|
-
["voyageai" /* VOYAGEAI */]: ({
|
|
6692
|
+
["voyageai" /* VOYAGEAI */]: ({
|
|
6693
|
+
modelName,
|
|
6694
|
+
apiToken,
|
|
6695
|
+
maxDocuments,
|
|
6696
|
+
baseURL
|
|
6697
|
+
}) => {
|
|
6698
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6654
6699
|
return new VoyageAIRerank({
|
|
6655
6700
|
apiKey: apiToken || this.resolveApiKey("voyageai" /* VOYAGEAI */),
|
|
6656
6701
|
model: modelName,
|
|
6657
|
-
topN: maxDocuments || 20
|
|
6702
|
+
topN: maxDocuments || 20,
|
|
6703
|
+
...routerURL && { baseUrl: routerURL }
|
|
6658
6704
|
});
|
|
6659
6705
|
},
|
|
6660
6706
|
// Other providers don't support rerank yet
|
|
@@ -6665,10 +6711,16 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6665
6711
|
};
|
|
6666
6712
|
// Embedding model creators
|
|
6667
6713
|
embeddingModelCreators = {
|
|
6668
|
-
["openai" /* OPENAI */]: ({ modelName, apiToken }) =>
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6714
|
+
["openai" /* OPENAI */]: ({ modelName, apiToken, baseURL }) => {
|
|
6715
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6716
|
+
return new OpenAIEmbeddings({
|
|
6717
|
+
model: modelName,
|
|
6718
|
+
apiKey: apiToken || this.resolveApiKey("openai" /* OPENAI */),
|
|
6719
|
+
...routerURL && {
|
|
6720
|
+
configuration: { baseURL: `${routerURL}/v1` }
|
|
6721
|
+
}
|
|
6722
|
+
});
|
|
6723
|
+
},
|
|
6672
6724
|
// Other providers not yet implemented for embeddings
|
|
6673
6725
|
["anthropic" /* ANTHROPIC */]: void 0,
|
|
6674
6726
|
["cohere" /* COHERE */]: void 0,
|
|
@@ -6676,7 +6728,82 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6676
6728
|
["aws" /* AWS */]: void 0,
|
|
6677
6729
|
["voyageai" /* VOYAGEAI */]: void 0
|
|
6678
6730
|
};
|
|
6679
|
-
|
|
6731
|
+
// ══════════════════════════════════════════════════════════════
|
|
6732
|
+
// initializeChatModel — overloaded: ModelConfig | ModelByIdConfig
|
|
6733
|
+
// ══════════════════════════════════════════════════════════════
|
|
6734
|
+
async initializeChatModel(config, customTools) {
|
|
6735
|
+
if ("provider" in config && "modelName" in config) {
|
|
6736
|
+
return this.initializeChatModelDirect(config, customTools);
|
|
6737
|
+
}
|
|
6738
|
+
return this.initializeChatModelByIdInternal(config);
|
|
6739
|
+
}
|
|
6740
|
+
/**
|
|
6741
|
+
* Direct initialization by provider + modelName (no DB lookup).
|
|
6742
|
+
*/
|
|
6743
|
+
async initializeChatModelDirect(config, customTools) {
|
|
6744
|
+
const toolsConfig = normalizeToolConfigs(config.tools);
|
|
6745
|
+
const modelIdentifier = `${config.provider}:${config.modelName}`;
|
|
6746
|
+
const cacheKey = generateModelCacheKey(
|
|
6747
|
+
modelIdentifier,
|
|
6748
|
+
config.temperature,
|
|
6749
|
+
config.maxTokens,
|
|
6750
|
+
toolsConfig,
|
|
6751
|
+
config.baseURL
|
|
6752
|
+
);
|
|
6753
|
+
const cached = this.modelInstanceCache.get(cacheKey);
|
|
6754
|
+
if (cached) {
|
|
6755
|
+
this.logger.debug(`Using cached chat model instance: ${cacheKey}`);
|
|
6756
|
+
return cached;
|
|
6757
|
+
}
|
|
6758
|
+
const provider = config.provider;
|
|
6759
|
+
if (!Object.values(ModelProvider).includes(provider)) {
|
|
6760
|
+
throw new Error(
|
|
6761
|
+
`Unknown provider "${provider}". Valid: ${Object.values(ModelProvider).join(", ")}`
|
|
6762
|
+
);
|
|
6763
|
+
}
|
|
6764
|
+
const apiToken = this.resolveApiKey(provider);
|
|
6765
|
+
const temperature = config.temperature ?? 0.7;
|
|
6766
|
+
const maxTokens = config.maxTokens ?? 4096;
|
|
6767
|
+
const modelConfig = {
|
|
6768
|
+
modelId: modelIdentifier,
|
|
6769
|
+
modelName: config.modelName,
|
|
6770
|
+
provider,
|
|
6771
|
+
modelType: "chat" /* CHAT */,
|
|
6772
|
+
defaultTemperature: Number(temperature),
|
|
6773
|
+
defaultMaxTokens: Number(maxTokens),
|
|
6774
|
+
apiToken,
|
|
6775
|
+
requiresApiKey: true,
|
|
6776
|
+
baseURL: config.baseURL
|
|
6777
|
+
};
|
|
6778
|
+
this.logger.debug(
|
|
6779
|
+
`Creating chat model: ${modelIdentifier} (apiKeyResolved=${!!apiToken})`
|
|
6780
|
+
);
|
|
6781
|
+
const creator = this.chatModelCreators[provider];
|
|
6782
|
+
if (!creator) {
|
|
6783
|
+
throw new Error(`Chat models not supported for provider: ${provider}`);
|
|
6784
|
+
}
|
|
6785
|
+
const model = creator(modelConfig);
|
|
6786
|
+
model.metadata = {
|
|
6787
|
+
...model.metadata,
|
|
6788
|
+
modelId: modelIdentifier
|
|
6789
|
+
};
|
|
6790
|
+
if (toolsConfig || customTools) {
|
|
6791
|
+
const boundModel = await this.bindToolsToModel(
|
|
6792
|
+
model,
|
|
6793
|
+
toolsConfig,
|
|
6794
|
+
customTools
|
|
6795
|
+
);
|
|
6796
|
+
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
6797
|
+
return boundModel;
|
|
6798
|
+
}
|
|
6799
|
+
this.modelInstanceCache.set(cacheKey, model);
|
|
6800
|
+
return model;
|
|
6801
|
+
}
|
|
6802
|
+
/**
|
|
6803
|
+
* Legacy initialization by model ID (DB lookup via configFetcher).
|
|
6804
|
+
* @deprecated Pass ModelConfig with provider + modelName instead.
|
|
6805
|
+
*/
|
|
6806
|
+
async initializeChatModelByIdInternal(config) {
|
|
6680
6807
|
const cacheKey = this.generateModelCacheKey(config);
|
|
6681
6808
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6682
6809
|
if (cachedModel) {
|
|
@@ -6702,9 +6829,6 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6702
6829
|
this.logger.debug(`Creating new chat model instance: ${cacheKey}`);
|
|
6703
6830
|
let model;
|
|
6704
6831
|
if (finalConfig.useBedrock && finalConfig.bedrockModelId) {
|
|
6705
|
-
this.logger.debug(
|
|
6706
|
-
`Using Bedrock for model ${finalConfig.modelName}, bedrockModelId: ${finalConfig.bedrockModelId}`
|
|
6707
|
-
);
|
|
6708
6832
|
model = new ChatBedrockConverse({
|
|
6709
6833
|
model: finalConfig.bedrockModelId,
|
|
6710
6834
|
region: this.resolveBedrockRegion(),
|
|
@@ -6725,29 +6849,12 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6725
6849
|
...model.metadata,
|
|
6726
6850
|
modelId: config.modelId
|
|
6727
6851
|
};
|
|
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
6852
|
if (config.toolsConfig || config.customTools) {
|
|
6742
|
-
this.logger.debug(
|
|
6743
|
-
`[TOOLS] Calling bindToolsToModel with toolsConfig: ${JSON.stringify(config.toolsConfig)}`
|
|
6744
|
-
);
|
|
6745
6853
|
const boundModel = await this.bindToolsToModel(
|
|
6746
6854
|
model,
|
|
6747
6855
|
config.toolsConfig,
|
|
6748
6856
|
config.customTools
|
|
6749
6857
|
);
|
|
6750
|
-
this.logger.debug(`[TOOLS] bindToolsToModel returned successfully`);
|
|
6751
6858
|
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
6752
6859
|
return boundModel;
|
|
6753
6860
|
}
|
|
@@ -7573,6 +7680,6 @@ var MongoTokenStore = class {
|
|
|
7573
7680
|
}
|
|
7574
7681
|
};
|
|
7575
7682
|
|
|
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 };
|
|
7683
|
+
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
7684
|
//# sourceMappingURL=index.js.map
|
|
7578
7685
|
//# sourceMappingURL=index.js.map
|