@smythos/sre 1.5.26 → 1.5.32

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.
@@ -88,6 +88,139 @@ export declare class GenAILLM extends Component {
88
88
  description: string;
89
89
  label: string;
90
90
  };
91
+ useWebSearch: {
92
+ type: string;
93
+ description: string;
94
+ label: string;
95
+ };
96
+ webSearchContextSize: {
97
+ type: string;
98
+ valid: string[];
99
+ label: string;
100
+ };
101
+ webSearchCity: {
102
+ type: string;
103
+ max: number;
104
+ label: string;
105
+ allowEmpty: boolean;
106
+ };
107
+ webSearchCountry: {
108
+ type: string;
109
+ max: number;
110
+ label: string;
111
+ allowEmpty: boolean;
112
+ };
113
+ webSearchRegion: {
114
+ type: string;
115
+ max: number;
116
+ label: string;
117
+ allowEmpty: boolean;
118
+ };
119
+ webSearchTimezone: {
120
+ type: string;
121
+ max: number;
122
+ label: string;
123
+ allowEmpty: boolean;
124
+ };
125
+ useSearch: {
126
+ type: string;
127
+ description: string;
128
+ label: string;
129
+ allowEmpty: boolean;
130
+ };
131
+ searchMode: {
132
+ type: string;
133
+ valid: string[];
134
+ label: string;
135
+ allowEmpty: boolean;
136
+ };
137
+ returnCitations: {
138
+ type: string;
139
+ description: string;
140
+ label: string;
141
+ allowEmpty: boolean;
142
+ };
143
+ maxSearchResults: {
144
+ type: string;
145
+ min: number;
146
+ max: number;
147
+ label: string;
148
+ allowEmpty: boolean;
149
+ };
150
+ searchDataSources: {
151
+ type: string;
152
+ max: number;
153
+ label: string;
154
+ allowEmpty: boolean;
155
+ };
156
+ searchCountry: {
157
+ type: string;
158
+ max: number;
159
+ label: string;
160
+ allowEmpty: boolean;
161
+ };
162
+ excludedWebsites: {
163
+ type: string;
164
+ max: number;
165
+ label: string;
166
+ allowEmpty: boolean;
167
+ };
168
+ allowedWebsites: {
169
+ type: string;
170
+ max: number;
171
+ label: string;
172
+ allowEmpty: boolean;
173
+ };
174
+ includedXHandles: {
175
+ type: string;
176
+ max: number;
177
+ label: string;
178
+ allowEmpty: boolean;
179
+ };
180
+ excludedXHandles: {
181
+ type: string;
182
+ max: number;
183
+ label: string;
184
+ allowEmpty: boolean;
185
+ };
186
+ postFavoriteCount: {
187
+ type: string;
188
+ min: number;
189
+ max: number;
190
+ label: string;
191
+ allowEmpty: boolean;
192
+ };
193
+ postViewCount: {
194
+ type: string;
195
+ min: number;
196
+ max: number;
197
+ label: string;
198
+ allowEmpty: boolean;
199
+ };
200
+ link: {
201
+ type: string;
202
+ max: number;
203
+ label: string;
204
+ allowEmpty: boolean;
205
+ };
206
+ safeSearch: {
207
+ type: string;
208
+ description: string;
209
+ label: string;
210
+ allowEmpty: boolean;
211
+ };
212
+ fromDate: {
213
+ type: string;
214
+ max: number;
215
+ label: string;
216
+ allowEmpty: boolean;
217
+ };
218
+ toDate: {
219
+ type: string;
220
+ max: number;
221
+ label: string;
222
+ allowEmpty: boolean;
223
+ };
91
224
  };
