@exulu/backend 1.25.4 → 1.26.0

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.d.ts CHANGED
@@ -27,7 +27,7 @@ declare const STATISTICS_TYPE_ENUM: {
27
27
  AGENT_RUN: string;
28
28
  };
29
29
 
30
- type ExuluFieldTypes = "text" | "longText" | "shortText" | "number" | "boolean" | "code" | "json" | "enum" | "markdown";
30
+ type ExuluFieldTypes = "text" | "longText" | "shortText" | "number" | "boolean" | "code" | "json" | "enum" | "markdown" | "file" | "date" | "uuid";
31
31
 
32
32
  interface Item {
33
33
  id?: string;
@@ -80,6 +80,7 @@ type ExuluConfig = {
80
80
  s3secret: string;
81
81
  s3Bucket: string;
82
82
  s3endpoint?: string;
83
+ s3prefix?: string;
83
84
  };
84
85
  };
85
86
  declare class ExuluApp {
@@ -144,6 +145,7 @@ type User = {
144
145
  id: string;
145
146
  name: string;
146
147
  agents: "read" | "write";
148
+ evals: "read" | "write";
147
149
  workflows: "read" | "write";
148
150
  variables: "read" | "write";
149
151
  users: "read" | "write";
@@ -179,13 +181,11 @@ type ExuluAgentConfig = {
179
181
  };
180
182
  };
181
183
  };
182
- type ExuluAgentEval = {
183
- runner: ExuluEvalRunnerInstance;
184
- };
185
184
  type imageTypes = '.png' | '.jpg' | '.jpeg' | '.gif' | '.webp';
186
185
  type fileTypes = '.pdf' | '.docx' | '.xlsx' | '.xls' | '.csv' | '.pptx' | '.ppt' | '.txt' | '.md' | '.json';
187
186
  type audioTypes = '.mp3' | '.wav' | '.m4a' | '.mp4' | '.mpeg';
188
187
  type videoTypes = '.mp4' | '.m4a' | '.mp3' | '.mpeg' | '.wav';
188
+ type allFileTypes = imageTypes | fileTypes | audioTypes | videoTypes;
189
189
  interface ExuluAgentParams {
190
190
  id: string;
191
191
  name: string;
@@ -200,9 +200,9 @@ interface ExuluAgentParams {
200
200
  audio: audioTypes[];
201
201
  video: videoTypes[];
202
202
  };
203
- evals?: ExuluAgentEval[];
204
203
  outputSchema?: z.ZodType;
205
204
  rateLimit?: RateLimiterRule;
205
+ evals?: ExuluEval[];
206
206
  }
207
207
  interface ExuluAgentToolConfig {
208
208
  id: string;
@@ -213,6 +213,50 @@ interface ExuluAgentToolConfig {
213
213
  value?: any;
214
214
  }[];
215
215
  }
