@smythos/sre 1.5.37 → 1.5.40
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.js +65 -45
- package/dist/index.js.map +1 -1
- package/dist/types/Components/ECMASandbox.class.d.ts +14 -0
- package/dist/types/Components/MemoryDeleteKeyVal.class.d.ts +19 -0
- package/dist/types/Components/MemoryReadKeyVal.class.d.ts +17 -0
- package/dist/types/Components/MemoryWriteKeyVal.class.d.ts +17 -0
- package/dist/types/Components/MemoryWriteObject.class.d.ts +19 -0
- package/dist/types/Components/index.d.ts +10 -0
- package/dist/types/Core/ConnectorsService.d.ts +2 -1
- package/dist/types/helpers/ECMASandbox.helper.d.ts +3 -0
- package/dist/types/helpers/Log.helper.d.ts +1 -1
- package/dist/types/index.d.ts +8 -1
- package/dist/types/subsystems/ComputeManager/Code.service/connectors/ECMASandbox.class.d.ts +19 -0
- package/dist/types/subsystems/LLMManager/LLM.helper.d.ts +21 -10
- package/dist/types/subsystems/LLMManager/LLM.service/LLMConnector.d.ts +5 -5
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.d.ts +2 -3
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.d.ts +2 -3
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Echo.class.d.ts +2 -3
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.d.ts +2 -3
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Groq.class.d.ts +2 -3
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.d.ts +3 -4
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.d.ts +19 -14
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.d.ts +95 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.d.ts +87 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/OpenAIApiInterface.d.ts +85 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/OpenAIApiInterfaceFactory.d.ts +49 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.d.ts +146 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.d.ts +10 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/index.d.ts +4 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/types.d.ts +38 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/xAI.class.d.ts +1 -2
- package/dist/types/subsystems/Security/Vault.service/connectors/JSONFileVault.class.d.ts +5 -0
- package/dist/types/types/LLM.types.d.ts +82 -37
- package/dist/types/utils/data.utils.d.ts +2 -1
- package/package.json +4 -3
- package/src/Components/APICall/APICall.class.ts +2 -1
- package/src/Components/Component.class.ts +1 -1
- package/src/Components/ECMASandbox.class.ts +71 -0
- package/src/Components/GenAILLM.class.ts +1 -1
- package/src/Components/MemoryDeleteKeyVal.class.ts +70 -0
- package/src/Components/MemoryReadKeyVal.class.ts +66 -0
- package/src/Components/MemoryWriteKeyVal.class.ts +62 -0
- package/src/Components/MemoryWriteObject.class.ts +97 -0
- package/src/Components/index.ts +10 -0
- package/src/Core/ConnectorsService.ts +3 -3
- package/src/helpers/Conversation.helper.ts +11 -3
- package/src/helpers/ECMASandbox.helper.ts +54 -0
- package/src/helpers/Log.helper.ts +57 -17
- package/src/index.ts +192 -185
- package/src/index.ts.bak +192 -185
- package/src/subsystems/AgentManager/Agent.class.ts +11 -6
- package/src/subsystems/AgentManager/AgentRuntime.class.ts +13 -13
- package/src/subsystems/ComputeManager/Code.service/connectors/ECMASandbox.class.ts +131 -0
- package/src/subsystems/ComputeManager/Code.service/index.ts +2 -0
- package/src/subsystems/LLMManager/LLM.helper.ts +57 -27
- package/src/subsystems/LLMManager/LLM.inference.ts +4 -0
- package/src/subsystems/LLMManager/LLM.service/LLMConnector.ts +125 -28
- package/src/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.ts +18 -17
- package/src/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.ts +2 -7
- package/src/subsystems/LLMManager/LLM.service/connectors/Echo.class.ts +2 -6
- package/src/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.ts +26 -17
- package/src/subsystems/LLMManager/LLM.service/connectors/Groq.class.ts +2 -7
- package/src/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.ts +2 -7
- package/src/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.ts +314 -84
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.ts +455 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts +528 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/OpenAIApiInterface.ts +100 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/OpenAIApiInterfaceFactory.ts +81 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts +853 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts +37 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/index.ts +4 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/types.ts +37 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/xAI.class.ts +0 -5
- package/src/subsystems/LLMManager/LLM.service/index.ts +1 -1
- package/src/subsystems/LLMManager/ModelsProvider.service/ModelsProviderConnector.ts +2 -2
- package/src/subsystems/LLMManager/models.ts +1 -1
- package/src/subsystems/MemoryManager/Cache.service/connectors/RedisCache.class.ts +18 -0
- package/src/subsystems/MemoryManager/RuntimeContext.ts +33 -16
- package/src/subsystems/Security/Vault.service/connectors/JSONFileVault.class.ts +68 -42
- package/src/types/LLM.types.ts +91 -43
- package/src/utils/data.utils.ts +3 -2
- package/src/subsystems/LLMManager/LLM.service/connectors/OpenAI.class.ts +0 -848
|
@@ -11,7 +11,6 @@ import EventEmitter from 'events';
|
|
|
11
11
|
|
|
12
12
|
import { BUILT_IN_MODEL_PREFIX } from '@sre/constants';
|
|
13
13
|
import {
|
|
14
|
-
TLLMParams,
|
|
15
14
|
ToolData,
|
|
16
15
|
TLLMMessageBlock,
|
|
17
16
|
TLLMToolResultMessageBlock,
|
|
@@ -21,9 +20,9 @@ import {
|
|
|
21
20
|
BedrockCredentials,
|
|
22
21
|
ILLMRequestFuncParams,
|
|
23
22
|
TLLMChatResponse,
|
|
24
|
-
TLLMConnectorParams,
|
|
25
23
|
ILLMRequestContext,
|
|
26
24
|
TCustomLLMModel,
|
|
25
|
+
TLLMPreparedParams,
|
|
27
26
|
} from '@sre/types/LLM.types';
|
|
28
27
|
import { LLMHelper } from '@sre/LLMManager/LLM.helper';
|
|
29
28
|
import { isJSONString } from '@sre/utils/general.utils';
|
|
@@ -195,11 +194,7 @@ export class BedrockConnector extends LLMConnector {
|
|
|
195
194
|
}
|
|
196
195
|
}
|
|
197
196
|
|
|
198
|
-
protected async
|
|
199
|
-
throw new Error('Web search is not supported for Bedrock');
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
protected async reqBodyAdapter(params: TLLMParams): Promise<ConverseCommandInput> {
|
|
197
|
+
protected async reqBodyAdapter(params: TLLMPreparedParams): Promise<ConverseCommandInput> {
|
|
203
198
|
const customModelInfo = params.modelInfo;
|
|
204
199
|
|
|
205
200
|
let systemPrompt;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSONContent } from '@sre/helpers/JsonContent.helper';
|
|
2
2
|
import { LLMConnector } from '../LLMConnector';
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
|
-
import { APIKeySource, ILLMRequestFuncParams, TLLMChatResponse,
|
|
4
|
+
import { APIKeySource, ILLMRequestFuncParams, TLLMChatResponse, TLLMPreparedParams } from '@sre/types/LLM.types';
|
|
5
5
|
|
|
6
6
|
export class EchoConnector extends LLMConnector {
|
|
7
7
|
public name = 'LLM:Echo';
|
|
@@ -52,11 +52,7 @@ export class EchoConnector extends LLMConnector {
|
|
|
52
52
|
return emitter;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
protected async
|
|
56
|
-
throw new Error('Web search is not supported for Echo');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
protected async reqBodyAdapter(params: TLLMParams): Promise<any> {
|
|
55
|
+
protected async reqBodyAdapter(params: TLLMPreparedParams): Promise<any> {
|
|
60
56
|
return params;
|
|
61
57
|
}
|
|
62
58
|
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
|
|
6
|
-
import { GoogleGenerativeAI, ModelParams, GenerationConfig, GenerateContentRequest, UsageMetadata } from '@google/generative-ai';
|
|
6
|
+
import { GoogleGenerativeAI, ModelParams, GenerationConfig, GenerateContentRequest, UsageMetadata, FunctionCallingMode } from '@google/generative-ai';
|
|
7
7
|
import { GoogleAIFileManager, FileState } from '@google/generative-ai/server';
|
|
8
8
|
import { GoogleGenAI } from '@google/genai';
|
|
9
9
|
|
|
@@ -21,13 +21,12 @@ import {
|
|
|
21
21
|
TLLMToolResultMessageBlock,
|
|
22
22
|
APIKeySource,
|
|
23
23
|
TLLMEvent,
|
|
24
|
-
TLLMParams,
|
|
25
24
|
BasicCredentials,
|
|
26
25
|
ILLMRequestFuncParams,
|
|
27
26
|
TLLMChatResponse,
|
|
28
27
|
TGoogleAIRequestBody,
|
|
29
|
-
TLLMConnectorParams,
|
|
30
28
|
ILLMRequestContext,
|
|
29
|
+
TLLMPreparedParams,
|
|
31
30
|
} from '@sre/types/LLM.types';
|
|
32
31
|
import { LLMHelper } from '@sre/LLMManager/LLM.helper';
|
|
33
32
|
|
|
@@ -115,7 +114,7 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
115
114
|
|
|
116
115
|
return {
|
|
117
116
|
content,
|
|
118
|
-
finishReason,
|
|
117
|
+
finishReason: finishReason.toLowerCase(),
|
|
119
118
|
useTool,
|
|
120
119
|
toolsData,
|
|
121
120
|
message: { content, role: 'assistant' },
|
|
@@ -193,11 +192,6 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
193
192
|
throw error;
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
|
-
|
|
197
|
-
protected async webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<any> {
|
|
198
|
-
throw new Error('Web search is not supported for Google AI');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
195
|
// #region Image Generation, will be moved to a different subsystem/service
|
|
202
196
|
protected async imageGenRequest({ body, context }: ILLMRequestFuncParams): Promise<any> {
|
|
203
197
|
try {
|
|
@@ -242,7 +236,7 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
242
236
|
throw new Error('Image editing is not supported for Google AI. Imagen models only support image generation.');
|
|
243
237
|
}
|
|
244
238
|
|
|
245
|
-
protected async reqBodyAdapter(params:
|
|
239
|
+
protected async reqBodyAdapter(params: TLLMPreparedParams): Promise<TGoogleAIRequestBody> {
|
|
246
240
|
const model = params?.model;
|
|
247
241
|
|
|
248
242
|
// Check if this is an image generation request based on capabilities
|
|
@@ -403,7 +397,7 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
403
397
|
|
|
404
398
|
const transformedToolsData = toolsData.map(
|
|
405
399
|
(toolData): TLLMToolResultMessageBlock => ({
|
|
406
|
-
role: TLLMMessageRole.
|
|
400
|
+
role: TLLMMessageRole.User,
|
|
407
401
|
parts: [
|
|
408
402
|
{
|
|
409
403
|
functionResponse: {
|
|
@@ -459,7 +453,7 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
459
453
|
});
|
|
460
454
|
}
|
|
461
455
|
|
|
462
|
-
private async prepareMessages(params:
|
|
456
|
+
private async prepareMessages(params: TLLMPreparedParams): Promise<string | TLLMMessageBlock[] | GenerateContentRequest> {
|
|
463
457
|
let messages: string | TLLMMessageBlock[] | GenerateContentRequest = params?.messages || '';
|
|
464
458
|
|
|
465
459
|
const files: BinaryInput[] = params?.files || [];
|
|
@@ -475,7 +469,7 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
475
469
|
return messages;
|
|
476
470
|
}
|
|
477
471
|
|
|
478
|
-
private async prepareMessagesWithFiles(params:
|
|
472
|
+
private async prepareMessagesWithFiles(params: TLLMPreparedParams): Promise<string> {
|
|
479
473
|
const model = params.model;
|
|
480
474
|
|
|
481
475
|
let messages: string | TLLMMessageBlock[] = params?.messages || '';
|
|
@@ -544,7 +538,7 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
544
538
|
return messages as string;
|
|
545
539
|
}
|
|
546
540
|
|
|
547
|
-
private async prepareMessagesWithTools(params:
|
|
541
|
+
private async prepareMessagesWithTools(params: TLLMPreparedParams): Promise<GenerateContentRequest> {
|
|
548
542
|
let formattedMessages: TLLMMessageBlock[];
|
|
549
543
|
let systemInstruction = '';
|
|
550
544
|
|
|
@@ -571,15 +565,30 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
571
565
|
|
|
572
566
|
if (params?.toolsConfig?.tools) toolsPrompt.tools = params?.toolsConfig?.tools as any;
|
|
573
567
|
if (params?.toolsConfig?.tool_choice) {
|
|
568
|
+
// Map tool choice to valid Google AI function calling modes
|
|
569
|
+
let mode: FunctionCallingMode = FunctionCallingMode.AUTO; // default
|
|
570
|
+
const toolChoice = params?.toolsConfig?.tool_choice;
|
|
571
|
+
|
|
572
|
+
if (toolChoice === 'auto') {
|
|
573
|
+
mode = FunctionCallingMode.AUTO;
|
|
574
|
+
} else if (toolChoice === 'required') {
|
|
575
|
+
mode = FunctionCallingMode.ANY;
|
|
576
|
+
} else if (toolChoice === 'none') {
|
|
577
|
+
mode = FunctionCallingMode.NONE;
|
|
578
|
+
} else if (typeof toolChoice === 'object' && toolChoice.type === 'function') {
|
|
579
|
+
// Handle OpenAI-style named tool choice - force any function call
|
|
580
|
+
mode = FunctionCallingMode.ANY;
|
|
581
|
+
}
|
|
582
|
+
|
|
574
583
|
toolsPrompt.toolConfig = {
|
|
575
|
-
functionCallingConfig: { mode
|
|
584
|
+
functionCallingConfig: { mode },
|
|
576
585
|
};
|
|
577
586
|
}
|
|
578
587
|
|
|
579
588
|
return toolsPrompt;
|
|
580
589
|
}
|
|
581
590
|
|
|
582
|
-
private async prepareMessagesWithTextQuery(params:
|
|
591
|
+
private async prepareMessagesWithTextQuery(params: TLLMPreparedParams): Promise<string> {
|
|
583
592
|
const model = params.model;
|
|
584
593
|
let systemInstruction = '';
|
|
585
594
|
let prompt = '';
|
|
@@ -615,7 +624,7 @@ export class GoogleAIConnector extends LLMConnector {
|
|
|
615
624
|
return prompt;
|
|
616
625
|
}
|
|
617
626
|
|
|
618
|
-
private async prepareBodyForImageGenRequest(params:
|
|
627
|
+
private async prepareBodyForImageGenRequest(params: TLLMPreparedParams): Promise<any> {
|
|
619
628
|
return {
|
|
620
629
|
prompt: params.prompt,
|
|
621
630
|
model: params.model,
|
|
@@ -11,9 +11,8 @@ import {
|
|
|
11
11
|
BasicCredentials,
|
|
12
12
|
ILLMRequestFuncParams,
|
|
13
13
|
TLLMChatResponse,
|
|
14
|
-
TLLMParams,
|
|
15
|
-
TLLMConnectorParams,
|
|
16
14
|
ILLMRequestContext,
|
|
15
|
+
TLLMPreparedParams,
|
|
17
16
|
TLLMToolResultMessageBlock,
|
|
18
17
|
} from '@sre/types/LLM.types';
|
|
19
18
|
import { LLMHelper } from '@sre/LLMManager/LLM.helper';
|
|
@@ -154,11 +153,7 @@ export class GroqConnector extends LLMConnector {
|
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
155
|
|
|
157
|
-
protected async
|
|
158
|
-
throw new Error('Web search is not supported for Groq');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
protected async reqBodyAdapter(params: TLLMParams): Promise<ChatCompletionCreateParams> {
|
|
156
|
+
protected async reqBodyAdapter(params: TLLMPreparedParams): Promise<ChatCompletionCreateParams> {
|
|
162
157
|
const messages = params?.messages || [];
|
|
163
158
|
|
|
164
159
|
const body: ChatCompletionCreateParams = {
|
|
@@ -4,7 +4,6 @@ import axios, { AxiosInstance } from 'axios';
|
|
|
4
4
|
import { JSON_RESPONSE_INSTRUCTION, BUILT_IN_MODEL_PREFIX } from '@sre/constants';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
TLLMParams,
|
|
8
7
|
ToolData,
|
|
9
8
|
TLLMMessageBlock,
|
|
10
9
|
TLLMToolResultMessageBlock,
|
|
@@ -13,8 +12,8 @@ import {
|
|
|
13
12
|
BasicCredentials,
|
|
14
13
|
ILLMRequestFuncParams,
|
|
15
14
|
TLLMChatResponse,
|
|
16
|
-
TLLMConnectorParams,
|
|
17
15
|
ILLMRequestContext,
|
|
16
|
+
TLLMPreparedParams,
|
|
18
17
|
} from '@sre/types/LLM.types';
|
|
19
18
|
import { LLMHelper } from '@sre/LLMManager/LLM.helper';
|
|
20
19
|
|
|
@@ -113,11 +112,7 @@ export class PerplexityConnector extends LLMConnector {
|
|
|
113
112
|
return emitter;
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
protected async
|
|
117
|
-
throw new Error('Web search is not supported for Perplexity');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
protected async reqBodyAdapter(params: TLLMParams): Promise<ChatCompletionParams> {
|
|
115
|
+
protected async reqBodyAdapter(params: TLLMPreparedParams): Promise<ChatCompletionParams> {
|
|
121
116
|
const messages = params?.messages || [];
|
|
122
117
|
|
|
123
118
|
//#region Handle JSON response format
|