@flutchai/flutch-sdk 0.1.10 → 0.1.11
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 +113 -79
- 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 +114 -79
- 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
|
@@ -5516,37 +5516,43 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
5516
5516
|
logger = new Logger(_McpToolFilter.name);
|
|
5517
5517
|
mcpConverter;
|
|
5518
5518
|
/**
|
|
5519
|
-
* Fetch available tools from MCP runtime with
|
|
5520
|
-
* @param
|
|
5521
|
-
* @returns Array of LangChain Tool instances
|
|
5519
|
+
* Fetch available tools from MCP runtime with dynamic schema generation
|
|
5520
|
+
* @param toolsConfig Array of tool configurations with dynamic config
|
|
5521
|
+
* @returns Array of LangChain Tool instances with dynamic schemas
|
|
5522
5522
|
*/
|
|
5523
|
-
async getFilteredTools(
|
|
5523
|
+
async getFilteredTools(toolsConfig = []) {
|
|
5524
5524
|
this.logger.debug(
|
|
5525
|
-
`[DEBUG] Getting filtered tools.
|
|
5525
|
+
`[DEBUG] Getting filtered tools with dynamic schemas. Config: ${JSON.stringify(toolsConfig)}`
|
|
5526
5526
|
);
|
|
5527
5527
|
this.logger.debug(`[DEBUG] MCP Runtime URL: ${this.mcpRuntimeUrl}`);
|
|
5528
|
-
if (
|
|
5529
|
-
this.logger.debug("No tools
|
|
5528
|
+
if (toolsConfig.length === 0) {
|
|
5529
|
+
this.logger.debug("No tools configured, returning empty array");
|
|
5530
5530
|
return [];
|
|
5531
5531
|
}
|
|
5532
5532
|
try {
|
|
5533
|
-
const filterParam = enabledTools.join(",");
|
|
5534
5533
|
this.logger.debug(
|
|
5535
|
-
`[DEBUG] Making HTTP request to: ${this.mcpRuntimeUrl}/tools/
|
|
5534
|
+
`[DEBUG] Making HTTP POST request to: ${this.mcpRuntimeUrl}/tools/schemas`
|
|
5535
|
+
);
|
|
5536
|
+
this.logger.debug(`[DEBUG] Request body: ${JSON.stringify(toolsConfig)}`);
|
|
5537
|
+
const response = await axios2.post(
|
|
5538
|
+
`${this.mcpRuntimeUrl}/tools/schemas`,
|
|
5539
|
+
{ tools: toolsConfig },
|
|
5540
|
+
{
|
|
5541
|
+
timeout: 5e3,
|
|
5542
|
+
headers: {
|
|
5543
|
+
"Content-Type": "application/json"
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5536
5546
|
);
|
|
5537
|
-
const response = await axios2.get(`${this.mcpRuntimeUrl}/tools/list`, {
|
|
5538
|
-
params: { filter: filterParam },
|
|
5539
|
-
timeout: 5e3
|
|
5540
|
-
});
|
|
5541
5547
|
this.logger.debug(
|
|
5542
5548
|
`[DEBUG] HTTP response status: ${response.status}, data length: ${Array.isArray(response.data) ? response.data.length : "not array"}`
|
|
5543
5549
|
);
|
|
5544
|
-
const
|
|
5550
|
+
const dynamicTools = Array.isArray(response.data) ? response.data : [];
|
|
5545
5551
|
this.logger.debug(
|
|
5546
|
-
`Retrieved ${
|
|
5552
|
+
`Retrieved ${dynamicTools.length} dynamic tool schemas from MCP Runtime`
|
|
5547
5553
|
);
|
|
5548
5554
|
const mcpClient = {
|
|
5549
|
-
getTools: async () =>
|
|
5555
|
+
getTools: async () => dynamicTools,
|
|
5550
5556
|
executeTool: async (name, args) => {
|
|
5551
5557
|
this.logger.debug(`[DEBUG] Executing tool ${name} with args:`, args);
|
|
5552
5558
|
const response2 = await axios2.post(
|
|
@@ -5561,20 +5567,20 @@ var McpToolFilter = class _McpToolFilter {
|
|
|
5561
5567
|
isHealthy: async () => true
|
|
5562
5568
|
};
|
|
5563
5569
|
this.logger.log(
|
|
5564
|
-
`\u{1F680} [McpToolFilter] Converting ${
|
|
5570
|
+
`\u{1F680} [McpToolFilter] Converting ${dynamicTools.length} dynamic tools using McpConverter`
|
|
5565
5571
|
);
|
|
5566
|
-
const tools = await this.mcpConverter.convertTools(
|
|
5572
|
+
const tools = await this.mcpConverter.convertTools(dynamicTools);
|
|
5567
5573
|
this.logger.log(
|
|
5568
5574
|
`\u{1F680} [McpToolFilter] Converted tools: ${tools.map((t) => t.name).join(", ")}`
|
|
5569
5575
|
);
|
|
5570
5576
|
this.logger.log(
|
|
5571
|
-
`Configured ${tools.length} tools from MCP runtime: ${
|
|
5577
|
+
`Configured ${tools.length} tools with dynamic schemas from MCP runtime: ${dynamicTools.map((t) => t.name).join(", ")}`
|
|
5572
5578
|
);
|
|
5573
5579
|
return tools;
|
|
5574
5580
|
} catch (error) {
|
|
5575
5581
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5576
5582
|
this.logger.warn(
|
|
5577
|
-
`[DEBUG] Failed to fetch
|
|
5583
|
+
`[DEBUG] Failed to fetch dynamic tool schemas from MCP runtime (${this.mcpRuntimeUrl}): ${errorMessage}`
|
|
5578
5584
|
);
|
|
5579
5585
|
this.logger.warn(`[DEBUG] Error details:`, {
|
|
5580
5586
|
error,
|
|
@@ -6119,8 +6125,30 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6119
6125
|
/**
|
|
6120
6126
|
* Generate cache key for model instances based on configuration
|
|
6121
6127
|
*/
|
|
6122
|
-
|
|
6123
|
-
|
|
6128
|
+
/**
|
|
6129
|
+
* Generate hash from toolsConfig for cache key
|
|
6130
|
+
* Uses MD5 hash to create short, unique identifier
|
|
6131
|
+
*/
|
|
6132
|
+
hashToolsConfig(toolsConfig) {
|
|
6133
|
+
const sorted = toolsConfig.map((t) => `${t.toolName}:${t.enabled}:${JSON.stringify(t.config || {})}`).sort().join("|");
|
|
6134
|
+
return createHash("md5").update(sorted).digest("hex").slice(0, 16);
|
|
6135
|
+
}
|
|
6136
|
+
/**
|
|
6137
|
+
* Generate cache key from ModelByIdConfig
|
|
6138
|
+
* Format: modelId:temperature:maxTokens[:toolsHash]
|
|
6139
|
+
* Example: "model123:0.7:4096" or "model123:0.7:4096:a1b2c3d4e5f6g7h8"
|
|
6140
|
+
*/
|
|
6141
|
+
generateModelCacheKey(config) {
|
|
6142
|
+
const parts = [
|
|
6143
|
+
config.modelId,
|
|
6144
|
+
config.temperature ?? "default",
|
|
6145
|
+
config.maxTokens ?? "default"
|
|
6146
|
+
];
|
|
6147
|
+
if (config.toolsConfig && config.toolsConfig.length > 0) {
|
|
6148
|
+
const toolsHash = this.hashToolsConfig(config.toolsConfig);
|
|
6149
|
+
parts.push(toolsHash);
|
|
6150
|
+
}
|
|
6151
|
+
return parts.join(":");
|
|
6124
6152
|
}
|
|
6125
6153
|
/**
|
|
6126
6154
|
* TEMPORARY SOLUTION for compatibility with new OpenAI models
|
|
@@ -6357,12 +6385,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6357
6385
|
["voyageai" /* VOYAGEAI */]: void 0
|
|
6358
6386
|
};
|
|
6359
6387
|
async initializeChatModel(config) {
|
|
6360
|
-
const cacheKey = this.generateModelCacheKey(
|
|
6361
|
-
config.modelId,
|
|
6362
|
-
config.temperature,
|
|
6363
|
-
config.maxTokens,
|
|
6364
|
-
"chat" /* CHAT */
|
|
6365
|
-
);
|
|
6388
|
+
const cacheKey = this.generateModelCacheKey(config);
|
|
6366
6389
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6367
6390
|
if (cachedModel) {
|
|
6368
6391
|
this.logger.debug(`Using cached chat model instance: ${cacheKey}`);
|
|
@@ -6400,17 +6423,70 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6400
6423
|
metadataKeys: Object.keys(model.metadata || {}),
|
|
6401
6424
|
hasModelId: !!model.metadata?.modelId
|
|
6402
6425
|
});
|
|
6426
|
+
this.logger.debug(`[TOOLS CHECK] toolsConfig exists: ${!!config.toolsConfig}, customTools exists: ${!!config.customTools}`);
|
|
6427
|
+
if (config.toolsConfig) {
|
|
6428
|
+
this.logger.debug(`[TOOLS CHECK] toolsConfig length: ${config.toolsConfig.length}, content: ${JSON.stringify(config.toolsConfig)}`);
|
|
6429
|
+
}
|
|
6430
|
+
if (config.toolsConfig || config.customTools) {
|
|
6431
|
+
this.logger.debug(`[TOOLS] Calling bindToolsToModel with toolsConfig: ${JSON.stringify(config.toolsConfig)}`);
|
|
6432
|
+
const boundModel = await this.bindToolsToModel(
|
|
6433
|
+
model,
|
|
6434
|
+
config.toolsConfig,
|
|
6435
|
+
config.customTools
|
|
6436
|
+
);
|
|
6437
|
+
this.logger.debug(`[TOOLS] bindToolsToModel returned successfully`);
|
|
6438
|
+
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
6439
|
+
return boundModel;
|
|
6440
|
+
}
|
|
6403
6441
|
this.modelInstanceCache.set(cacheKey, model);
|
|
6404
6442
|
return model;
|
|
6405
6443
|
}
|
|
6444
|
+
/**
|
|
6445
|
+
* Bind tools to model (merge toolsConfig and customTools)
|
|
6446
|
+
* For toolsConfig: fetch tool executors from MCP Runtime
|
|
6447
|
+
* For customTools: use as-is (already prepared DynamicStructuredTool)
|
|
6448
|
+
*
|
|
6449
|
+
* Returns:
|
|
6450
|
+
* - Runnable when tools are bound (model.bindTools returns Runnable)
|
|
6451
|
+
* - BaseChatModel when no tools
|
|
6452
|
+
*/
|
|
6453
|
+
async bindToolsToModel(model, toolsConfig, customTools) {
|
|
6454
|
+
const allTools = [];
|
|
6455
|
+
if (toolsConfig && toolsConfig.length > 0) {
|
|
6456
|
+
try {
|
|
6457
|
+
const enabledToolsConfig = toolsConfig.filter((tc) => tc.enabled !== false);
|
|
6458
|
+
if (enabledToolsConfig.length > 0) {
|
|
6459
|
+
this.logger.debug(
|
|
6460
|
+
`Fetching ${enabledToolsConfig.length} tools with dynamic schemas from MCP Runtime: ${enabledToolsConfig.map((tc) => tc.toolName).join(", ")}`
|
|
6461
|
+
);
|
|
6462
|
+
const mcpToolFilter = new McpToolFilter();
|
|
6463
|
+
const mcpTools = await mcpToolFilter.getFilteredTools(
|
|
6464
|
+
enabledToolsConfig
|
|
6465
|
+
);
|
|
6466
|
+
this.logger.debug(
|
|
6467
|
+
`Successfully fetched ${mcpTools.length} tools with dynamic schemas from MCP Runtime`
|
|
6468
|
+
);
|
|
6469
|
+
allTools.push(...mcpTools);
|
|
6470
|
+
}
|
|
6471
|
+
} catch (error) {
|
|
6472
|
+
this.logger.error(
|
|
6473
|
+
`Failed to fetch tools from MCP Runtime: ${error instanceof Error ? error.message : String(error)}`
|
|
6474
|
+
);
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
if (customTools && customTools.length > 0) {
|
|
6478
|
+
allTools.push(...customTools);
|
|
6479
|
+
this.logger.debug(`Added ${customTools.length} custom tools to model`);
|
|
6480
|
+
}
|
|
6481
|
+
if (allTools.length > 0) {
|
|
6482
|
+
this.logger.debug(`Binding ${allTools.length} tools to model`);
|
|
6483
|
+
const modelWithTools = model.bindTools(allTools);
|
|
6484
|
+
return modelWithTools;
|
|
6485
|
+
}
|
|
6486
|
+
return model;
|
|
6487
|
+
}
|
|
6406
6488
|
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
|
-
);
|
|
6489
|
+
const cacheKey = this.generateModelCacheKey(config);
|
|
6414
6490
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6415
6491
|
if (cachedModel) {
|
|
6416
6492
|
this.logger.debug(`Using cached rerank model instance: ${cacheKey}`);
|
|
@@ -6438,14 +6514,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6438
6514
|
return model;
|
|
6439
6515
|
}
|
|
6440
6516
|
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
|
-
);
|
|
6517
|
+
const cacheKey = this.generateModelCacheKey(config);
|
|
6449
6518
|
const cachedModel = this.modelInstanceCache.get(cacheKey);
|
|
6450
6519
|
if (cachedModel) {
|
|
6451
6520
|
this.logger.debug(`Using cached embedding model instance: ${cacheKey}`);
|
|
@@ -6593,7 +6662,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6593
6662
|
}
|
|
6594
6663
|
// Simple API request for microservices (copy from original LLMInitializer)
|
|
6595
6664
|
async fetchFromApi(modelId) {
|
|
6596
|
-
const apiUrl = process.env.API_URL
|
|
6665
|
+
const apiUrl = process.env.API_URL;
|
|
6597
6666
|
const token = process.env.INTERNAL_API_TOKEN;
|
|
6598
6667
|
if (!token) {
|
|
6599
6668
|
throw new Error("INTERNAL_API_TOKEN required for API mode");
|
|
@@ -6637,40 +6706,6 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6637
6706
|
return result;
|
|
6638
6707
|
}
|
|
6639
6708
|
};
|
|
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
6709
|
|
|
6675
6710
|
// src/retriever/enums.ts
|
|
6676
6711
|
var RetrieverSearchType = /* @__PURE__ */ ((RetrieverSearchType2) => {
|
|
@@ -6981,6 +7016,6 @@ StaticDiscovery = __decorateClass([
|
|
|
6981
7016
|
Injectable()
|
|
6982
7017
|
], StaticDiscovery);
|
|
6983
7018
|
|
|
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,
|
|
7019
|
+
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
7020
|
//# sourceMappingURL=index.js.map
|
|
6986
7021
|
//# sourceMappingURL=index.js.map
|