216
+ type ExuluQueueConfig = {
217
+ queue: Queue;
218
+ ratelimit: number;
219
+ concurrency: number;
220
+ };
221
+ type ExuluEvalTokenMetadata = {
222
+ totalTokens?: number;
223
+ reasoningTokens?: number;
224
+ inputTokens?: number;
225
+ outputTokens?: number;
226
+ cachedInputTokens?: number;
227
+ };
228
+ type ExuluEvalMetadata = {
229
+ tokens?: ExuluEvalTokenMetadata;
230
+ duration?: number;
231
+ };
232
+ interface ExuluEvalParams {
233
+ id: string;
234
+ name: string;
235
+ description: string;
236
+ execute: (params: {
237
+ messages: UIMessage[];
238
+ metadata: ExuluEvalMetadata;
239
+ config?: Record<string, any>;
240
+ }) => Promise<number>;
241
+ config?: {
242
+ name: string;
243
+ description: string;
244
+ }[];
245
+ queue: ExuluQueueConfig;
246
+ }
247
+ declare class ExuluEval {
248
+ id: string;
249
+ name: string;
250
+ description: string;
251
+ private execute;
252
+ config?: {
253
+ name: string;
254
+ description: string;
255
+ }[];
256
+ queue: ExuluQueueConfig;
257
+ constructor({ id, name, description, execute, config, queue }: ExuluEvalParams);
258
+ run(messages: UIMessage[], metadata: ExuluEvalMetadata, config?: Record<string, any>): Promise<number>;
259
+ }
216
260
  declare class ExuluAgent {
217
261
  id: string;
218
262
  name: string;
@@ -223,7 +267,7 @@ declare class ExuluAgent {
223
267
  maxContextLength?: number;
224
268
  rateLimit?: RateLimiterRule;
225
269
  config?: ExuluAgentConfig | undefined;
226
- evals?: ExuluAgentEval[];
270
+ evals?: ExuluEval[];
227
271
  model?: {
228
272
  create: ({ apiKey }: {
229
273
  apiKey: string;
@@ -236,11 +280,11 @@ declare class ExuluAgent {
236
280
  audio: string[];
237
281
  video: string[];
238
282
  };
239
- constructor({ id, name, description, config, rateLimit, capabilities, type, evals, maxContextLength }: ExuluAgentParams);
283
+ constructor({ id, name, description, config, rateLimit, capabilities, type, maxContextLength, evals }: ExuluAgentParams);
240
284
  get providerName(): string;
241
285
  get modelName(): string;
242
286
  tool: (instance: string, agents: ExuluAgent[]) => Promise<ExuluTool | null>;
243
- generateSync: ({ prompt, user, session, message, currentTools, allExuluTools, statistics, toolConfigs, providerapikey, contexts, exuluConfig, filesContext, outputSchema, instructions }: {
287
+ generateSync: ({ prompt, user, session, message, currentTools, allExuluTools, statistics, toolConfigs, providerapikey, contexts, exuluConfig, outputSchema, instructions }: {
244
288
  prompt?: string;
245
289
  user?: User;
246
290
  session?: string;
@@ -252,11 +296,10 @@ declare class ExuluAgent {
252
296
  providerapikey: string;
253
297
  contexts?: ExuluContext[] | undefined;
254
298
  exuluConfig?: ExuluConfig;
255
- filesContext?: ExuluContext;
256
299
  instructions?: string;
257
300
  outputSchema?: z.ZodType;
258
301
  }) => Promise<string | any>;
259
- generateStream: ({ express, user, session, message, currentTools, allExuluTools, statistics, toolConfigs, providerapikey, contexts, exuluConfig, filesContext, instructions, }: {
302
+ generateStream: ({ express, user, session, message, currentTools, allExuluTools, statistics, toolConfigs, providerapikey, contexts, exuluConfig, instructions, }: {
260
303
  express: {
261
304
  res: Response;
262
305
  req: Request;
@@ -271,7 +314,6 @@ declare class ExuluAgent {
271
314
  providerapikey: string;
272
315
  contexts?: ExuluContext[] | undefined;
273
316
  exuluConfig?: ExuluConfig;
274
- filesContext?: ExuluContext;
275
317
  instructions?: string;
276
318
  }) => Promise<void>;
277
319
  }
@@ -283,7 +325,9 @@ type VectorOperationResponse = Promise<{
283
325
  type VectorGenerateOperation = (inputs: ChunkerResponse) => VectorGenerationResponse;
284
326
  type ChunkerOperation = (item: Item & {
285
327
  id: string;
286
- }, maxChunkSize: number) => Promise<ChunkerResponse>;
328
+ }, maxChunkSize: number, utils: {
329
+ storage: ExuluStorage;
330
+ }) => Promise<ChunkerResponse>;
287
331
  type ChunkerResponse = {
288
332
  item: Item & {
289
333
  id: string;
@@ -305,106 +349,27 @@ declare class ExuluEmbedder {
305
349
  id: string;
306
350
  name: string;
307
351
  slug: string;
308
- queue?: Queue;
352
+ queue?: Promise<ExuluQueueConfig>;
309
353
  private generateEmbeddings;
354
+ description: string;
310
355
  vectorDimensions: number;
311
356
  maxChunkSize: number;
312
- chunker: ChunkerOperation;
357
+ _chunker: ChunkerOperation;
313
358
  constructor({ id, name, description, generateEmbeddings, queue, vectorDimensions, maxChunkSize, chunker }: {
314
359
  id: string;
315
360
  name: string;
316
361
  description: string;
317
362
  generateEmbeddings: VectorGenerateOperation;
318
363
  chunker: ChunkerOperation;
319
- queue?: Queue;
364
+ queue?: Promise<ExuluQueueConfig>;
320
365
  vectorDimensions: number;
321
366
  maxChunkSize: number;
322
367
  });
323
- generateFromQuery(query: string, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
324
- generateFromDocument(input: Item, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
325
- }
326
- interface WorkflowVariable {
327
- name: string;
328
- description?: string;
329
- type: 'string';
330
- required: boolean;
331
- defaultValue?: string;
332
- }
333
- interface WorkflowStep {
334
- id: string;
335
- type: 'user' | 'assistant' | 'tool';
336
- content?: string;
337
- contentExample?: string;
338
- toolName?: string;
339
- variablesUsed?: string[];
340
- }
341
- interface ExuluWorkflow {
342
- id: string;
343
- name: string;
344
- description?: string;
345
- rights_mode?: ExuluRightsMode;
346
- RBAC?: ExuluRBAC;
347
- variables?: WorkflowVariable[];
348
- steps_json?: WorkflowStep[];
349
- }
350
- interface ExuluRBAC {
351
- users?: Array<{
368
+ chunker: (item: Item & {
352
369
  id: string;
353
- rights: 'read' | 'write';
354
- }>;
355
- roles?: Array<{
356
- id: string;
357
- rights: 'read' | 'write';
358
- }>;
359
- }
360
- type ExuluEvalRunnerInstance = {
361
- name: string;
362
- description: string;
363
- testcases: ExuluEvalInput[];
364
- run: ExuluEvalRunner;
365
- };
366
- type ExuluEvalRunner = ({ data, runner }: {
367
- data: ExuluEvalInput;
368
- runner: {
369
- agent?: ExuluAgent & {
370
- providerapikey: string;
371
- };
372
- workflow?: ExuluWorkflow;
373
- };
374
- }) => Promise<{
375
- score: number;
376
- comment: string;
377
- }>;
378
- type ExuluEvalInput = {
379
- prompt?: string;
380
- inputs?: any;
381
- result?: string;
382
- category?: string;
383
- metadata?: Record<string, any>;
384
- duration?: number;
385
- reference?: string;
386
- };
387
- declare class ExuluEval {
388
- name: string;
389
- description: string;
390
- constructor({ name, description }: {
391
- name: string;
392
- description: string;
393
- });
394
- create: {
395
- LlmAsAJudge: {
396
- niah: ({ label, model, needles, testDocument, contextlengths }: {
397
- label: string;
398
- model: LanguageModel;
399
- needles: {
400
- question: string;
401
- answer: string;
402
- }[];
403
- testDocument: string;
404
- contextlengths: (5000 | 30000 | 50000 | 128000)[];
405
- }) => ExuluEvalRunnerInstance;
406
- };
407
- };
370
+ }, maxChunkSize: number, config: ExuluConfig) => Promise<ChunkerResponse>;
371
+ generateFromQuery(query: string, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
372
+ generateFromDocument(input: Item, config: ExuluConfig, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
408
373
  }
409
374
  declare class ExuluTool {
410
375
  id: string;
@@ -438,12 +403,50 @@ declare class ExuluTool {
438
403
  }>;
439
404
  });
440
405
  }
406
+ type ExuluContextFieldProcessor = {
407
+ description: string;
408
+ execute: ({ item, user, role, utils, config }: {
409
+ item: Item & {
410
+ field: string;
411
+ };
412
+ user: number;
413
+ role: string;
414
+ utils: {
415
+ storage: ExuluStorage;
416
+ items: {
417
+ update: ExuluContext['updateItem'];
418
+ create: ExuluContext['createItem'];
419
+ delete: ExuluContext['deleteItem'];
420
+ };
421
+ };
422
+ config: ExuluConfig;
423
+ }) => Promise<string>;
424
+ config?: {
425
+ queue?: Promise<ExuluQueueConfig>;
426
+ trigger: "manual" | "onUpdate" | "onCreate" | "always";
427
+ };
428
+ };
441
429
  type ExuluContextFieldDefinition = {
442
430
  name: string;
443
431
  type: ExuluFieldTypes;
444
432
  unique?: boolean;
433
+ required?: boolean;
434
+ default?: any;
435
+ calculated?: boolean;
436
+ index?: boolean;
437
+ enumValues?: string[];
438
+ allowedFileTypes?: allFileTypes[];
439
+ processor?: ExuluContextFieldProcessor;
445
440
  };
446
441
  type ExuluRightsMode = "private" | "users" | "roles" | "public" | "projects";
442
+ declare class ExuluStorage {
443
+ private config;
444
+ constructor({ config }: {
445
+ config: ExuluConfig;
446
+ });
447
+ getPresignedUrl: (key: string) => Promise<string>;
448
+ uploadFile: (user: number, file: Buffer | Uint8Array, key: string, type: string, metadata?: Record<string, string>) => Promise<string>;
449
+ }
447
450
  declare class ExuluContext {
448
451
  id: string;
449
452
  name: string;
@@ -475,39 +478,37 @@ declare class ExuluContext {
475
478
  language?: "german" | "english";
476
479
  };
477
480
  });
481
+ process: (trigger: STATISTICS_LABELS, user: number, role: string, item: Item & {
482
+ field: string;
483
+ }, config: ExuluConfig) => Promise<{
484
+ result: string;
485
+ job?: string;
486
+ }>;
478
487
  deleteAll: () => Promise<VectorOperationResponse>;
479
488
  tableExists: () => Promise<boolean>;
480
489
  chunksTableExists: () => Promise<boolean>;
481
- createAndUpsertEmbeddings: (item: Item, user?: number, statistics?: ExuluStatisticParams, role?: string, job?: string) => Promise<{
490
+ createAndUpsertEmbeddings: (item: Item, config: ExuluConfig, user?: number, statistics?: ExuluStatisticParams, role?: string, job?: string) => Promise<{
482
491
  id: string;
483
492
  chunks?: number;
484
493
  job?: string;
485
494
  }>;
486
- createItem: (item: Item, user?: number, role?: string, upsert?: boolean) => Promise<{
487
- item: Item;
488
- job?: string;
489
- }>;
490
- updateItem: (item: Item, user?: number, role?: string) => Promise<{
491
- item: Item;
492
- job?: string;
493
- }>;
494
- deleteItem: (item: Item, user?: number, role?: string) => Promise<{
495
- id: string;
496
- job?: string;
497
- }>;
495
+ private createItem;
496
+ private updateItem;
497
+ private deleteItem;
498
498
  embeddings: {
499
499
  generate: {
500
- one: ({ item, user, role, trigger }: {
500
+ one: ({ item, user, role, trigger, config }: {
501
501
  item: Item;
502
502
  user?: number;
503
503
  role?: string;
504
504
  trigger: STATISTICS_LABELS;
505
+ config: ExuluConfig;
505
506
  }) => Promise<{
506
507
  id: string;
507
508
  job?: string;
508
509
  chunks?: number;
509
510
  }>;
510
- all: (userId?: number, roleId?: string) => Promise<{
511
+ all: (config: ExuluConfig, userId?: number, roleId?: string) => Promise<{
511
512
  jobs: string[];
512
513
  items: number;
513
514
  }>;
@@ -540,10 +541,18 @@ declare const authentication: ({ apikey, authtoken, internalkey, db, }: {
540
541
  }>;
541
542
 
542
543
  declare class ExuluQueues {
543
- queues: Queue[];
544
+ queues: {
545
+ queue: Queue;
546
+ ratelimit: number;
547
+ concurrency: number;
548
+ }[];
544
549
  constructor();
545
- queue(name: string): Queue | undefined;
546
- use(name: string): Queue;
550
+ queue(name: string): {
551
+ queue: Queue;
552
+ ratelimit: number;
553
+ concurrency: number;
554
+ } | undefined;
555
+ use: (name: string, concurrency?: number, ratelimit?: number) => Promise<ExuluQueueConfig>;
547
556
  }
548
557
  declare const queues: ExuluQueues;
549
558
 
@@ -1420,7 +1429,6 @@ declare const ExuluJobs: {
1420
1429
  };
1421
1430
  };
1422
1431
  declare const ExuluDefaultContexts: {
1423
- files: ExuluContext;
1424
1432
  codeStandards: ExuluContext;
1425
1433
  outputs: ExuluContext;
1426
1434
  };
@@ -1482,4 +1490,4 @@ declare const ExuluChunkers: {
1482
1490
  };
1483
1491
  };
1484
1492
 
1485
- export { type JOB_STATUS as EXULU_JOB_STATUS, JOB_STATUS_ENUM as EXULU_JOB_STATUS_ENUM, type STATISTICS_TYPE as EXULU_STATISTICS_TYPE, STATISTICS_TYPE_ENUM as EXULU_STATISTICS_TYPE_ENUM, ExuluAgent, ExuluApp, authentication as ExuluAuthentication, ExuluChunkers, ExuluContext, ExuluDefaultAgents, ExuluDefaultContexts, ExuluEmbedder, ExuluEval, ExuluJobs, ExuluOtel, queues as ExuluQueues, ExuluTool, ExuluUtils, ExuluVariables, db };
1493
+ export { type JOB_STATUS as EXULU_JOB_STATUS, JOB_STATUS_ENUM as EXULU_JOB_STATUS_ENUM, type STATISTICS_TYPE as EXULU_STATISTICS_TYPE, STATISTICS_TYPE_ENUM as EXULU_STATISTICS_TYPE_ENUM, ExuluAgent, ExuluApp, authentication as ExuluAuthentication, ExuluChunkers, ExuluContext, ExuluDefaultAgents, ExuluDefaultContexts, ExuluEmbedder, ExuluEval, type ExuluEvalMetadata, type ExuluEvalTokenMetadata, ExuluJobs, ExuluOtel, type ExuluQueueConfig, queues as ExuluQueues, ExuluTool, ExuluUtils, ExuluVariables, db };