@exulu/backend 1.67.0 → 1.68.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/{chunk-ZPZKOT6I.js → chunk-VPSLTGZF.js} +1428 -139
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-4B7BQ5G2.js → convert-exulu-tools-to-ai-sdk-tools-CHQF36XW.js} +1 -1
- package/dist/index.cjs +24279 -22720
- package/dist/index.d.cts +256 -100
- package/dist/index.d.ts +256 -100
- package/dist/index.js +2837 -2645
- package/ee/agentic-retrieval/v3/agent-loop.ts +4 -4
- package/ee/agentic-retrieval/v3/index.ts +20 -6
- package/ee/python/documents/processing/doc_processor.ts +79 -34
- package/ee/workers.ts +3 -17
- package/package.json +1 -1
- package/ee/agentic-retrieval/v4/agent-loop.ts +0 -208
- package/ee/agentic-retrieval/v4/context-sampler.ts +0 -79
- package/ee/agentic-retrieval/v4/index.ts +0 -690
- package/ee/agentic-retrieval/v4/types.ts +0 -58
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,29 @@ import { z } from 'zod';
|
|
|
10
10
|
import { Tiktoken } from 'tiktoken/lite';
|
|
11
11
|
import models from 'tiktoken/model_to_encoding.json';
|
|
12
12
|
|
|
13
|
+
interface Project {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
custom_instructions: string;
|
|
18
|
+
rights_mode?: 'private' | 'users' | 'roles' | 'public';
|
|
19
|
+
created_by?: string;
|
|
20
|
+
project_items?: string[];
|
|
21
|
+
RBAC?: {
|
|
22
|
+
type?: string;
|
|
23
|
+
users?: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
rights: 'read' | 'write';
|
|
26
|
+
}>;
|
|
27
|
+
roles?: Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
rights: 'read' | 'write';
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
createdAt?: string;
|
|
33
|
+
updatedAt?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
13
36
|
type ApiKeyScopeMode = "admin" | "agents";
|
|
14
37
|
type User = {
|
|
15
38
|
id: number;
|
|
@@ -22,10 +45,20 @@ type User = {
|
|
|
22
45
|
personal_system_prompt?: string;
|
|
23
46
|
super_admin?: boolean;
|
|
24
47
|
favourite_agents?: string[];
|
|
48
|
+
/** Per-user favourited data items — global ids ("<contextId>/<itemId>"). */
|
|
49
|
+
favourite_items?: string[];
|
|
50
|
+
/** Per-user recently viewed data items — global ids, most-recent first. */
|
|
51
|
+
recently_viewed_items?: string[];
|
|
25
52
|
scope_mode?: ApiKeyScopeMode;
|
|
26
53
|
agent_ids?: string[];
|
|
27
54
|
role: UserRole;
|
|
28
55
|
team?: ExuluTeam;
|
|
56
|
+
/**
|
|
57
|
+
* Optional attribution target (mainly for API keys, type "api"): hydrated
|
|
58
|
+
* from the `project` uuid column at auth time so buildTags can emit
|
|
59
|
+
* project_id_ for API-triggered requests.
|
|
60
|
+
*/
|
|
61
|
+
project?: Project;
|
|
29
62
|
/**
|
|
30
63
|
* Live LiteLLM budget snapshot for the user, attached at context time when
|
|
31
64
|
* the "show user budget in chat" setting is on. Not a Postgres column.
|
|
@@ -350,6 +383,50 @@ type ExuluContextProcessor = {
|
|
|
350
383
|
};
|
|
351
384
|
};
|
|
352
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Chunking is now an ExuluContext concern (it used to live on the removed
|
|
388
|
+
* ExuluEmbedder class). A context may supply its own `chunker` to control how
|
|
389
|
+
* an item is split into embeddable chunks; if it doesn't, `defaultChunker`
|
|
390
|
+
* runs. Embedding generation itself goes through LiteLLM via resolveEmbedder —
|
|
391
|
+
* the chunker only produces the text segments.
|
|
392
|
+
*/
|
|
393
|
+
type ChunkerResponse = {
|
|
394
|
+
item: Item & {
|
|
395
|
+
id: string;
|
|
396
|
+
};
|
|
397
|
+
chunks: {
|
|
398
|
+
content: string;
|
|
399
|
+
index: number;
|
|
400
|
+
metadata?: Record<string, unknown>;
|
|
401
|
+
}[];
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* A chunker takes a (fully-hydrated) item and a target max chunk size and
|
|
405
|
+
* returns the ordered text chunks to embed. `utils.storage` is provided for
|
|
406
|
+
* chunkers that need to read file contents from object storage.
|
|
407
|
+
*
|
|
408
|
+
* Note: unlike the old ExuluEmbedder.chunker, there is no `settings` argument —
|
|
409
|
+
* the per-context `embedder_settings` config layer was removed. Chunkers that
|
|
410
|
+
* need configuration should close over it in code.
|
|
411
|
+
*/
|
|
412
|
+
type ChunkerOperation = (item: Item & {
|
|
413
|
+
id: string;
|
|
414
|
+
}, maxChunkSize: number, utils: {
|
|
415
|
+
storage: ExuluStorage;
|
|
416
|
+
}) => Promise<ChunkerResponse>;
|
|
417
|
+
/**
|
|
418
|
+
* Built-in chunker used when a context configures an embedder model but does
|
|
419
|
+
* not provide its own `chunker`. It runs the standard SentenceChunker (also
|
|
420
|
+
* exposed as ExuluChunkers.sentence) over the item's primary text — preferring
|
|
421
|
+
* a `content` field, then `description`, combined with the `name` — so a
|
|
422
|
+
* context "just works" from a model name alone. `maxChunkSize` is used as the
|
|
423
|
+
* per-chunk token budget. Contexts with structured or file-backed content
|
|
424
|
+
* should supply a custom ChunkerOperation.
|
|
425
|
+
*/
|
|
426
|
+
declare const defaultChunker: ChunkerOperation;
|
|
427
|
+
|
|
428
|
+
type ExuluRightsMode = "private" | "users" | "roles" | "teams" | "public";
|
|
429
|
+
|
|
353
430
|
type STATISTICS_TYPE = "CONTEXT_RETRIEVE" | "SOURCE_UPDATE" | "EMBEDDER_UPSERT" | "EMBEDDER_GENERATE" | "EMBEDDER_DELETE" | "WORKFLOW_RUN" | "CONTEXT_UPSERT" | "TOOL_CALL" | "AGENT_RUN";
|
|
354
431
|
declare const STATISTICS_TYPE_ENUM: {
|
|
355
432
|
CONTEXT_RETRIEVE: string;
|
|
@@ -373,67 +450,6 @@ type ExuluStatistic = {
|
|
|
373
450
|
};
|
|
374
451
|
type STATISTICS_LABELS = "tool" | "agent" | "flow" | "api" | "claude-code" | "user" | "processor";
|
|
375
452
|
|
|
376
|
-
type ExuluEmbedderConfig = {
|
|
377
|
-
name: string;
|
|
378
|
-
description: string;
|
|
379
|
-
default?: string;
|
|
380
|
-
};
|
|
381
|
-
type VectorGenerationResponse = Promise<{
|
|
382
|
-
id: string;
|
|
383
|
-
chunks: {
|
|
384
|
-
content: string;
|
|
385
|
-
index: number;
|
|
386
|
-
metadata: Record<string, string>;
|
|
387
|
-
vector: number[];
|
|
388
|
-
}[];
|
|
389
|
-
}>;
|
|
390
|
-
type VectorGenerateOperation = (inputs: ChunkerResponse, settings: Record<string, string>) => VectorGenerationResponse;
|
|
391
|
-
type ChunkerOperation = (item: Item & {
|
|
392
|
-
id: string;
|
|
393
|
-
}, maxChunkSize: number, utils: {
|
|
394
|
-
storage: ExuluStorage;
|
|
395
|
-
}, config: Record<string, string>) => Promise<ChunkerResponse>;
|
|
396
|
-
type ChunkerResponse = {
|
|
397
|
-
item: Item & {
|
|
398
|
-
id: string;
|
|
399
|
-
};
|
|
400
|
-
chunks: {
|
|
401
|
-
content: string;
|
|
402
|
-
index: number;
|
|
403
|
-
}[];
|
|
404
|
-
};
|
|
405
|
-
declare class ExuluEmbedder {
|
|
406
|
-
id: string;
|
|
407
|
-
name: string;
|
|
408
|
-
slug: string;
|
|
409
|
-
queue?: Promise<ExuluQueueConfig>;
|
|
410
|
-
private generateEmbeddings;
|
|
411
|
-
description: string;
|
|
412
|
-
vectorDimensions: number;
|
|
413
|
-
config?: ExuluEmbedderConfig[];
|
|
414
|
-
maxChunkSize: number;
|
|
415
|
-
_chunker: ChunkerOperation;
|
|
416
|
-
constructor({ id, name, description, generateEmbeddings, queue, vectorDimensions, maxChunkSize, chunker, config, }: {
|
|
417
|
-
id: string;
|
|
418
|
-
name: string;
|
|
419
|
-
description: string;
|
|
420
|
-
config?: ExuluEmbedderConfig[];
|
|
421
|
-
generateEmbeddings: VectorGenerateOperation;
|
|
422
|
-
chunker: ChunkerOperation;
|
|
423
|
-
queue?: Promise<ExuluQueueConfig>;
|
|
424
|
-
vectorDimensions: number;
|
|
425
|
-
maxChunkSize: number;
|
|
426
|
-
});
|
|
427
|
-
chunker: (context: string, item: Item & {
|
|
428
|
-
id: string;
|
|
429
|
-
}, maxChunkSize: number, config: ExuluConfig) => Promise<ChunkerResponse>;
|
|
430
|
-
private hydrateEmbedderConfig;
|
|
431
|
-
generateFromQuery(context: string, query: string, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
|
|
432
|
-
generateFromDocument(context: string, input: Item, config: ExuluConfig, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
type ExuluRightsMode = "private" | "users" | "roles" | "public";
|
|
436
|
-
|
|
437
453
|
/**
|
|
438
454
|
* Base operator type with comparison operations
|
|
439
455
|
*/
|
|
@@ -536,8 +552,6 @@ type ExuluEntitiesConfig = {
|
|
|
536
552
|
types?: EntityTypeDefinition[];
|
|
537
553
|
/** models.id used for extraction. Resolved via resolveModel(). Falls back to a platform default. */
|
|
538
554
|
model?: string;
|
|
539
|
-
/** Where to extract from. "chunks" (default) locates each mention to a chunk. */
|
|
540
|
-
extractFrom?: "chunks" | "document";
|
|
541
555
|
/** Weight of the shared-entity boost term in retrieval ranking. Default 0.3. */
|
|
542
556
|
boostWeight?: number;
|
|
543
557
|
/** Drop mentions below this extractor confidence (0..1). Default 0.5. */
|
|
@@ -609,6 +623,18 @@ type VectorSearchChunkResult = {
|
|
|
609
623
|
};
|
|
610
624
|
};
|
|
611
625
|
|
|
626
|
+
/**
|
|
627
|
+
* A context's embedder is now just a reference to a LiteLLM embedding model
|
|
628
|
+
* (plus an optional queue), not an ExuluEmbedder instance. Embedding generation
|
|
629
|
+
* goes through resolveEmbedder; chunking is configured separately via the
|
|
630
|
+
* context's `chunker` (or the built-in default chunker).
|
|
631
|
+
*/
|
|
632
|
+
type ExuluContextEmbedder = {
|
|
633
|
+
/** LiteLLM model_name of the embedding model (declared in config.litellm.yaml). */
|
|
634
|
+
model: string;
|
|
635
|
+
/** When set, embedding generation runs as a background job on this queue. */
|
|
636
|
+
queue?: Promise<ExuluQueueConfig>;
|
|
637
|
+
};
|
|
612
638
|
type ExuluContextFieldDefinition = {
|
|
613
639
|
name: string;
|
|
614
640
|
type: ExuluFieldTypes;
|
|
@@ -651,14 +677,20 @@ declare class ExuluContext {
|
|
|
651
677
|
fields: ExuluContextFieldDefinition[];
|
|
652
678
|
processor?: ExuluContextProcessor;
|
|
653
679
|
description: string;
|
|
654
|
-
embedder?:
|
|
680
|
+
embedder?: ExuluContextEmbedder;
|
|
681
|
+
/**
|
|
682
|
+
* Splits an item into embeddable chunks. Moved here from the removed
|
|
683
|
+
* ExuluEmbedder. When omitted, the built-in `defaultChunker` (SentenceChunker)
|
|
684
|
+
* is used so a context works from just an embedder model name.
|
|
685
|
+
*/
|
|
686
|
+
chunker?: ChunkerOperation;
|
|
655
687
|
queryRewriter?: (query: string) => Promise<string>;
|
|
656
688
|
resultReranker?: (results: {
|
|
657
689
|
chunk_content: string;
|
|
658
690
|
chunk_index: number;
|
|
659
691
|
chunk_id: string;
|
|
660
692
|
chunk_source: string;
|
|
661
|
-
chunk_metadata: Record<string,
|
|
693
|
+
chunk_metadata: Record<string, unknown>;
|
|
662
694
|
chunk_created_at: string;
|
|
663
695
|
chunk_updated_at: string;
|
|
664
696
|
item_id: string;
|
|
@@ -669,7 +701,7 @@ declare class ExuluContext {
|
|
|
669
701
|
chunk_index: number;
|
|
670
702
|
chunk_id: string;
|
|
671
703
|
chunk_source: string;
|
|
672
|
-
chunk_metadata: Record<string,
|
|
704
|
+
chunk_metadata: Record<string, unknown>;
|
|
673
705
|
chunk_created_at: string;
|
|
674
706
|
chunk_updated_at: string;
|
|
675
707
|
item_id: string;
|
|
@@ -698,12 +730,13 @@ declare class ExuluContext {
|
|
|
698
730
|
*/
|
|
699
731
|
entities?: ExuluEntitiesConfig;
|
|
700
732
|
sources: ExuluContextSource[];
|
|
701
|
-
constructor({ id, name, description, embedder, processor, active, fields, queryRewriter, resultReranker, configuration, entities, sources, }: {
|
|
733
|
+
constructor({ id, name, description, embedder, chunker, processor, active, fields, queryRewriter, resultReranker, configuration, entities, sources, }: {
|
|
702
734
|
id: string;
|
|
703
735
|
name: string;
|
|
704
736
|
fields: ExuluContextFieldDefinition[];
|
|
705
737
|
description: string;
|
|
706
|
-
embedder?:
|
|
738
|
+
embedder?: ExuluContextEmbedder;
|
|
739
|
+
chunker?: ChunkerOperation;
|
|
707
740
|
sources: ExuluContextSource[];
|
|
708
741
|
category?: string;
|
|
709
742
|
active: boolean;
|
|
@@ -837,6 +870,18 @@ declare class ExuluContext {
|
|
|
837
870
|
processed: number;
|
|
838
871
|
skipped: number;
|
|
839
872
|
}>;
|
|
873
|
+
/**
|
|
874
|
+
* Extract + ingest entities for a SINGLE item — powers the item detail
|
|
875
|
+
* page's "Extract entities" test action. Returns the number of mentions
|
|
876
|
+
* found so the UI can report the result.
|
|
877
|
+
*/
|
|
878
|
+
extractItem: (itemId: string) => Promise<{
|
|
879
|
+
extracted: number;
|
|
880
|
+
}>;
|
|
881
|
+
/** Detach all entities from a single item (drops links, prunes orphans). */
|
|
882
|
+
detachItem: (itemId: string) => Promise<{
|
|
883
|
+
detached: number;
|
|
884
|
+
}>;
|
|
840
885
|
/** Remove all entities (and their mentions via cascade) of a given type. */
|
|
841
886
|
purgeType: (typeName: string) => Promise<{
|
|
842
887
|
removed: number;
|
|
@@ -846,26 +891,6 @@ declare class ExuluContext {
|
|
|
846
891
|
createChunksTable: () => Promise<void>;
|
|
847
892
|
}
|
|
848
893
|
|
|
849
|
-
declare class ExuluReranker {
|
|
850
|
-
id: string;
|
|
851
|
-
name: string;
|
|
852
|
-
description: string;
|
|
853
|
-
execute: (params: {
|
|
854
|
-
query: string;
|
|
855
|
-
chunks: VectorSearchChunkResult[];
|
|
856
|
-
}) => Promise<VectorSearchChunkResult[]>;
|
|
857
|
-
constructor({ id, name, description, execute, }: {
|
|
858
|
-
id: string;
|
|
859
|
-
name: string;
|
|
860
|
-
description: string;
|
|
861
|
-
execute: (params: {
|
|
862
|
-
query: string;
|
|
863
|
-
chunks: VectorSearchChunkResult[];
|
|
864
|
-
}) => Promise<VectorSearchChunkResult[]>;
|
|
865
|
-
});
|
|
866
|
-
run(query: string, chunks: VectorSearchChunkResult[]): Promise<VectorSearchChunkResult[]>;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
894
|
type ExuluAgentToolConfig = {
|
|
870
895
|
id: string;
|
|
871
896
|
type: string;
|
|
@@ -944,8 +969,8 @@ declare class ExuluProvider {
|
|
|
944
969
|
constructor({ id, name, description, config, capabilities, type, maxContextLength, provider, queue, authenticationInformation, workflows, }: ExuluProviderParams);
|
|
945
970
|
get providerName(): string;
|
|
946
971
|
get modelName(): string;
|
|
947
|
-
tool: (instance: string, providers: ExuluProvider[], contexts: ExuluContext[]
|
|
948
|
-
generateSync: ({ prompt, req, user, session, inputMessages, approvedTools, currentTools, currentSkills, allExuluTools, statistics, toolConfigs, providerapikey, languageModel, contexts,
|
|
972
|
+
tool: (instance: string, providers: ExuluProvider[], contexts: ExuluContext[]) => Promise<ExuluTool | null>;
|
|
973
|
+
generateSync: ({ prompt, req, user, session, inputMessages, approvedTools, currentTools, currentSkills, allExuluTools, statistics, toolConfigs, providerapikey, languageModel, contexts, exuluConfig, agent, instructions, maxStepCount, onTokenUsage }: {
|
|
949
974
|
prompt?: string;
|
|
950
975
|
user?: User;
|
|
951
976
|
maxStepCount?: number;
|
|
@@ -962,7 +987,6 @@ declare class ExuluProvider {
|
|
|
962
987
|
providerapikey?: string | undefined;
|
|
963
988
|
languageModel: LanguageModel;
|
|
964
989
|
contexts?: ExuluContext[] | undefined;
|
|
965
|
-
rerankers?: ExuluReranker[] | undefined;
|
|
966
990
|
exuluConfig?: ExuluConfig;
|
|
967
991
|
instructions?: string;
|
|
968
992
|
onTokenUsage?: (usage: {
|
|
@@ -978,7 +1002,7 @@ declare class ExuluProvider {
|
|
|
978
1002
|
* - Image files -> image parts (which ARE supported by Responses API)
|
|
979
1003
|
*/
|
|
980
1004
|
private processFilePartsInMessages;
|
|
981
|
-
generateStream: ({ user, session, agent, message, previousMessages, currentTools, currentSkills, approvedTools, allExuluTools, toolConfigs, providerapikey, languageModel, contexts,
|
|
1005
|
+
generateStream: ({ user, session, agent, message, previousMessages, currentTools, currentSkills, approvedTools, allExuluTools, toolConfigs, providerapikey, languageModel, contexts, exuluConfig, instructions, req, maxStepCount }: {
|
|
982
1006
|
user?: User;
|
|
983
1007
|
session?: string;
|
|
984
1008
|
agent?: ExuluAgent;
|
|
@@ -993,7 +1017,6 @@ declare class ExuluProvider {
|
|
|
993
1017
|
providerapikey?: string | undefined;
|
|
994
1018
|
languageModel: LanguageModel;
|
|
995
1019
|
contexts?: ExuluContext[] | undefined;
|
|
996
|
-
rerankers?: ExuluReranker[] | undefined;
|
|
997
1020
|
exuluConfig?: ExuluConfig;
|
|
998
1021
|
instructions?: string;
|
|
999
1022
|
req?: Request;
|
|
@@ -1099,17 +1122,15 @@ declare class ExuluApp {
|
|
|
1099
1122
|
private _config?;
|
|
1100
1123
|
private _evals;
|
|
1101
1124
|
private _queues;
|
|
1102
|
-
private _rerankers;
|
|
1103
1125
|
private _contexts?;
|
|
1104
1126
|
private _tools;
|
|
1105
1127
|
private _expressApp;
|
|
1106
1128
|
constructor();
|
|
1107
|
-
create: ({ contexts, providers, config, agents, tools, evals,
|
|
1129
|
+
create: ({ contexts, providers, config, agents, tools, evals, }: {
|
|
1108
1130
|
contexts?: Record<string, ExuluContext>;
|
|
1109
1131
|
config: ExuluConfig;
|
|
1110
1132
|
agents?: ExuluAgent[];
|
|
1111
1133
|
providers?: ExuluProvider[];
|
|
1112
|
-
rerankers?: ExuluReranker[];
|
|
1113
1134
|
evals?: ExuluEval[];
|
|
1114
1135
|
tools?: ExuluTool[];
|
|
1115
1136
|
}) => Promise<ExuluApp>;
|
|
@@ -2208,14 +2229,72 @@ declare function validatePythonEnvironment(packageRoot?: string, checkPackages?:
|
|
|
2208
2229
|
message: string;
|
|
2209
2230
|
}>;
|
|
2210
2231
|
|
|
2232
|
+
/**
|
|
2233
|
+
* resolveOcr — the OCR-side counterpart of resolveEmbedder.
|
|
2234
|
+
*
|
|
2235
|
+
* Like resolveEmbedder, this is LiteLLM-ONLY: OCR always goes through the
|
|
2236
|
+
* spawned LiteLLM proxy's Mistral-compatible `/v1/ocr` endpoint. There is no
|
|
2237
|
+
* in-code provider/SDK fallback — a caller just names a LiteLLM `model` (e.g.
|
|
2238
|
+
* "mistral-ocr", "vertex-ocr") and it works, with cost attribution via tags
|
|
2239
|
+
* (user/role/project/agent/routine/context, when provided — see buildTags()).
|
|
2240
|
+
*
|
|
2241
|
+
* Routing OCR through the proxy means we can cost-control it through the same
|
|
2242
|
+
* tag-based budgets as chat and embeddings, and switch the underlying provider
|
|
2243
|
+
* (mistral / azure_ai / vertex_ai) by editing config.litellm.yaml without
|
|
2244
|
+
* touching this code.
|
|
2245
|
+
*
|
|
2246
|
+
* LiteLLM follows the Mistral OCR request/response shape:
|
|
2247
|
+
* https://docs.mistral.ai/capabilities/vision/#optical-character-recognition-ocr
|
|
2248
|
+
*/
|
|
2249
|
+
type ResolveOcrInput = {
|
|
2250
|
+
/** LiteLLM model_name of the OCR model (e.g. "mistral-ocr"). */
|
|
2251
|
+
model: string;
|
|
2252
|
+
/** Context this OCR belongs to — emitted as context_id_/context_name_ tags. */
|
|
2253
|
+
contextId?: string;
|
|
2254
|
+
contextName?: string;
|
|
2255
|
+
user?: User;
|
|
2256
|
+
/** When only a numeric user id is available (background ingestion jobs). */
|
|
2257
|
+
userId?: number;
|
|
2258
|
+
roleId?: string;
|
|
2259
|
+
project?: Project;
|
|
2260
|
+
agent?: ExuluAgent;
|
|
2261
|
+
routine?: {
|
|
2262
|
+
id: string;
|
|
2263
|
+
name: string;
|
|
2264
|
+
};
|
|
2265
|
+
};
|
|
2266
|
+
|
|
2211
2267
|
type DocumentProcessorConfig = {
|
|
2212
2268
|
vlm?: {
|
|
2213
|
-
|
|
2269
|
+
/**
|
|
2270
|
+
* LiteLLM model_name for the VLM page-validation pass (declared in
|
|
2271
|
+
* config.litellm.yaml, e.g. "vertex-gemini-2.5-flash"). Resolved via
|
|
2272
|
+
* resolveModel() so the VLM pass shares the same tag-based cost controls
|
|
2273
|
+
* and provider-switching as chat / embeddings / OCR, and the underlying
|
|
2274
|
+
* provider can be swapped without code changes.
|
|
2275
|
+
*/
|
|
2276
|
+
model: string;
|
|
2214
2277
|
concurrency: number;
|
|
2215
2278
|
};
|
|
2216
2279
|
processor: {
|
|
2217
2280
|
name: "docling" | "liteparse" | "mistral" | "officeparser";
|
|
2281
|
+
/**
|
|
2282
|
+
* LiteLLM model_name for the "mistral" OCR processor (declared in
|
|
2283
|
+
* config.litellm.yaml). Defaults to "mistral-ocr". OCR is routed through
|
|
2284
|
+
* the LiteLLM proxy so it shares the same tag-based cost controls as chat
|
|
2285
|
+
* and embeddings, and the underlying provider (mistral / azure_ai /
|
|
2286
|
+
* vertex_ai) can be switched without code changes.
|
|
2287
|
+
*/
|
|
2288
|
+
model?: string;
|
|
2218
2289
|
};
|
|
2290
|
+
/**
|
|
2291
|
+
* Optional cost-attribution context, forwarded to LiteLLM as spend tags
|
|
2292
|
+
* (user / role / project / context) for both the OCR pass (resolveOcr) and
|
|
2293
|
+
* the VLM page-validation pass (resolveModel). Not yet populated by callers;
|
|
2294
|
+
* the wiring is in place so per-user/per-context budgets work the moment
|
|
2295
|
+
* attribution is threaded through.
|
|
2296
|
+
*/
|
|
2297
|
+
attribution?: Omit<ResolveOcrInput, "model">;
|
|
2219
2298
|
debugging?: {
|
|
2220
2299
|
deleteTempFiles?: boolean;
|
|
2221
2300
|
};
|
|
@@ -2235,6 +2314,81 @@ declare function documentProcessor({ file, name, config }: {
|
|
|
2235
2314
|
config?: DocumentProcessorConfig;
|
|
2236
2315
|
}): Promise<ProcessedDocument | undefined>;
|
|
2237
2316
|
|
|
2317
|
+
/**
|
|
2318
|
+
* resolveReranker — the rerank-side counterpart of resolveEmbedder / resolveOcr.
|
|
2319
|
+
*
|
|
2320
|
+
* Like those, this is LiteLLM-ONLY: reranking always goes through the spawned
|
|
2321
|
+
* LiteLLM proxy's cohere-compatible `/v1/rerank` endpoint. There is no in-code
|
|
2322
|
+
* provider/SDK fallback — a caller just names a LiteLLM `model` (a model_name
|
|
2323
|
+
* declared in config.litellm.yaml with `model_info.type: reranker`) and it
|
|
2324
|
+
* works, with cost attribution via tags (user/role/project/agent/routine/
|
|
2325
|
+
* context, when provided — see buildTags()).
|
|
2326
|
+
*
|
|
2327
|
+
* Routing rerank through the proxy means we cost-control it through the same
|
|
2328
|
+
* tag-based budgets as chat / embeddings / OCR, and switch the underlying
|
|
2329
|
+
* provider (cohere / vertex_ai / together_ai / ...) by editing
|
|
2330
|
+
* config.litellm.yaml without touching this code.
|
|
2331
|
+
*
|
|
2332
|
+
* `rerank` takes the chunks directly, builds each document as
|
|
2333
|
+
* `item_name + ": " + chunk_content` (the standard retrieval convention), calls
|
|
2334
|
+
* the proxy, and maps the relevance scores back onto the chunks (reordered,
|
|
2335
|
+
* `rerank_score` attached). The item type is constrained structurally
|
|
2336
|
+
* (item_name / chunk_content) so both ChunkResult and VectorSearchChunkResult
|
|
2337
|
+
* work without importing either — no src/exulu → retrieval/GraphQL dependency.
|
|
2338
|
+
*
|
|
2339
|
+
* LiteLLM follows the Cohere rerank request/response shape:
|
|
2340
|
+
* https://docs.cohere.com/reference/rerank
|
|
2341
|
+
*/
|
|
2342
|
+
type ResolveRerankerInput = {
|
|
2343
|
+
/** LiteLLM model_name of the reranker (e.g. "rerank-v4.0-pro"). */
|
|
2344
|
+
model: string;
|
|
2345
|
+
/** Context this rerank belongs to — emitted as context_id_/context_name_ tags. */
|
|
2346
|
+
contextId?: string;
|
|
2347
|
+
contextName?: string;
|
|
2348
|
+
user?: User;
|
|
2349
|
+
/** When only a numeric user id is available (background ingestion jobs). */
|
|
2350
|
+
userId?: number;
|
|
2351
|
+
roleId?: string;
|
|
2352
|
+
project?: Project;
|
|
2353
|
+
agent?: ExuluAgent;
|
|
2354
|
+
routine?: {
|
|
2355
|
+
id: string;
|
|
2356
|
+
name: string;
|
|
2357
|
+
};
|
|
2358
|
+
};
|
|
2359
|
+
/** Minimal chunk shape rerank() needs to build a document. */
|
|
2360
|
+
type RerankableChunk = {
|
|
2361
|
+
item_name?: string;
|
|
2362
|
+
chunk_content?: string;
|
|
2363
|
+
};
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* Public, package-facing reranker — the counterpart of
|
|
2367
|
+
* `ExuluDocumentProcessor.process`. A drop-in replacement for a hand-rolled
|
|
2368
|
+
* Cohere / Google reranker: pass `{ query, items, model }` and get the items
|
|
2369
|
+
* back reordered desc by relevance with a `rerank_score` attached.
|
|
2370
|
+
*
|
|
2371
|
+
* `model` is a LiteLLM model_name declared in config.litellm.yaml with
|
|
2372
|
+
* `model_info.type: reranker`, so the SAME call works against any supported
|
|
2373
|
+
* provider (cohere / vertex_ai / together_ai / ...) — switch providers in
|
|
2374
|
+
* config, not in code — and reranking is cost-attributed via the optional
|
|
2375
|
+
* identity/context fields (user / role / project / agent / routine / context).
|
|
2376
|
+
*
|
|
2377
|
+
* Each document is built as `item_name + ": " + chunk_content` (the standard
|
|
2378
|
+
* retrieval convention). Items are constrained structurally, so any chunk shape
|
|
2379
|
+
* carrying `item_name` / `chunk_content` works and the extra fields are
|
|
2380
|
+
* preserved on the returned objects.
|
|
2381
|
+
*/
|
|
2382
|
+
type ExuluRerankInput<T extends RerankableChunk> = {
|
|
2383
|
+
query: string;
|
|
2384
|
+
items: T[];
|
|
2385
|
+
/** Only score/return the top N items (optional optimization hint). */
|
|
2386
|
+
topN?: number;
|
|
2387
|
+
} & ResolveRerankerInput;
|
|
2388
|
+
declare function rerank<T extends RerankableChunk>(input: ExuluRerankInput<T>): Promise<(T & {
|
|
2389
|
+
rerank_score: number;
|
|
2390
|
+
})[]>;
|
|
2391
|
+
|
|
2238
2392
|
/**
|
|
2239
2393
|
* Creates the v3 ExuluTool for agentic context retrieval.
|
|
2240
2394
|
*
|
|
@@ -2244,9 +2398,8 @@ declare function documentProcessor({ file, name, config }: {
|
|
|
2244
2398
|
* - Context example records sampled at init and cached
|
|
2245
2399
|
* - Strategy-specific instructions and tool sets
|
|
2246
2400
|
*/
|
|
2247
|
-
declare function createAgenticRetrievalToolV3({ contexts, instructions: adminInstructions,
|
|
2401
|
+
declare function createAgenticRetrievalToolV3({ contexts, instructions: adminInstructions, user, role, model, preselected, memoryItems }: {
|
|
2248
2402
|
contexts: ExuluContext[];
|
|
2249
|
-
rerankers: ExuluReranker[];
|
|
2250
2403
|
user?: User;
|
|
2251
2404
|
role?: string;
|
|
2252
2405
|
model?: LanguageModel;
|
|
@@ -2326,6 +2479,9 @@ declare const ExuluAuthentication: {
|
|
|
2326
2479
|
declare const ExuluDocumentProcessor: {
|
|
2327
2480
|
process: typeof documentProcessor;
|
|
2328
2481
|
};
|
|
2482
|
+
declare const ExuluReranker: {
|
|
2483
|
+
rerank: typeof rerank;
|
|
2484
|
+
};
|
|
2329
2485
|
declare const ExuluOtel: {
|
|
2330
2486
|
create: ({ SIGNOZ_ACCESS_TOKEN, SIGNOZ_TRACES_URL, SIGNOZ_LOGS_URL, }: {
|
|
2331
2487
|
SIGNOZ_ACCESS_TOKEN: string;
|
|
@@ -2366,4 +2522,4 @@ declare const ExuluPython: {
|
|
|
2366
2522
|
instructions: typeof getPythonSetupInstructions;
|
|
2367
2523
|
};
|
|
2368
2524
|
|
|
2369
|
-
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, type ExuluAgent, ExuluApp, ExuluAuthentication, ExuluChunkers, ExuluContext, ExuluDatabase, ExuluDefaultProviders, ExuluDefaultTools, ExuluDocumentProcessor,
|
|
2525
|
+
export { type ChunkerOperation, type ChunkerResponse, 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, type ExuluAgent, ExuluApp, ExuluAuthentication, ExuluChunkers, ExuluContext, type ExuluContextEmbedder, ExuluDatabase, ExuluDefaultProviders, ExuluDefaultTools, ExuluDocumentProcessor, ExuluEval, type Item as ExuluItem, ExuluJobs, type ExuluOauthConfig, type ExuluOauthToolContext, ExuluOtel, ExuluProvider, ExuluPython, queues as ExuluQueues, ExuluReranker, ExuluTool, trajectoryRegistry as ExuluTrajectoryRegistry, ExuluVariables, defaultChunker };
|