92
225
  inputs: {
93
226
  Input: {
@@ -4,12 +4,11 @@ import { IAgent } from '@sre/types/Agent.types';
4
4
  export declare const cachePrefix = "serverless_code";
5
5
  export declare const cacheTTL: number;
6
6
  export declare function getLambdaFunctionName(agentId: string, componentId: string): string;
7
- export declare function generateCodeHash(code_body: string, code_imports: string, codeInputs: string[]): string;
7
+ export declare function generateCodeHash(code_body: string, codeInputs: string[]): string;
8
8
  export declare function getSanitizeCodeHash(code: string): string;
9
9
  export declare function getDeployedCodeHash(agentId: string, componentId: string): Promise<any>;
10
10
  export declare function setDeployedCodeHash(agentId: string, componentId: string, codeHash: string): Promise<void>;
11
- export declare function extractNpmImports(code: string): unknown[];
12
- export declare function generateLambdaCode(code_imports: string, code_body: string, input_variables: string[]): string;
11
+ export declare function generateLambdaCode(code: string, parameters: string[]): string;
13
12
  export declare function zipCode(directory: string): Promise<unknown>;
14
13
  export declare function createOrUpdateLambdaFunction(functionName: any, zipFilePath: any, awsConfigs: any): Promise<void>;
15
14
  export declare function waitForRoleDeploymentStatus(roleName: any, client: any): Promise<boolean>;
@@ -38,3 +37,10 @@ export declare function reportUsage({ cost, agentId, teamId }: {
38
37
  agentId: string;
39
38
  teamId: string;
40
39
  }): void;
40
+ export declare function validateAsyncMainFunction(code: string): {
41
+ isValid: boolean;
42
+ error?: string;
43
+ parameters?: string[];
44
+ dependencies?: string[];
45
+ };
46
+ export declare function generateCodeFromLegacyComponent(code_body: string, code_imports: string, codeInputs: string[]): string;
@@ -165,6 +165,7 @@ export * from './subsystems/LLMManager/LLM.service/connectors/Groq.class';
165
165
  export * from './subsystems/LLMManager/LLM.service/connectors/OpenAI.class';
166
166
  export * from './subsystems/LLMManager/LLM.service/connectors/Perplexity.class';
167
167
  export * from './subsystems/LLMManager/LLM.service/connectors/VertexAI.class';
168
+ export * from './subsystems/LLMManager/LLM.service/connectors/xAI';
168
169
  export * from './subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class';
169
170
  export * from './subsystems/MemoryManager/Cache.service/connectors/LocalStorageCache.class';
170
171
  export * from './subsystems/MemoryManager/Cache.service/connectors/RAMCache.class';
@@ -0,0 +1,121 @@
1
+ import EventEmitter from 'events';
2
+ import { TLLMParams, ToolData, TLLMMessageBlock, TLLMToolResultMessageBlock, TLLMMessageRole, APIKeySource, ILLMRequestFuncParams, TLLMChatResponse } from '@sre/types/LLM.types';
3
+ import { LLMConnector } from '../LLMConnector';
4
+ type ChatCompletionParams = {
5
+ model: string;
6
+ messages: any[];
7
+ max_tokens?: number;
8
+ temperature?: number;
9
+ top_p?: number;
10
+ frequency_penalty?: number;
11
+ presence_penalty?: number;
12
+ stop?: string | string[];
13
+ response_format?: {
14
+ type: string;
15
+ };
16
+ stream?: boolean;
17
+ stream_options?: {
18
+ include_usage: boolean;
19
+ };
20
+ tools?: any[];
21
+ tool_choice?: any;
22
+ search_parameters?: {
23
+ mode?: 'auto' | 'on' | 'off';
24
+ return_citations?: boolean;
25
+ max_search_results?: number;
26
+ sources?: Array<{
27
+ type: 'web' | 'x' | 'news' | 'rss';
28
+ country?: string;
29
+ excluded_websites?: string[];
30
+ allowed_websites?: string[];
31
+ safe_search?: boolean;
32
+ included_x_handles?: string[];
33
+ excluded_x_handles?: string[];
34
+ post_favorite_count?: number;
35
+ post_view_count?: number;
36
+ links?: string[];
37
+ }>;
38
+ from_date?: string;
39
+ to_date?: string;
40
+ };
41
+ };
42
+ type TUsage = {
43
+ prompt_tokens: number;
44
+ completion_tokens: number;
45
+ total_tokens: number;
46
+ prompt_tokens_details?: {
47
+ text_tokens?: number;
48
+ audio_tokens?: number;
49
+ image_tokens?: number;
50
+ cached_tokens?: number;
51
+ };
52
+ completion_tokens_details?: {
53
+ reasoning_tokens?: number;
54
+ audio_tokens?: number;
55
+ accepted_prediction_tokens?: number;
56
+ rejected_prediction_tokens?: number;
57
+ };
58
+ reasoning_tokens?: number;
59
+ num_sources_used?: number;
60
+ };
61
+ export declare class xAIConnector extends LLMConnector {
62
+ name: string;
63
+ private getClient;
64
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
65
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
66
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
67
+ protected reqBodyAdapter(params: TLLMParams): Promise<ChatCompletionParams>;
68
+ protected reportUsage(usage: TUsage, metadata: {
69
+ modelEntryName: string;
70
+ keySource: APIKeySource;
71
+ agentId: string;
72
+ teamId: string;
73
+ }): {
74
+ sourceId: string;
75
+ input_tokens: number;
76
+ output_tokens: number;
77
+ input_tokens_cache_write: number;
78
+ input_tokens_cache_read: number;
79
+ reasoning_tokens: number;
80
+ keySource: APIKeySource;
81
+ agentId: string;
82
+ teamId: string;
83
+ };
84
+ formatToolsConfig({ type, toolDefinitions, toolChoice }: {
85
+ type?: string;
86
+ toolDefinitions: any;
87
+ toolChoice?: string;
88
+ }): {
89
+ tools: any[];
90
+ tool_choice: string;
91
+ } | {
92
+ tools?: undefined;
93
+ tool_choice?: undefined;
94
+ };
95
+ transformToolMessageBlocks({ messageBlock, toolsData, }: {
96
+ messageBlock: TLLMMessageBlock;
97
+ toolsData: ToolData[];
98
+ }): TLLMToolResultMessageBlock[];
99
+ getConsistentMessages(messages: any): {
100
+ role: TLLMMessageRole;
101
+ content?: string | {
102
+ text: string;
103
+ }[] | Array<import("@anthropic-ai/sdk/resources").TextBlockParam | import("@anthropic-ai/sdk/resources").ImageBlockParam | import("@anthropic-ai/sdk/resources").ToolUseBlockParam | import("@anthropic-ai/sdk/resources").ToolResultBlockParam>;
104
+ parts?: {
105
+ text?: string;
106
+ functionCall?: {
107
+ name: string;
108
+ args: string;
109
+ };
110
+ functionResponse?: {
111
+ name: string;
112
+ response: {
113
+ name: string;
114
+ content: string;
115
+ };
116
+ };
117
+ }[];
118
+ tool_calls?: ToolData[];
119
+ }[];
120
+ }
121
+ export {};
@@ -2594,6 +2594,7 @@ export declare const models: {
2594
2594
  tokens: number;
2595
2595
  completionTokens: number;
2596
2596
  enabled: boolean;
2597
+ hidden: boolean;
2597
2598
  keyOptions: {
2598
2599
  tokens: number;
2599
2600
  completionTokens: number;
@@ -74,6 +74,22 @@ export type TLLMParams = {
74
74
  webSearchCountry?: string;
75
75
  webSearchRegion?: string;
76
76
  webSearchTimezone?: string;
77
+ useSearch?: boolean;
78
+ searchMode?: 'auto' | 'on' | 'off';
79
+ returnCitations?: boolean;
80
+ maxSearchResults?: number;
81
+ searchDataSources?: string[];
82
+ searchCountry?: string;
83
+ excludedWebsites?: string[];
84
+ allowedWebsites?: string[];
85
+ includedXHandles?: string[];
86
+ excludedXHandles?: string[];
87
+ postFavoriteCount?: number;
88
+ postViewCount?: number;
89
+ rssLinks?: string;
90
+ safeSearch?: boolean;
91
+ fromDate?: string;
92
+ toDate?: string;
77
93
  useReasoning?: boolean;
78
94
  isUserKey?: boolean;
79
95
  capabilities?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smythos/sre",
3
- "version": "1.5.26",
3
+ "version": "1.5.32",
4
4
  "description": "Smyth Runtime Environment",
5
5
  "author": "Alaa-eddine KADDOURI",
6
6
  "license": "MIT",
@@ -97,6 +97,145 @@ export class GenAILLM extends Component {
97
97
  description: 'The maximum number of messages to use from this component context window (if useContextWindow is true)',
98
98
  label: 'Maximum Context Window Length',
99
99
  },
100
+
101
+ // #region Web Search
102
+ useWebSearch: {
103
+ type: 'boolean',
104
+ description: 'If true, the component will use web search for additional context',
105
+ label: 'Use Web Search',
106
+ },
107
+ webSearchContextSize: {
108
+ type: 'string',
109
+ valid: ['high', 'medium', 'low'],
110
+ label: 'Web Search Context Size',
111
+ },
112
+ webSearchCity: {
113
+ type: 'string',
114
+ max: 100,
115
+ label: 'Web Search City',
116
+ allowEmpty: true,
117
+ },
118
+ webSearchCountry: {
119
+ type: 'string',
120
+ max: 2,
121
+ label: 'Web Search Country',
122
+ allowEmpty: true,
123
+ },
124
+ webSearchRegion: {
125
+ type: 'string',
126
+ max: 100,
127
+ label: 'Web Search Region',
128
+ allowEmpty: true,
129
+ },
130
+ webSearchTimezone: {
131
+ type: 'string',
132
+ max: 100,
133
+ label: 'Web Search Timezone',
134
+ allowEmpty: true,
135
+ },
136
+ // #endregion
137
+
138
+ // #region xAI Search
139
+ useSearch: {
140
+ type: 'boolean',
141
+ description: 'If true, the component will use xAI live search capabilities',
142
+ label: 'Use Search',
143
+ allowEmpty: true,
144
+ },
145
+ searchMode: {
146
+ type: 'string',
147
+ valid: ['auto', 'on', 'off'],
148
+ label: 'Search Mode',
149
+ allowEmpty: true,
150
+ },
151
+ returnCitations: {
152
+ type: 'boolean',
153
+ description: 'If true, include citations and sources in the response',
154
+ label: 'Return Citations',
155
+ allowEmpty: true,
156
+ },
157
+ maxSearchResults: {
158
+ type: 'number',
159
+ min: 1,
160
+ max: 50,
161
+ label: 'Max Search Results',
162
+ allowEmpty: true,
163
+ },
164
+ searchDataSources: {
165
+ type: 'array',
166
+ max: 4,
167
+ label: 'Search Data Sources',
168
+ allowEmpty: true,
169
+ },
170
+ searchCountry: {
171
+ type: 'string',
172
+ max: 2,
173
+ label: 'Search Country',
174
+ allowEmpty: true,
175
+ },
176
+ excludedWebsites: {
177
+ type: 'string',
178
+ max: 10000,
179
+ label: 'Excluded Websites',
180
+ allowEmpty: true,
181
+ },
182
+ allowedWebsites: {
183
+ type: 'string',
184
+ max: 10000,
185
+ label: 'Allowed Websites',
186
+ allowEmpty: true,
187
+ },
188
+ includedXHandles: {
189
+ type: 'string',
190
+ max: 1000,
191
+ label: 'Included X Handles',
192
+ allowEmpty: true,
193
+ },
194
+ excludedXHandles: {
195
+ type: 'string',
196
+ max: 1000,
197
+ label: 'Excluded X Handles',
198
+ allowEmpty: true,
199
+ },
200
+ postFavoriteCount: {
201
+ type: 'number',
202
+ min: 0,
203
+ max: 1000000000,
204
+ label: 'Post Favorite Count',
205
+ allowEmpty: true,
206
+ },
207
+ postViewCount: {
208
+ type: 'number',
209
+ min: 0,
210
+ max: 1000000000,
211
+ label: 'Post View Count',
212
+ allowEmpty: true,
213
+ },
214
+ link: {
215
+ type: 'string',
216
+ max: 5000,
217
+ label: 'RSS Link',
218
+ allowEmpty: true,
219
+ },
220
+ safeSearch: {
221
+ type: 'boolean',
222
+ description: 'If true, enable safe search filtering',
223
+ label: 'Safe Search',
224
+ allowEmpty: true,
225
+ },
226
+ fromDate: {
227
+ type: 'string',
228
+ max: 10,
229
+ label: 'From Date',
230
+ allowEmpty: true,
231
+ },
232
+ toDate: {
233
+ type: 'string',
234
+ max: 10,
235
+ label: 'To Date',
236
+ allowEmpty: true,
237
+ },
238
+ // #endregion
100
239
  },
101
240
  inputs: {
102
241
  Input: {
@@ -131,13 +270,40 @@ export class GenAILLM extends Component {
131
270
  useContextWindow: Joi.boolean().optional().label('Use Context Window'),
132
271
  maxContextWindowLength: Joi.number().optional().min(0).label('Maximum Context Window Length'),
133
272
 
134
- // #region Search
135
- useWebSearch: Joi.boolean().optional().label('Use Search'),
136
- webSearchContextSize: Joi.string().valid('high', 'medium', 'low').optional().label('Search Content Size'),
137
- webSearchCity: Joi.string().max(100).optional().allow('').label('Search City'),
138
- webSearchCountry: Joi.string().max(100).optional().allow('').label('Search Country'),
139
- webSearchRegion: Joi.string().max(100).optional().allow('').label('Search Region'),
140
- webSearchTimezone: Joi.string().max(100).optional().allow('').label('Search Timezone'),
273
+ // #region Web Search
274
+ useWebSearch: Joi.boolean().optional().label('Use Web Search'),
275
+ webSearchContextSize: Joi.string().valid('high', 'medium', 'low').optional().label('Web Search Context Size'),
276
+ webSearchCity: Joi.string().max(100).optional().allow('').label('Web Search City'),
277
+ webSearchCountry: Joi.string().max(2).optional().allow('').label('Web Search Country'),
278
+ webSearchRegion: Joi.string().max(100).optional().allow('').label('Web Search Region'),
279
+ webSearchTimezone: Joi.string().max(100).optional().allow('').label('Web Search Timezone'),
280
+ // #endregion
281
+
282
+ // #region xAI Search
283
+ useSearch: Joi.boolean().optional().allow('').label('Use Search'),
284
+ searchMode: Joi.string().valid('auto', 'on', 'off').optional().allow('').label('Search Mode'),
285
+ returnCitations: Joi.boolean().optional().allow('').label('Return Citations'),
286
+ maxSearchResults: Joi.number().min(1).max(100).optional().allow('').label('Max Search Results'),
287
+ searchDataSources: Joi.array().items(Joi.string().valid('web', 'x', 'news', 'rss')).max(4).optional().allow('').label('Search Data Sources'),
288
+ searchCountry: Joi.string().length(2).optional().allow('').label('Search Country'),
289
+ excludedWebsites: Joi.string().max(10000).optional().allow('').label('Excluded Websites'),
290
+ allowedWebsites: Joi.string().max(10000).optional().allow('').label('Allowed Websites'),
291
+ includedXHandles: Joi.string().max(1000).optional().allow('').label('Included X Handles'),
292
+ excludedXHandles: Joi.string().max(1000).optional().allow('').label('Excluded X Handles'),
293
+ postFavoriteCount: Joi.number().min(0).max(1000000000).optional().allow('').label('Post Favorite Count'),
294
+ postViewCount: Joi.number().min(0).max(1000000000).optional().allow('').label('Post View Count'),
295
+ rssLinks: Joi.string().max(10000).optional().allow('').label('RSS Link'),
296
+ safeSearch: Joi.boolean().optional().allow('').label('Safe Search'),
297
+ fromDate: Joi.string()
298
+ .pattern(/^\d{4}-\d{2}-\d{2}$/)
299
+ .optional()
300
+ .allow('')
301
+ .label('From Date'),
302
+ toDate: Joi.string()
303
+ .pattern(/^\d{4}-\d{2}-\d{2}$/)
304
+ .optional()
305
+ .allow('')
306
+ .label('To Date'),
141
307
  // #endregion
142
308
 
143
309
  useReasoning: Joi.boolean().optional().label('Use Reasoning'),
@@ -3,13 +3,14 @@ import { Component } from './Component.class';
3
3
  import Joi from 'joi';
4
4
  import { ConnectorService } from '@sre/Core/ConnectorsService';
5
5
  import { AWSCredentials, AWSRegionConfig } from '@sre/types/AWS.types';
6
- import { calculateExecutionCost, getLambdaCredentials, reportUsage } from '@sre/helpers/AWSLambdaCode.helper';
6
+ import { calculateExecutionCost, generateCodeFromLegacyComponent, getLambdaCredentials, reportUsage } from '@sre/helpers/AWSLambdaCode.helper';
7
7
 
8
8
  export class ServerlessCode extends Component {
9
9
 
10
10
  protected configSchema = Joi.object({
11
11
  code_imports: Joi.string().max(1000).allow('').label('Imports'),
12
12
  code_body: Joi.string().max(500000).allow('').label('Code'),
13
+ code: Joi.string().max(500000).allow('').label('Code').optional(),
13
14
  deploy_btn: Joi.string().max(500000).allow('').label('Deploy').optional(),
14
15
  accessKeyId: Joi.string().max(100).allow('').label('AWS Access Key ID').optional(),
15
16
  secretAccessKey: Joi.string().max(200).allow('').label('AWS Secret Access Key').optional(),
@@ -70,11 +71,14 @@ export class ServerlessCode extends Component {
70
71
  secretAccessKey: codeCredentials.secretAccessKey,
71
72
  })
72
73
  }
74
+ let code = config?.data?.code;
75
+ if (!code) {
76
+ code = generateCodeFromLegacyComponent(config.data.code_body, config.data.code_imports, Object.keys(codeInputs))
77
+ }
73
78
  // Deploy lambda function if it doesn't exist or the code hash is different
74
79
  await codeConnector.agent(agent.id)
75
80
  .deploy(config.id, {
76
- code: config?.data?.code_body,
77
- dependencies: config?.data?.code_imports,
81
+ code,
78
82
  inputs: codeInputs,
79
83
  }, {
80
84
  runtime: 'nodejs',