@flutchai/flutch-sdk 0.1.10 → 0.1.12
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 +131 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -16
- package/dist/index.d.ts +20 -16
- package/dist/index.js +132 -82
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,21 +2,22 @@ import { JSONSchema7 } from 'json-schema';
|
|
|
2
2
|
import * as _nestjs_common from '@nestjs/common';
|
|
3
3
|
import { OnModuleInit, Logger, Type, CanActivate, ExecutionContext, DynamicModule } from '@nestjs/common';
|
|
4
4
|
import { ConfigService } from '@nestjs/config';
|
|
5
|
-
import { HumanMessage } from '@langchain/core/messages';
|
|
5
|
+
import { HumanMessage, AIMessageChunk } from '@langchain/core/messages';
|
|
6
6
|
import { BaseChannel, CompiledStateGraph, LangGraphRunnableConfig } from '@langchain/langgraph';
|
|
7
7
|
import Redis from 'ioredis';
|
|
8
8
|
import { Registry } from 'prom-client';
|
|
9
9
|
import { Response, Request } from 'express';
|
|
10
10
|
import { DiscoveryService, MetadataScanner, ModuleRef } from '@nestjs/core';
|
|
11
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
12
|
-
import { RunnableConfig } from '@langchain/core/runnables';
|
|
11
|
+
import { DynamicStructuredTool, StructuredTool } from '@langchain/core/tools';
|
|
12
|
+
import { Runnable, RunnableConfig } from '@langchain/core/runnables';
|
|
13
13
|
import { ChatAnthropic } from '@langchain/anthropic';
|
|
14
14
|
import { ChatCohere } from '@langchain/cohere';
|
|
15
15
|
import { ChatMistralAI } from '@langchain/mistralai';
|
|
16
16
|
import { ChatOpenAI } from '@langchain/openai';
|
|
17
|
-
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
17
|
+
import { BaseChatModel, BaseChatModelCallOptions } from '@langchain/core/language_models/chat_models';
|
|
18
18
|
import { BaseDocumentCompressor } from '@langchain/core/retrievers/document_compressors';
|
|
19
19
|
import { Embeddings } from '@langchain/core/embeddings';
|
|
20
|
+
import { BaseLanguageModelInput } from '@langchain/core/language_models/base';
|
|
20
21
|
import { Document } from '@langchain/core/documents';
|
|
21
22
|
|
|
22
23
|
interface RequestContext {
|
|
@@ -1222,6 +1223,8 @@ interface ModelByIdConfig {
|
|
|
1222
1223
|
modelId: string;
|
|
1223
1224
|
temperature?: number;
|
|
1224
1225
|
maxTokens?: number;
|
|
1226
|
+
toolsConfig?: IAgentToolConfig[];
|
|
1227
|
+
customTools?: DynamicStructuredTool[];
|
|
1225
1228
|
}
|
|
1226
1229
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1227
1230
|
interface ModelConfigWithToken {
|
|
@@ -1239,7 +1242,9 @@ type ModelCreator = (config: ModelConfig & {
|
|
|
1239
1242
|
customApiToken?: string;
|
|
1240
1243
|
}) => LLModel;
|
|
1241
1244
|
|
|
1242
|
-
type
|
|
1245
|
+
type ChatModelWithTools = Runnable<BaseLanguageModelInput, AIMessageChunk, BaseChatModelCallOptions>;
|
|
1246
|
+
type ChatModelOrRunnable = BaseChatModel | ChatModelWithTools;
|
|
1247
|
+
type Model = BaseChatModel | ChatModelWithTools | BaseDocumentCompressor | Embeddings;
|
|
1243
1248
|
interface ModelByIdWithTypeConfig extends ModelByIdConfig {
|
|
1244
1249
|
modelType: ModelType;
|
|
1245
1250
|
}
|
|
@@ -1250,11 +1255,11 @@ interface ModelConfigWithTokenAndType extends ModelConfigWithToken {
|
|
|
1250
1255
|
supportedFormats?: string[];
|
|
1251
1256
|
}
|
|
1252
1257
|
interface IModelInitializer {
|
|
1253
|
-
createChatModelById(modelId: string): Promise<
|
|
1258
|
+
createChatModelById(modelId: string): Promise<ChatModelOrRunnable>;
|
|
1254
1259
|
createRerankModelById(modelId: string): Promise<BaseDocumentCompressor>;
|
|
1255
1260
|
createEmbeddingModelById(modelId: string): Promise<Embeddings>;
|
|
1256
1261
|
createModelById(modelId: string, expectedType?: ModelType): Promise<Model>;
|
|
1257
|
-
initializeChatModel(config: ModelByIdConfig): Promise<
|
|
1262
|
+
initializeChatModel(config: ModelByIdConfig): Promise<ChatModelOrRunnable>;
|
|
1258
1263
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1259
1264
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
1260
1265
|
initializeModelByType(config: ModelByIdWithTypeConfig): Promise<Model>;
|
|
@@ -1279,15 +1284,17 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1279
1284
|
private modelConfigCache;
|
|
1280
1285
|
private modelInstanceCache;
|
|
1281
1286
|
constructor(configFetcher?: ModelConfigFetcher, logger?: Logger);
|
|
1287
|
+
private hashToolsConfig;
|
|
1282
1288
|
private generateModelCacheKey;
|
|
1283
1289
|
private requiresMaxCompletionTokens;
|
|
1284
1290
|
private readonly chatModelCreators;
|
|
1285
1291
|
private readonly rerankModelCreators;
|
|
1286
1292
|
private readonly embeddingModelCreators;
|
|
1287
|
-
initializeChatModel(config: ModelByIdConfig): Promise<BaseChatModel
|
|
1293
|
+
initializeChatModel(config: ModelByIdConfig): Promise<BaseChatModel | Runnable<BaseLanguageModelInput, AIMessageChunk, BaseChatModelCallOptions>>;
|
|
1294
|
+
private bindToolsToModel;
|
|
1288
1295
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1289
1296
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
1290
|
-
createChatModelById(modelId: string): Promise<
|
|
1297
|
+
createChatModelById(modelId: string): Promise<ChatModelOrRunnable>;
|
|
1291
1298
|
createRerankModelById(modelId: string): Promise<BaseDocumentCompressor>;
|
|
1292
1299
|
createEmbeddingModelById(modelId: string): Promise<Embeddings>;
|
|
1293
1300
|
createModelById(modelId: string, expectedType?: ModelType): Promise<Model>;
|
|
@@ -1305,11 +1312,6 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1305
1312
|
};
|
|
1306
1313
|
private fetchFromApi;
|
|
1307
1314
|
}
|
|
1308
|
-
declare function prepareModelWithTools(model: BaseChatModel, tools: StructuredTool[], baseConfig?: any): {
|
|
1309
|
-
modelWithTools: any;
|
|
1310
|
-
finalConfig: any;
|
|
1311
|
-
toolsMethod: "bindTools" | "manual" | "none";
|
|
1312
|
-
};
|
|
1313
1315
|
|
|
1314
1316
|
interface VoyageAIRerankConfig {
|
|
1315
1317
|
apiKey?: string;
|
|
@@ -1335,6 +1337,7 @@ interface IToolCatalog extends IBaseEntity {
|
|
|
1335
1337
|
isActive: boolean;
|
|
1336
1338
|
toolVersion?: string;
|
|
1337
1339
|
configSchema?: IToolConfigOption[];
|
|
1340
|
+
supportsDynamicSchema?: boolean;
|
|
1338
1341
|
}
|
|
1339
1342
|
interface IToolConfigOption {
|
|
1340
1343
|
key: string;
|
|
@@ -1357,6 +1360,7 @@ interface IToolConfigOption {
|
|
|
1357
1360
|
provider?: ModelProvider;
|
|
1358
1361
|
isActive?: boolean;
|
|
1359
1362
|
};
|
|
1363
|
+
includeInSchema?: boolean;
|
|
1360
1364
|
}
|
|
1361
1365
|
|
|
1362
1366
|
interface IAgentToolConfig {
|
|
@@ -1423,7 +1427,7 @@ declare class McpToolFilter {
|
|
|
1423
1427
|
private readonly logger;
|
|
1424
1428
|
private readonly mcpConverter;
|
|
1425
1429
|
constructor(mcpRuntimeUrl?: string);
|
|
1426
|
-
getFilteredTools(
|
|
1430
|
+
getFilteredTools(toolsConfig?: IAgentToolConfig[]): Promise<StructuredTool[]>;
|
|
1427
1431
|
getAllTools(): Promise<StructuredTool[]>;
|
|
1428
1432
|
isHealthy(): Promise<boolean>;
|
|
1429
1433
|
getAvailableToolNames(): Promise<string[]>;
|
|
@@ -1561,4 +1565,4 @@ declare class StaticDiscovery implements ServiceDiscoveryProvider {
|
|
|
1561
1565
|
}>>;
|
|
1562
1566
|
}
|
|
1563
1567
|
|
|
1564
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, AttachmentType, type AuditEntry, 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 CitationValue, type CompiledGraphFor, type ConcreteModels, type CustomDocument, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExtendedCallbackContext, type ExtendedCallbackHandler, FileBasedDiscovery, 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 IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, 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 IModelInitializer, 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, 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, bootstrap, createEndpointDescriptors, findCallbackMethod, findEndpointMethod, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints,
|
|
1568
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, AttachmentType, type AuditEntry, 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 ConcreteModels, type CustomDocument, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExtendedCallbackContext, type ExtendedCallbackHandler, FileBasedDiscovery, 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 IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, 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 IModelInitializer, 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, 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, bootstrap, createEndpointDescriptors, findCallbackMethod, findEndpointMethod, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, traceApiCall };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,21 +2,22 @@ import { JSONSchema7 } from 'json-schema';
|
|
|
2
2
|
import * as _nestjs_common from '@nestjs/common';
|
|
3
3
|
import { OnModuleInit, Logger, Type, CanActivate, ExecutionContext, DynamicModule } from '@nestjs/common';
|
|
4
4
|
import { ConfigService } from '@nestjs/config';
|
|
5
|
-
import { HumanMessage } from '@langchain/core/messages';
|
|
5
|
+
import { HumanMessage, AIMessageChunk } from '@langchain/core/messages';
|
|
6
6
|
import { BaseChannel, CompiledStateGraph, LangGraphRunnableConfig } from '@langchain/langgraph';
|
|
7
7
|
import Redis from 'ioredis';
|
|
8
8
|
import { Registry } from 'prom-client';
|
|
9
9
|
import { Response, Request } from 'express';
|
|
10
10
|
import { DiscoveryService, MetadataScanner, ModuleRef } from '@nestjs/core';
|
|
11
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
12
|
-
import { RunnableConfig } from '@langchain/core/runnables';
|
|
11
|
+
import { DynamicStructuredTool, StructuredTool } from '@langchain/core/tools';
|
|
12
|
+
import { Runnable, RunnableConfig } from '@langchain/core/runnables';
|
|
13
13
|
import { ChatAnthropic } from '@langchain/anthropic';
|
|
14
14
|
import { ChatCohere } from '@langchain/cohere';
|
|
15
15
|
import { ChatMistralAI } from '@langchain/mistralai';
|
|
16
16
|
import { ChatOpenAI } from '@langchain/openai';
|
|
17
|
-
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
17
|
+
import { BaseChatModel, BaseChatModelCallOptions } from '@langchain/core/language_models/chat_models';
|
|
18
18
|
import { BaseDocumentCompressor } from '@langchain/core/retrievers/document_compressors';
|
|
19
19
|
import { Embeddings } from '@langchain/core/embeddings';
|
|
20
|
+
import { BaseLanguageModelInput } from '@langchain/core/language_models/base';
|
|
20
21
|
import { Document } from '@langchain/core/documents';
|
|
21
22
|
|
|
22
23
|
interface RequestContext {
|
|
@@ -1222,6 +1223,8 @@ interface ModelByIdConfig {
|
|
|
1222
1223
|
modelId: string;
|
|
1223
1224
|
temperature?: number;
|
|
1224
1225
|
maxTokens?: number;
|
|
1226
|
+
toolsConfig?: IAgentToolConfig[];
|
|
1227
|
+
customTools?: DynamicStructuredTool[];
|
|
1225
1228
|
}
|
|
1226
1229
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1227
1230
|
interface ModelConfigWithToken {
|
|
@@ -1239,7 +1242,9 @@ type ModelCreator = (config: ModelConfig & {
|
|
|
1239
1242
|
customApiToken?: string;
|
|
1240
1243
|
}) => LLModel;
|
|
1241
1244
|
|
|
1242
|
-
type
|
|
1245
|
+
type ChatModelWithTools = Runnable<BaseLanguageModelInput, AIMessageChunk, BaseChatModelCallOptions>;
|
|
1246
|
+
type ChatModelOrRunnable = BaseChatModel | ChatModelWithTools;
|
|
1247
|
+
type Model = BaseChatModel | ChatModelWithTools | BaseDocumentCompressor | Embeddings;
|
|
1243
1248
|
interface ModelByIdWithTypeConfig extends ModelByIdConfig {
|
|
1244
1249
|
modelType: ModelType;
|
|
1245
1250
|
}
|
|
@@ -1250,11 +1255,11 @@ interface ModelConfigWithTokenAndType extends ModelConfigWithToken {
|
|
|
1250
1255
|
supportedFormats?: string[];
|
|
1251
1256
|
}
|
|
1252
1257
|
interface IModelInitializer {
|
|
1253
|
-
createChatModelById(modelId: string): Promise<
|
|
1258
|
+
createChatModelById(modelId: string): Promise<ChatModelOrRunnable>;
|
|
1254
1259
|
createRerankModelById(modelId: string): Promise<BaseDocumentCompressor>;
|
|
1255
1260
|
createEmbeddingModelById(modelId: string): Promise<Embeddings>;
|
|
1256
1261
|
createModelById(modelId: string, expectedType?: ModelType): Promise<Model>;
|
|
1257
|
-
initializeChatModel(config: ModelByIdConfig): Promise<
|
|
1262
|
+
initializeChatModel(config: ModelByIdConfig): Promise<ChatModelOrRunnable>;
|
|
1258
1263
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1259
1264
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
1260
1265
|
initializeModelByType(config: ModelByIdWithTypeConfig): Promise<Model>;
|
|
@@ -1279,15 +1284,17 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1279
1284
|
private modelConfigCache;
|
|
1280
1285
|
private modelInstanceCache;
|
|
1281
1286
|
constructor(configFetcher?: ModelConfigFetcher, logger?: Logger);
|
|
1287
|
+
private hashToolsConfig;
|
|
1282
1288
|
private generateModelCacheKey;
|
|
1283
1289
|
private requiresMaxCompletionTokens;
|
|
1284
1290
|
private readonly chatModelCreators;
|
|
1285
1291
|
private readonly rerankModelCreators;
|
|
1286
1292
|
private readonly embeddingModelCreators;
|
|
1287
|
-
initializeChatModel(config: ModelByIdConfig): Promise<BaseChatModel
|
|
1293
|
+
initializeChatModel(config: ModelByIdConfig): Promise<BaseChatModel | Runnable<BaseLanguageModelInput, AIMessageChunk, BaseChatModelCallOptions>>;
|
|
1294
|
+
private bindToolsToModel;
|
|
1288
1295
|
initializeRerankModel(config: ModelByIdConfig): Promise<BaseDocumentCompressor>;
|
|
1289
1296
|
initializeEmbeddingModel(config: ModelByIdConfig): Promise<Embeddings>;
|
|
1290
|
-
createChatModelById(modelId: string): Promise<
|
|
1297
|
+
createChatModelById(modelId: string): Promise<ChatModelOrRunnable>;
|
|
1291
1298
|
createRerankModelById(modelId: string): Promise<BaseDocumentCompressor>;
|
|
1292
1299
|
createEmbeddingModelById(modelId: string): Promise<Embeddings>;
|
|
1293
1300
|
createModelById(modelId: string, expectedType?: ModelType): Promise<Model>;
|
|
@@ -1305,11 +1312,6 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1305
1312
|
};
|
|
1306
1313
|
private fetchFromApi;
|
|
1307
1314
|
}
|
|
1308
|
-
declare function prepareModelWithTools(model: BaseChatModel, tools: StructuredTool[], baseConfig?: any): {
|
|
1309
|
-
modelWithTools: any;
|
|
1310
|
-
finalConfig: any;
|
|
1311
|
-
toolsMethod: "bindTools" | "manual" | "none";
|
|
1312
|
-
};
|
|
1313
1315
|
|
|
1314
1316
|
interface VoyageAIRerankConfig {
|
|
1315
1317
|
apiKey?: string;
|
|
@@ -1335,6 +1337,7 @@ interface IToolCatalog extends IBaseEntity {
|
|
|
1335
1337
|
isActive: boolean;
|
|
1336
1338
|
toolVersion?: string;
|
|
1337
1339
|
configSchema?: IToolConfigOption[];
|
|
1340
|
+
supportsDynamicSchema?: boolean;
|
|
1338
1341
|
}
|
|
1339
1342
|
interface IToolConfigOption {
|
|
1340
1343
|
key: string;
|
|
@@ -1357,6 +1360,7 @@ interface IToolConfigOption {
|
|
|
1357
1360
|
provider?: ModelProvider;
|
|
1358
1361
|
isActive?: boolean;
|
|
1359
1362
|
};
|
|
1363
|
+
includeInSchema?: boolean;
|
|
1360
1364
|
}
|
|
1361
1365
|
|
|
1362
1366
|
interface IAgentToolConfig {
|
|
@@ -1423,7 +1427,7 @@ declare class McpToolFilter {
|
|
|
1423
1427
|
private readonly logger;
|
|
1424
1428
|
private readonly mcpConverter;
|
|
1425
1429
|
constructor(mcpRuntimeUrl?: string);
|
|
1426
|
-
getFilteredTools(
|
|
1430
|
+
getFilteredTools(toolsConfig?: IAgentToolConfig[]): Promise<StructuredTool[]>;
|
|
1427
1431
|
getAllTools(): Promise<StructuredTool[]>;
|
|
1428
1432
|
isHealthy(): Promise<boolean>;
|
|
1429
1433
|
getAvailableToolNames(): Promise<string[]>;
|
|
@@ -1561,4 +1565,4 @@ declare class StaticDiscovery implements ServiceDiscoveryProvider {
|
|
|
1561
1565
|
}>>;
|
|
1562
1566
|
}
|
|
1563
1567
|
|
|
1564
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, AttachmentType, type AuditEntry, 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 CitationValue, type CompiledGraphFor, type ConcreteModels, type CustomDocument, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExtendedCallbackContext, type ExtendedCallbackHandler, FileBasedDiscovery, 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 IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, 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 IModelInitializer, 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, 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, bootstrap, createEndpointDescriptors, findCallbackMethod, findEndpointMethod, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints,
|
|
1568
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, AttachmentType, type AuditEntry, 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 ConcreteModels, type CustomDocument, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExtendedCallbackContext, type ExtendedCallbackHandler, FileBasedDiscovery, 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 IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, 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 IModelInitializer, 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, 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, bootstrap, createEndpointDescriptors, findCallbackMethod, findEndpointMethod, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, traceApiCall };
|
package/dist/index.js
CHANGED
|
@@ -3880,6 +3880,9 @@ var GraphServiceTokens = {
|
|
|
3880
3880
|
CLIENT: "GRAPH_SERVICE_CLIENT",
|
|
3881
3881
|
SETTINGS_REPOSITORY: "GRAPH_SERVICE_SETTINGS_REPOSITORY"
|
|
3882
3882
|
};
|
|
3883
|
+
|
|
3884
|
+
// src/graph/graph.controller.ts
|
|
3885
|
+
init_builder_registry_service();
|
|
3883
3886
|
var GraphController = class {
|
|
3884
3887
|
constructor(graphService, builderRegistry) {
|
|
3885
3888
|
this.graphService = graphService;
|
|
@@ -4042,7 +4045,8 @@ __decorateClass([
|
|
|
4042
4045
|
GraphController = __decorateClass([
|
|
4043
4046
|
ApiTags("Graphs"),
|
|
4044
4047
|
Controller(),
|
|
4045
|
-
__decorateParam(0, Inject("GRAPH_SERVICE"))
|
|
4048
|
+
__decorateParam(0, Inject("GRAPH_SERVICE")),
|
|
4049
|
+
__decorateParam(1, Inject(BuilderRegistryService))
|
|
4046
4050
|
], GraphController);
|
|
4047
4051
|
|
|
4048
4052
|
// src/graph/graph-manifest.schema.ts
|
|
@@ -4678,17 +4682,22 @@ var EventProcessor = class {
|
|
|
4678
4682
|
durationMs: Math.max(0, completedAt - startedAt),
|
|
4679
4683
|
totalEvents: acc.traceEvents.length
|
|
4680
4684
|
} : null;
|
|
4685
|
+
const textChain = allChains.find((c) => c.channel === "text");
|
|
4686
|
+
const text = textChain ? textChain.steps.filter((step) => step.type === "text").map((step) => step.text || "").join("") : "";
|
|
4681
4687
|
this.logger.log("\u{1F4CA} [EventProcessor] Final result assembled", {
|
|
4682
4688
|
totalChains: allChains.length,
|
|
4683
4689
|
textChains: allChains.filter((c) => c.channel === "text").length,
|
|
4684
4690
|
processingChains: allChains.filter((c) => c.channel === "processing").length,
|
|
4685
|
-
totalSteps: allChains.reduce((sum, c) => sum + c.steps.length, 0)
|
|
4691
|
+
totalSteps: allChains.reduce((sum, c) => sum + c.steps.length, 0),
|
|
4692
|
+
textLength: text.length
|
|
4686
4693
|
});
|
|
4687
4694
|
return {
|
|
4688
4695
|
content: {
|
|
4689
4696
|
contentChains: allChains.length > 0 ? allChains : void 0,
|
|
4690
4697
|
attachments: acc.attachments,
|
|
4691
|
-
metadata: acc.metadata
|
|
4698
|
+
metadata: acc.metadata,
|
|
4699
|
+
text
|
|
4700
|
+
// Add extracted text for backwards compatibility
|
|
4692
4701
|
},
|
|
4693
4702
|
trace
|
|
4694
4703
|
};
|
|
@@ -5516,37 +5525,43 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
5516
5525
|
logger = new Logger(_McpToolFilter.name);
|
|
5517
5526
|
mcpConverter;
|
|
5518
5527
|
/**
|
|
5519
|
-
* Fetch available tools from MCP runtime with
|
|
5520
|
-
* @param
|
|
5521
|
-
* @returns Array of LangChain Tool instances
|
|
5528
|
+
* Fetch available tools from MCP runtime with dynamic schema generation
|
|
5529
|
+
* @param toolsConfig Array of tool configurations with dynamic config
|
|
5530
|
+
* @returns Array of LangChain Tool instances with dynamic schemas
|
|
5522
5531
|
*/
|
|
5523
|
-
async getFilteredTools(
|
|
5532
|
+
async getFilteredTools(toolsConfig = []) {
|
|
5524
5533
|
this.logger.debug(
|
|
5525
|
-
`[DEBUG] Getting filtered tools.
|
|
5534
|
+
`[DEBUG] Getting filtered tools with dynamic schemas. Config: ${JSON.stringify(toolsConfig)}`
|
|
5526
5535
|
);
|
|
5527
5536
|
this.logger.debug(`[DEBUG] MCP Runtime URL: ${this.mcpRuntimeUrl}`);
|
|
5528
|
-
if (
|
|
5529
|
-
this.logger.debug("No tools
|
|
5537
|
+
if (toolsConfig.length === 0) {
|
|
5538
|
+
this.logger.debug("No tools configured, returning empty array");
|
|
5530
5539
|
return [];
|
|
5531
5540
|
}
|
|
5532
5541
|
try {
|
|
5533
|
-
const filterParam = enabledTools.join(",");
|
|
5534
5542
|
this.logger.debug(
|
|
5535
|
-
`[DEBUG] Making HTTP request to: ${this.mcpRuntimeUrl}/tools/
|
|
5543
|
+
`[DEBUG] Making HTTP POST request to: ${this.mcpRuntimeUrl}/tools/schemas`
|
|
5544
|
+
);
|
|
5545
|
+
this.logger.debug(`[DEBUG] Request body: ${JSON.stringify(toolsConfig)}`);
|
|
5546
|
+
const response = await axios2.post(
|
|
5547
|
+
`${this.mcpRuntimeUrl}/tools/schemas`,
|
|
5548
|
+
{ tools: toolsConfig },
|
|
5549
|
+
{
|
|
5550
|
+
timeout: 5e3,
|
|
5551
|
+
headers: {
|
|
5552
|
+
"Content-Type": "application/json"
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5536
5555
|
);
|
|
5537
|
-
const response = await axios2.get(`${this.mcpRuntimeUrl}/tools/list`, {
|
|
5538
|
-
params: { filter: filterParam },
|
|
5539
|
-
timeout: 5e3
|
|
5540
|
-
});
|
|
5541
5556
|
this.logger.debug(
|
|
5542
5557
|
`[DEBUG] HTTP response status: ${response.status}, data length: ${Array.isArray(response.data) ? response.data.length : "not array"}`
|
|
5543
5558
|
);
|
|
5544
|
-
const
|
|
5559
|
+
const dynamicTools = Array.isArray(response.data) ? response.data : [];
|
|
5545
5560
|
this.logger.debug(
|
|
5546
|
-
`Retrieved ${
|
|
5561
|
+
`Retrieved ${dynamicTools.length} dynamic tool schemas from MCP Runtime`
|
|
5547
5562
|
);
|
|
5548
5563
|
const mcpClient = {
|
|
5549
|
-
getTools: async () =>
|
|
5564
|
+
getTools: async () => dynamicTools,
|
|
5550
5565
|
executeTool: async (name, args) => {
|
|
5551
5566
|
this.logger.debug(`[DEBUG] Executing tool ${name} with args:`, args);
|
|
5552
5567
|
const response2 = await axios2.post(
|
|
@@ -5561,20 +5576,20 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
5561
5576
|
isHealthy: async () => true
|
|
5562
5577
|
};
|
|
5563
5578
|
this.logger.log(
|
|
5564
|
-
`\u{1F680} [McpToolFilter] Converting ${
|
|
5579
|
+
`\u{1F680} [McpToolFilter] Converting ${dynamicTools.length} dynamic tools using McpConverter`
|
|
5565
5580
|
);
|
|
5566
|
-
const tools = await this.mcpConverter.convertTools(
|
|
5581
|
+
const tools = await this.mcpConverter.convertTools(dynamicTools);
|
|
5567
5582
|
this.logger.log(
|
|
5568
5583
|
`\u{1F680} [McpToolFilter] Converted tools: ${tools.map((t) => t.name).join(", ")}`
|
|
5569
5584
|
);
|
|
5570
5585
|
this.logger.log(
|
|
5571
|
-
`Configured ${tools.length} tools from MCP runtime: ${
|
|
5586
|
+
`Configured ${tools.length} tools with dynamic schemas from MCP runtime: ${dynamicTools.map((t) => t.name).join(", ")}`
|
|
5572
5587
|
);
|
|
5573
5588
|
return tools;
|
|
5574
5589
|
} catch (error) {
|
|
5575
5590
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5576
5591
|
this.logger.warn(
|
|
5577
|
-
`[DEBUG] Failed to fetch
|
|
5592
|
+
`[DEBUG] Failed to fetch dynamic tool schemas from MCP runtime (${this.mcpRuntimeUrl}): ${errorMessage}`
|
|
5578
5593
|
);
|
|
5579
5594
|
this.logger.warn(`[DEBUG] Error details:`, {
|
|
5580
5595
|
error,
|
|
@@ -6119,8 +6134,30 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6119
6134
|
/**
|
|
6120
6135
|
* Generate cache key for model instances based on configuration
|
|
6121
6136
|
*/
|
|
6122
|
-
|
|
6123
|
-
|
|
6137
|
+
/**
|
|
6138
|
+
* Generate hash from toolsConfig for cache key
|
|
6139
|
+
* Uses MD5 hash to create short, unique identifier
|
|
6140
|
+
*/
|
|
6141
|
+
hashToolsConfig(toolsConfig) {
|
|
6142
|
+
const sorted = toolsConfig.map((t) => `${t.toolName}:${t.enabled}:${JSON.stringify(t.config || {})}`).sort().join("|");
|
|
6143
|
+
return createHash("md5").update(sorted).digest("hex").slice(0, 16);
|
|
6144
|
+
}
|
|
6145
|
+
/**
|
|
6146
|
+
* Generate cache key from ModelByIdConfig
|
|
6147
|
+
* Format: modelId:temperature:maxTokens[:toolsHash]
|
|
6148
|
+
* Example: "model123:0.7:4096" or "model123:0.7:4096:a1b2c3d4e5f6g7h8"
|
|
6149
|
+
*/
|
|
6150
|
+
generateModelCacheKey(config) {
|
|
6151
|
+
const parts = [
|
|
6152
|
+
config.modelId,
|
|
6153
|
+
config.temperature ?? "default",
|
|
6154
|
+
config.maxTokens ?? "default"
|
|
6155
|
+
];
|
|
6156
|
+
if (config.toolsConfig && config.toolsConfig.length > 0) {
|
|
6157
|
+
const toolsHash = this.hashToolsConfig(config.toolsConfig);
|
|
6158
|
+
parts.push(toolsHash);
|
|
6159
|
+
}
|
|
6160
|
+
return parts.join(":");
|
|
6124
6161
|
}
|
|
6125
6162
|
/**
|
|
6126
6163
|
* TEMPORARY SOLUTION for compatibility with new OpenAI models
|
|
@@ -6357,12 +6394,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6357
6394
|
["voyageai" /* VOYAGEAI */]: void 0
|
|
6358
6395
|
};
|
|
6359
6396
|
async initializeChatModel(config) {
|
|
6360
|
-
const cacheKey = this.generateModelCacheKey(
|
|
6361
|
-
config.modelId,
|
|
6362
|
-
config.temperature,
|
|
6363
|
-
config.maxTokens,
|
|
6364
|
-
"chat" /* CHAT */
|
|
6365
|
-
);
|
|
6397
|
+
const cacheKey = this.generateModelCacheKey(config);
|
|
6366
6398
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6367
6399
|
if (cachedModel) {
|
|
6368
6400
|
this.logger.debug(`Using cached chat model instance: ${cacheKey}`);
|
|
@@ -6400,17 +6432,76 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6400
6432
|
metadataKeys: Object.keys(model.metadata || {}),
|
|
6401
6433
|
hasModelId: !!model.metadata?.modelId
|
|
6402
6434
|
});
|
|
6435
|
+
this.logger.debug(
|
|
6436
|
+
`[TOOLS CHECK] toolsConfig exists: ${!!config.toolsConfig}, customTools exists: ${!!config.customTools}`
|
|
6437
|
+
);
|
|
6438
|
+
if (config.toolsConfig) {
|
|
6439
|
+
this.logger.debug(
|
|
6440
|
+
`[TOOLS CHECK] toolsConfig length: ${config.toolsConfig.length}, content: ${JSON.stringify(config.toolsConfig)}`
|
|
6441
|
+
);
|
|
6442
|
+
}
|
|
6443
|
+
if (config.toolsConfig || config.customTools) {
|
|
6444
|
+
this.logger.debug(
|
|
6445
|
+
`[TOOLS] Calling bindToolsToModel with toolsConfig: ${JSON.stringify(config.toolsConfig)}`
|
|
6446
|
+
);
|
|
6447
|
+
const boundModel = await this.bindToolsToModel(
|
|
6448
|
+
model,
|
|
6449
|
+
config.toolsConfig,
|
|
6450
|
+
config.customTools
|
|
6451
|
+
);
|
|
6452
|
+
this.logger.debug(`[TOOLS] bindToolsToModel returned successfully`);
|
|
6453
|
+
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
6454
|
+
return boundModel;
|
|
6455
|
+
}
|
|
6403
6456
|
this.modelInstanceCache.set(cacheKey, model);
|
|
6404
6457
|
return model;
|
|
6405
6458
|
}
|
|
6459
|
+
/**
|
|
6460
|
+
* Bind tools to model (merge toolsConfig and customTools)
|
|
6461
|
+
* For toolsConfig: fetch tool executors from MCP Runtime
|
|
6462
|
+
* For customTools: use as-is (already prepared DynamicStructuredTool)
|
|
6463
|
+
*
|
|
6464
|
+
* Returns:
|
|
6465
|
+
* - Runnable when tools are bound (model.bindTools returns Runnable)
|
|
6466
|
+
* - BaseChatModel when no tools
|
|
6467
|
+
*/
|
|
6468
|
+
async bindToolsToModel(model, toolsConfig, customTools) {
|
|
6469
|
+
const allTools = [];
|
|
6470
|
+
if (toolsConfig && toolsConfig.length > 0) {
|
|
6471
|
+
try {
|
|
6472
|
+
const enabledToolsConfig = toolsConfig.filter(
|
|
6473
|
+
(tc) => tc.enabled !== false
|
|
6474
|
+
);
|
|
6475
|
+
if (enabledToolsConfig.length > 0) {
|
|
6476
|
+
this.logger.debug(
|
|
6477
|
+
`Fetching ${enabledToolsConfig.length} tools with dynamic schemas from MCP Runtime: ${enabledToolsConfig.map((tc) => tc.toolName).join(", ")}`
|
|
6478
|
+
);
|
|
6479
|
+
const mcpToolFilter = new McpToolFilter();
|
|
6480
|
+
const mcpTools = await mcpToolFilter.getFilteredTools(enabledToolsConfig);
|
|
6481
|
+
this.logger.debug(
|
|
6482
|
+
`Successfully fetched ${mcpTools.length} tools with dynamic schemas from MCP Runtime`
|
|
6483
|
+
);
|
|
6484
|
+
allTools.push(...mcpTools);
|
|
6485
|
+
}
|
|
6486
|
+
} catch (error) {
|
|
6487
|
+
this.logger.error(
|
|
6488
|
+
`Failed to fetch tools from MCP Runtime: ${error instanceof Error ? error.message : String(error)}`
|
|
6489
|
+
);
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6492
|
+
if (customTools && customTools.length > 0) {
|
|
6493
|
+
allTools.push(...customTools);
|
|
6494
|
+
this.logger.debug(`Added ${customTools.length} custom tools to model`);
|
|
6495
|
+
}
|
|
6496
|
+
if (allTools.length > 0) {
|
|
6497
|
+
this.logger.debug(`Binding ${allTools.length} tools to model`);
|
|
6498
|
+
const modelWithTools = model.bindTools(allTools);
|
|
6499
|
+
return modelWithTools;
|
|
6500
|
+
}
|
|
6501
|
+
return model;
|
|
6502
|
+
}
|
|
6406
6503
|
async initializeRerankModel(config) {
|
|
6407
|
-
const cacheKey = this.generateModelCacheKey(
|
|
6408
|
-
config.modelId,
|
|
6409
|
-
void 0,
|
|
6410
|
-
// rerank models typically don't use temperature
|
|
6411
|
-
config.maxTokens,
|
|
6412
|
-
"rerank" /* RERANK */
|
|
6413
|
-
);
|
|
6504
|
+
const cacheKey = this.generateModelCacheKey(config);
|
|
6414
6505
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6415
6506
|
if (cachedModel) {
|
|
6416
6507
|
this.logger.debug(`Using cached rerank model instance: ${cacheKey}`);
|
|
@@ -6438,14 +6529,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6438
6529
|
return model;
|
|
6439
6530
|
}
|
|
6440
6531
|
async initializeEmbeddingModel(config) {
|
|
6441
|
-
const cacheKey = this.generateModelCacheKey(
|
|
6442
|
-
config.modelId,
|
|
6443
|
-
void 0,
|
|
6444
|
-
// embedding models typically don't use temperature
|
|
6445
|
-
void 0,
|
|
6446
|
-
// embedding models typically don't use maxTokens
|
|
6447
|
-
"embedding" /* EMBEDDING */
|
|
6448
|
-
);
|
|
6532
|
+
const cacheKey = this.generateModelCacheKey(config);
|
|
6449
6533
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6450
6534
|
if (cachedModel) {
|
|
6451
6535
|
this.logger.debug(`Using cached embedding model instance: ${cacheKey}`);
|
|
@@ -6593,7 +6677,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6593
6677
|
}
|
|
6594
6678
|
// Simple API request for microservices (copy from original LLMInitializer)
|
|
6595
6679
|
async fetchFromApi(modelId) {
|
|
6596
|
-
const apiUrl = process.env.API_URL
|
|
6680
|
+
const apiUrl = process.env.API_URL;
|
|
6597
6681
|
const token = process.env.INTERNAL_API_TOKEN;
|
|
6598
6682
|
if (!token) {
|
|
6599
6683
|
throw new Error("INTERNAL_API_TOKEN required for API mode");
|
|
@@ -6637,40 +6721,6 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6637
6721
|
return result;
|
|
6638
6722
|
}
|
|
6639
6723
|
};
|
|
6640
|
-
function prepareModelWithTools(model, tools, baseConfig = {}) {
|
|
6641
|
-
if (tools.length === 0) {
|
|
6642
|
-
return {
|
|
6643
|
-
modelWithTools: model,
|
|
6644
|
-
finalConfig: baseConfig,
|
|
6645
|
-
toolsMethod: "none"
|
|
6646
|
-
};
|
|
6647
|
-
}
|
|
6648
|
-
if (model.bindTools && typeof model.bindTools === "function") {
|
|
6649
|
-
try {
|
|
6650
|
-
const modelWithTools = model.bindTools(tools);
|
|
6651
|
-
return {
|
|
6652
|
-
modelWithTools,
|
|
6653
|
-
finalConfig: baseConfig,
|
|
6654
|
-
toolsMethod: "bindTools"
|
|
6655
|
-
};
|
|
6656
|
-
} catch (error) {
|
|
6657
|
-
const invokeConfig2 = { tools };
|
|
6658
|
-
const finalConfig2 = { ...baseConfig, ...invokeConfig2 };
|
|
6659
|
-
return {
|
|
6660
|
-
modelWithTools: model,
|
|
6661
|
-
finalConfig: finalConfig2,
|
|
6662
|
-
toolsMethod: "manual"
|
|
6663
|
-
};
|
|
6664
|
-
}
|
|
6665
|
-
}
|
|
6666
|
-
const invokeConfig = { tools };
|
|
6667
|
-
const finalConfig = { ...baseConfig, ...invokeConfig };
|
|
6668
|
-
return {
|
|
6669
|
-
modelWithTools: model,
|
|
6670
|
-
finalConfig,
|
|
6671
|
-
toolsMethod: "manual"
|
|
6672
|
-
};
|
|
6673
|
-
}
|
|
6674
6724
|
|
|
6675
6725
|
// src/retriever/enums.ts
|
|
6676
6726
|
var RetrieverSearchType = /* @__PURE__ */ ((RetrieverSearchType2) => {
|
|
@@ -6981,6 +7031,6 @@ StaticDiscovery = __decorateClass([
|
|
|
6981
7031
|
Injectable()
|
|
6982
7032
|
], StaticDiscovery);
|
|
6983
7033
|
|
|
6984
|
-
export { AbstractGraphBuilder, AttachmentType, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, CallbackController, CallbackMetrics, CallbackPatchService, CallbackRateLimiter, CallbackRegistry, CallbackStore, CallbackTokenGuard, ChatFeature, DEFAULT_TRACER_OPTIONS, ENDPOINT_METADATA_KEY, Endpoint, EndpointRegistry, EventProcessor, FileBasedDiscovery, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, RetrieverSearchType, RetrieverService, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, bootstrap, createEndpointDescriptors, findCallbackMethod, findEndpointMethod, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints,
|
|
7034
|
+
export { AbstractGraphBuilder, AttachmentType, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, CallbackController, CallbackMetrics, CallbackPatchService, CallbackRateLimiter, CallbackRegistry, CallbackStore, CallbackTokenGuard, ChatFeature, DEFAULT_TRACER_OPTIONS, ENDPOINT_METADATA_KEY, Endpoint, EndpointRegistry, EventProcessor, FileBasedDiscovery, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, RetrieverSearchType, RetrieverService, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, bootstrap, createEndpointDescriptors, findCallbackMethod, findEndpointMethod, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, traceApiCall };
|
|
6985
7035
|
//# sourceMappingURL=index.js.map
|
|
6986
7036
|
//# sourceMappingURL=index.js.map
|