@elizaos/plugin-knowledge 1.6.1 → 2.0.0-alpha.1
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/actions.d.ts +5 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/browser/index.browser.js +191 -0
- package/dist/browser/index.browser.js.map +12 -0
- package/dist/cjs/index.node.cjs +103074 -0
- package/dist/cjs/index.node.cjs.map +720 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/ctx-embeddings.d.ts +53 -0
- package/dist/ctx-embeddings.d.ts.map +1 -0
- package/dist/docs-loader.d.ts +9 -0
- package/dist/docs-loader.d.ts.map +1 -0
- package/dist/document-processor.d.ts +26 -0
- package/dist/document-processor.d.ts.map +1 -0
- package/dist/documents-provider.d.ts +3 -0
- package/dist/documents-provider.d.ts.map +1 -0
- package/dist/index.browser.d.ts +5 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.d.ts +12 -424
- package/dist/index.d.ts.map +1 -0
- package/dist/index.node.d.ts +2 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/llm.d.ts +27 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/node/index.node.js +103084 -0
- package/dist/node/index.node.js.map +719 -0
- package/dist/provider.d.ts +3 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/routes.d.ts +3 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/service.d.ts +76 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/types.d.ts +138 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/vite.config.d.ts +3 -0
- package/dist/vite.config.d.ts.map +1 -0
- package/package.json +51 -32
- package/README.md +0 -360
- package/dist/.vite/manifest.json +0 -11
- package/dist/assets/index-CFqKS0Ch.css +0 -1
- package/dist/assets/index-DcxhjPNa.js +0 -54
- package/dist/index.html +0 -14
- package/dist/index.js +0 -5396
- package/dist/index.js.map +0 -1
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import { type ModelConfig, type ProviderRateLimits } from "./types.ts";
|
|
3
|
+
export declare function validateModelConfig(runtime?: IAgentRuntime): ModelConfig;
|
|
4
|
+
export declare function getProviderRateLimits(runtime?: IAgentRuntime): Promise<ProviderRateLimits>;
|
|
5
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,WAAW,EAAqB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAS1F,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,WAAW,CAgExE;AAgCD,wBAAsB,qBAAqB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8BhG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const DEFAULT_CHUNK_TOKEN_SIZE = 500;
|
|
2
|
+
export declare const DEFAULT_CHUNK_OVERLAP_TOKENS = 100;
|
|
3
|
+
export declare const DEFAULT_CHARS_PER_TOKEN = 3.5;
|
|
4
|
+
export declare const CONTEXT_TARGETS: {
|
|
5
|
+
DEFAULT: {
|
|
6
|
+
MIN_TOKENS: number;
|
|
7
|
+
MAX_TOKENS: number;
|
|
8
|
+
};
|
|
9
|
+
PDF: {
|
|
10
|
+
MIN_TOKENS: number;
|
|
11
|
+
MAX_TOKENS: number;
|
|
12
|
+
};
|
|
13
|
+
MATH_PDF: {
|
|
14
|
+
MIN_TOKENS: number;
|
|
15
|
+
MAX_TOKENS: number;
|
|
16
|
+
};
|
|
17
|
+
CODE: {
|
|
18
|
+
MIN_TOKENS: number;
|
|
19
|
+
MAX_TOKENS: number;
|
|
20
|
+
};
|
|
21
|
+
TECHNICAL: {
|
|
22
|
+
MIN_TOKENS: number;
|
|
23
|
+
MAX_TOKENS: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare const SYSTEM_PROMPT = "You are a precision text augmentation tool. Your task is to expand a given text chunk with its direct context from a larger document. You must: 1) Keep the original chunk intact; 2) Add critical context from surrounding text; 3) Never summarize or rephrase the original chunk; 4) Create contextually rich output for improved semantic retrieval.";
|
|
27
|
+
export declare const SYSTEM_PROMPTS: {
|
|
28
|
+
DEFAULT: string;
|
|
29
|
+
CODE: string;
|
|
30
|
+
PDF: string;
|
|
31
|
+
MATH_PDF: string;
|
|
32
|
+
TECHNICAL: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const CONTEXTUAL_CHUNK_ENRICHMENT_PROMPT_TEMPLATE = "\n<document>\n{doc_content}\n</document>\n\nHere is the chunk we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this chunk by adding critical surrounding context. Follow these guidelines:\n\n1. Identify the document's main topic and key information relevant to understanding this chunk\n2. Include 2-3 sentences before the chunk that provide essential context\n3. Include 2-3 sentences after the chunk that complete thoughts or provide resolution\n4. For technical documents, include any definitions or explanations of terms used in the chunk\n5. For narrative content, include character or setting information needed to understand the chunk\n6. Keep the original chunk text COMPLETELY INTACT and UNCHANGED in your response\n7. Do not use phrases like \"this chunk discusses\" - directly present the context\n8. The total length should be between {min_tokens} and {max_tokens} tokens\n9. Format the response as a single coherent paragraph\n\nProvide ONLY the enriched chunk text in your response:";
|
|
35
|
+
export declare const CACHED_CHUNK_PROMPT_TEMPLATE = "\nHere is the chunk we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this chunk by adding critical surrounding context. Follow these guidelines:\n\n1. Identify the document's main topic and key information relevant to understanding this chunk\n2. Include 2-3 sentences before the chunk that provide essential context\n3. Include 2-3 sentences after the chunk that complete thoughts or provide resolution\n4. For technical documents, include any definitions or explanations of terms used in the chunk\n5. For narrative content, include character or setting information needed to understand the chunk\n6. Keep the original chunk text COMPLETELY INTACT and UNCHANGED in your response\n7. Do not use phrases like \"this chunk discusses\" - directly present the context\n8. The total length should be between {min_tokens} and {max_tokens} tokens\n9. Format the response as a single coherent paragraph\n\nProvide ONLY the enriched chunk text in your response:";
|
|
36
|
+
export declare const CACHED_CODE_CHUNK_PROMPT_TEMPLATE = "\nHere is the chunk of code we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this code chunk by adding critical surrounding context. Follow these guidelines:\n\n1. Preserve ALL code syntax, indentation, and comments exactly as they appear\n2. Include any import statements, function definitions, or class declarations that this code depends on\n3. Add necessary type definitions or interfaces that are referenced in this chunk\n4. Include any crucial comments from elsewhere in the document that explain this code\n5. If there are key variable declarations or initializations earlier in the document, include those\n6. Keep the original chunk COMPLETELY INTACT and UNCHANGED in your response\n7. The total length should be between {min_tokens} and {max_tokens} tokens\n8. Do NOT include implementation details for functions that are only called but not defined in this chunk\n\nProvide ONLY the enriched code chunk in your response:";
|
|
37
|
+
export declare const CACHED_MATH_PDF_PROMPT_TEMPLATE = "\nHere is the chunk we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this chunk by adding critical surrounding context. This document contains mathematical content that requires special handling. Follow these guidelines:\n\n1. Preserve ALL mathematical notation exactly as it appears in the chunk\n2. Include any defining equations, variables, or parameters mentioned earlier in the document that relate to this chunk\n3. Add section/subsection names or figure references if they help situate the chunk\n4. If variables or symbols are defined elsewhere in the document, include these definitions\n5. If mathematical expressions appear corrupted, try to infer their meaning from context\n6. Keep the original chunk text COMPLETELY INTACT and UNCHANGED in your response\n7. The total length should be between {min_tokens} and {max_tokens} tokens\n8. Format the response as a coherent mathematical explanation\n\nProvide ONLY the enriched chunk text in your response:";
|
|
38
|
+
export declare const CACHED_TECHNICAL_PROMPT_TEMPLATE = "\nHere is the chunk we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this chunk by adding critical surrounding context. This appears to be technical documentation that requires special handling. Follow these guidelines:\n\n1. Preserve ALL technical terminology, product names, and version numbers exactly as they appear\n2. Include any prerequisite information or requirements mentioned earlier in the document\n3. Add section/subsection headings or navigation path to situate this chunk within the document structure\n4. Include any definitions of technical terms, acronyms, or jargon used in this chunk\n5. If this chunk references specific configurations, include relevant parameter explanations\n6. Keep the original chunk text COMPLETELY INTACT and UNCHANGED in your response\n7. The total length should be between {min_tokens} and {max_tokens} tokens\n8. Format the response maintaining any hierarchical structure present in the original\n\nProvide ONLY the enriched chunk text in your response:";
|
|
39
|
+
export declare const MATH_PDF_PROMPT_TEMPLATE = "\n<document>\n{doc_content}\n</document>\n\nHere is the chunk we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this chunk by adding critical surrounding context. This document contains mathematical content that requires special handling. Follow these guidelines:\n\n1. Preserve ALL mathematical notation exactly as it appears in the chunk\n2. Include any defining equations, variables, or parameters mentioned earlier in the document that relate to this chunk\n3. Add section/subsection names or figure references if they help situate the chunk\n4. If variables or symbols are defined elsewhere in the document, include these definitions\n5. If mathematical expressions appear corrupted, try to infer their meaning from context\n6. Keep the original chunk text COMPLETELY INTACT and UNCHANGED in your response\n7. The total length should be between {min_tokens} and {max_tokens} tokens\n8. Format the response as a coherent mathematical explanation\n\nProvide ONLY the enriched chunk text in your response:";
|
|
40
|
+
export declare const CODE_PROMPT_TEMPLATE = "\n<document>\n{doc_content}\n</document>\n\nHere is the chunk of code we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this code chunk by adding critical surrounding context. Follow these guidelines:\n\n1. Preserve ALL code syntax, indentation, and comments exactly as they appear\n2. Include any import statements, function definitions, or class declarations that this code depends on\n3. Add necessary type definitions or interfaces that are referenced in this chunk\n4. Include any crucial comments from elsewhere in the document that explain this code\n5. If there are key variable declarations or initializations earlier in the document, include those\n6. Keep the original chunk COMPLETELY INTACT and UNCHANGED in your response\n7. The total length should be between {min_tokens} and {max_tokens} tokens\n8. Do NOT include implementation details for functions that are only called but not defined in this chunk\n\nProvide ONLY the enriched code chunk in your response:";
|
|
41
|
+
export declare const TECHNICAL_PROMPT_TEMPLATE = "\n<document>\n{doc_content}\n</document>\n\nHere is the chunk we want to situate within the whole document:\n<chunk>\n{chunk_content}\n</chunk>\n\nCreate an enriched version of this chunk by adding critical surrounding context. This appears to be technical documentation that requires special handling. Follow these guidelines:\n\n1. Preserve ALL technical terminology, product names, and version numbers exactly as they appear\n2. Include any prerequisite information or requirements mentioned earlier in the document\n3. Add section/subsection headings or navigation path to situate this chunk within the document structure\n4. Include any definitions of technical terms, acronyms, or jargon used in this chunk\n5. If this chunk references specific configurations, include relevant parameter explanations\n6. Keep the original chunk text COMPLETELY INTACT and UNCHANGED in your response\n7. The total length should be between {min_tokens} and {max_tokens} tokens\n8. Format the response maintaining any hierarchical structure present in the original\n\nProvide ONLY the enriched chunk text in your response:";
|
|
42
|
+
export declare function getContextualizationPrompt(docContent: string, chunkContent: string, minTokens?: number, maxTokens?: number, promptTemplate?: string): string;
|
|
43
|
+
export declare function getCachingContextualizationPrompt(chunkContent: string, contentType?: string, minTokens?: number, maxTokens?: number): {
|
|
44
|
+
prompt: string;
|
|
45
|
+
systemPrompt: string;
|
|
46
|
+
};
|
|
47
|
+
export declare function getPromptForMimeType(mimeType: string, docContent: string, chunkContent: string): string;
|
|
48
|
+
export declare function getCachingPromptForMimeType(mimeType: string, chunkContent: string): {
|
|
49
|
+
prompt: string;
|
|
50
|
+
systemPrompt: string;
|
|
51
|
+
};
|
|
52
|
+
export declare function getChunkWithContext(chunkContent: string, generatedContext: string): string;
|
|
53
|
+
//# sourceMappingURL=ctx-embeddings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ctx-embeddings.d.ts","sourceRoot":"","sources":["../ctx-embeddings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEF,eAAO,MAAM,aAAa,6VACkU,CAAC;AAE7V,eAAO,MAAM,cAAc;;;;;;CAa1B,CAAC;AAEF,eAAO,MAAM,2CAA2C,0iCAsBD,CAAC;AAExD,eAAO,MAAM,4BAA4B,ggCAkBc,CAAC;AAExD,eAAO,MAAM,iCAAiC,2+BAiBS,CAAC;AAExD,eAAO,MAAM,+BAA+B,2gCAiBW,CAAC;AAExD,eAAO,MAAM,gCAAgC,gjCAiBU,CAAC;AAExD,eAAO,MAAM,wBAAwB,qjCAqBkB,CAAC;AAExD,eAAO,MAAM,oBAAoB,qhCAqBsB,CAAC;AAExD,eAAO,MAAM,yBAAyB,0lCAqBiB,CAAC;AAExD,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,SAAS,SAAqC,EAC9C,SAAS,SAAqC,EAC9C,cAAc,SAA8C,GAC3D,MAAM,CAiBR;AAED,wBAAgB,iCAAiC,CAC/C,YAAY,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,SAAqC,EAC9C,SAAS,SAAqC,GAC7C;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAsD1C;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,MAAM,CAoCR;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA+B1C;AA0FD,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAK1F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type UUID } from "@elizaos/core";
|
|
2
|
+
import type { KnowledgeService } from "./service.ts";
|
|
3
|
+
export declare function getKnowledgePath(runtimePath?: string): string;
|
|
4
|
+
export declare function loadDocsFromPath(service: KnowledgeService, agentId: UUID, worldId?: UUID, knowledgePath?: string): Promise<{
|
|
5
|
+
total: number;
|
|
6
|
+
successful: number;
|
|
7
|
+
failed: number;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=docs-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-loader.d.ts","sourceRoot":"","sources":["../docs-loader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAmB7D;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,IAAI,EACb,OAAO,CAAC,EAAE,IAAI,EACd,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAwEhE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Buffer } from "node:buffer";
|
|
2
|
+
import { type IAgentRuntime, type Memory, type UUID } from "@elizaos/core";
|
|
3
|
+
export declare function processFragmentsSynchronously({ runtime, documentId, fullDocumentText, agentId, contentType, roomId, entityId, worldId, documentTitle, }: {
|
|
4
|
+
runtime: IAgentRuntime;
|
|
5
|
+
documentId: UUID;
|
|
6
|
+
fullDocumentText: string;
|
|
7
|
+
agentId: UUID;
|
|
8
|
+
contentType?: string;
|
|
9
|
+
roomId?: UUID;
|
|
10
|
+
entityId?: UUID;
|
|
11
|
+
worldId?: UUID;
|
|
12
|
+
documentTitle?: string;
|
|
13
|
+
}): Promise<number>;
|
|
14
|
+
export declare function extractTextFromDocument(fileBuffer: Buffer, contentType: string, originalFilename: string): Promise<string>;
|
|
15
|
+
export declare function createDocumentMemory({ text, agentId, clientDocumentId, originalFilename, contentType, worldId, fileSize, documentId, customMetadata, }: {
|
|
16
|
+
text: string;
|
|
17
|
+
agentId: UUID;
|
|
18
|
+
clientDocumentId: UUID;
|
|
19
|
+
originalFilename: string;
|
|
20
|
+
contentType: string;
|
|
21
|
+
worldId: UUID;
|
|
22
|
+
fileSize: number;
|
|
23
|
+
documentId?: UUID;
|
|
24
|
+
customMetadata?: Record<string, unknown>;
|
|
25
|
+
}): Memory;
|
|
26
|
+
//# sourceMappingURL=document-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-processor.d.ts","sourceRoot":"","sources":["../document-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,MAAM,EAIX,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;AA8DvB,wBAAsB,6BAA6B,CAAC,EAClD,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,MAAM,EACN,QAAQ,EACR,OAAO,EACP,aAAa,GACd,EAAE;IACD,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,IAAI,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,IAAI,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6ClB;AAED,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,EACV,cAAc,GACf,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,IAAI,CAAC;IACd,gBAAgB,EAAE,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,IAAI,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C,GAAG,MAAM,CAyBT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents-provider.d.ts","sourceRoot":"","sources":["../documents-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK7D,eAAO,MAAM,iBAAiB,EAAE,QAqH/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,cAAc,SAAS,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,429 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const ModelConfigSchema: z.ZodObject<{
|
|
5
|
-
EMBEDDING_PROVIDER: z.ZodOptional<z.ZodEnum<["openai", "google"]>>;
|
|
6
|
-
TEXT_PROVIDER: z.ZodOptional<z.ZodEnum<["openai", "anthropic", "openrouter", "google"]>>;
|
|
7
|
-
OPENAI_API_KEY: z.ZodOptional<z.ZodString>;
|
|
8
|
-
ANTHROPIC_API_KEY: z.ZodOptional<z.ZodString>;
|
|
9
|
-
OPENROUTER_API_KEY: z.ZodOptional<z.ZodString>;
|
|
10
|
-
GOOGLE_API_KEY: z.ZodOptional<z.ZodString>;
|
|
11
|
-
OPENAI_BASE_URL: z.ZodOptional<z.ZodString>;
|
|
12
|
-
ANTHROPIC_BASE_URL: z.ZodOptional<z.ZodString>;
|
|
13
|
-
OPENROUTER_BASE_URL: z.ZodOptional<z.ZodString>;
|
|
14
|
-
GOOGLE_BASE_URL: z.ZodOptional<z.ZodString>;
|
|
15
|
-
TEXT_EMBEDDING_MODEL: z.ZodString;
|
|
16
|
-
TEXT_MODEL: z.ZodOptional<z.ZodString>;
|
|
17
|
-
MAX_INPUT_TOKENS: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
18
|
-
MAX_OUTPUT_TOKENS: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
19
|
-
EMBEDDING_DIMENSION: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
20
|
-
LOAD_DOCS_ON_STARTUP: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
-
CTX_KNOWLEDGE_ENABLED: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
-
RATE_LIMIT_ENABLED: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
-
MAX_CONCURRENT_REQUESTS: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
24
|
-
REQUESTS_PER_MINUTE: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
25
|
-
TOKENS_PER_MINUTE: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
26
|
-
BATCH_DELAY_MS: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
27
|
-
}, "strip", z.ZodTypeAny, {
|
|
28
|
-
TEXT_EMBEDDING_MODEL: string;
|
|
29
|
-
MAX_INPUT_TOKENS: number;
|
|
30
|
-
MAX_OUTPUT_TOKENS: number;
|
|
31
|
-
EMBEDDING_DIMENSION: number;
|
|
32
|
-
LOAD_DOCS_ON_STARTUP: boolean;
|
|
33
|
-
CTX_KNOWLEDGE_ENABLED: boolean;
|
|
34
|
-
RATE_LIMIT_ENABLED: boolean;
|
|
35
|
-
MAX_CONCURRENT_REQUESTS: number;
|
|
36
|
-
REQUESTS_PER_MINUTE: number;
|
|
37
|
-
TOKENS_PER_MINUTE: number;
|
|
38
|
-
BATCH_DELAY_MS: number;
|
|
39
|
-
EMBEDDING_PROVIDER?: "openai" | "google" | undefined;
|
|
40
|
-
TEXT_PROVIDER?: "openai" | "google" | "anthropic" | "openrouter" | undefined;
|
|
41
|
-
OPENAI_API_KEY?: string | undefined;
|
|
42
|
-
ANTHROPIC_API_KEY?: string | undefined;
|
|
43
|
-
OPENROUTER_API_KEY?: string | undefined;
|
|
44
|
-
GOOGLE_API_KEY?: string | undefined;
|
|
45
|
-
OPENAI_BASE_URL?: string | undefined;
|
|
46
|
-
ANTHROPIC_BASE_URL?: string | undefined;
|
|
47
|
-
OPENROUTER_BASE_URL?: string | undefined;
|
|
48
|
-
GOOGLE_BASE_URL?: string | undefined;
|
|
49
|
-
TEXT_MODEL?: string | undefined;
|
|
50
|
-
}, {
|
|
51
|
-
TEXT_EMBEDDING_MODEL: string;
|
|
52
|
-
MAX_INPUT_TOKENS: string | number;
|
|
53
|
-
EMBEDDING_PROVIDER?: "openai" | "google" | undefined;
|
|
54
|
-
TEXT_PROVIDER?: "openai" | "google" | "anthropic" | "openrouter" | undefined;
|
|
55
|
-
OPENAI_API_KEY?: string | undefined;
|
|
56
|
-
ANTHROPIC_API_KEY?: string | undefined;
|
|
57
|
-
OPENROUTER_API_KEY?: string | undefined;
|
|
58
|
-
GOOGLE_API_KEY?: string | undefined;
|
|
59
|
-
OPENAI_BASE_URL?: string | undefined;
|
|
60
|
-
ANTHROPIC_BASE_URL?: string | undefined;
|
|
61
|
-
OPENROUTER_BASE_URL?: string | undefined;
|
|
62
|
-
GOOGLE_BASE_URL?: string | undefined;
|
|
63
|
-
TEXT_MODEL?: string | undefined;
|
|
64
|
-
MAX_OUTPUT_TOKENS?: string | number | undefined;
|
|
65
|
-
EMBEDDING_DIMENSION?: string | number | undefined;
|
|
66
|
-
LOAD_DOCS_ON_STARTUP?: boolean | undefined;
|
|
67
|
-
CTX_KNOWLEDGE_ENABLED?: boolean | undefined;
|
|
68
|
-
RATE_LIMIT_ENABLED?: boolean | undefined;
|
|
69
|
-
MAX_CONCURRENT_REQUESTS?: string | number | undefined;
|
|
70
|
-
REQUESTS_PER_MINUTE?: string | number | undefined;
|
|
71
|
-
TOKENS_PER_MINUTE?: string | number | undefined;
|
|
72
|
-
BATCH_DELAY_MS?: string | number | undefined;
|
|
73
|
-
}>;
|
|
74
|
-
type ModelConfig = z.infer<typeof ModelConfigSchema>;
|
|
75
|
-
/**
|
|
76
|
-
* Interface for provider rate limits
|
|
77
|
-
*/
|
|
78
|
-
interface ProviderRateLimits {
|
|
79
|
-
maxConcurrentRequests: number;
|
|
80
|
-
requestsPerMinute: number;
|
|
81
|
-
tokensPerMinute?: number;
|
|
82
|
-
provider: string;
|
|
83
|
-
rateLimitEnabled: boolean;
|
|
84
|
-
batchDelayMs: number;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Options for text generation overrides
|
|
88
|
-
*/
|
|
89
|
-
interface TextGenerationOptions {
|
|
90
|
-
provider?: 'anthropic' | 'openai' | 'openrouter' | 'google';
|
|
91
|
-
modelName?: string;
|
|
92
|
-
maxTokens?: number;
|
|
93
|
-
/**
|
|
94
|
-
* Document to cache for contextual retrieval.
|
|
95
|
-
* When provided (along with an Anthropic model via OpenRouter), this enables prompt caching.
|
|
96
|
-
* The document is cached with the provider and subsequent requests will reuse the cached document,
|
|
97
|
-
* significantly reducing costs for multiple operations on the same document.
|
|
98
|
-
* Most effective with contextual retrieval for Knowledge applications.
|
|
99
|
-
*/
|
|
100
|
-
cacheDocument?: string;
|
|
101
|
-
/**
|
|
102
|
-
* Options for controlling the cache behavior.
|
|
103
|
-
* Currently supports { type: 'ephemeral' } which sets up a temporary cache.
|
|
104
|
-
* Cache expires after approximately 5 minutes with Anthropic models.
|
|
105
|
-
* This can reduce costs by up to 90% for reads after the initial cache write.
|
|
106
|
-
*/
|
|
107
|
-
cacheOptions?: {
|
|
108
|
-
type: 'ephemeral';
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Whether to automatically detect and enable caching for contextual retrieval.
|
|
112
|
-
* Default is true for OpenRouter+Anthropic models with document-chunk prompts.
|
|
113
|
-
* Set to false to disable automatic caching detection.
|
|
114
|
-
*/
|
|
115
|
-
autoCacheContextualRetrieval?: boolean;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Options for adding knowledge to the system
|
|
119
|
-
*/
|
|
120
|
-
interface AddKnowledgeOptions {
|
|
121
|
-
/** Agent ID from the frontend - if not provided, will use runtime.agentId */
|
|
122
|
-
agentId?: UUID;
|
|
123
|
-
worldId: UUID;
|
|
124
|
-
roomId: UUID;
|
|
125
|
-
entityId: UUID;
|
|
126
|
-
/** Client-provided document ID */
|
|
127
|
-
clientDocumentId: UUID;
|
|
128
|
-
/** MIME type of the file */
|
|
129
|
-
contentType: string;
|
|
130
|
-
/** Original filename */
|
|
131
|
-
originalFilename: string;
|
|
132
|
-
/**
|
|
133
|
-
* Content of the document. Should be:
|
|
134
|
-
* - Base64 encoded string for binary files (PDFs, DOCXs, etc)
|
|
135
|
-
* - Plain text for text files
|
|
136
|
-
*/
|
|
137
|
-
content: string;
|
|
138
|
-
/**
|
|
139
|
-
* Optional metadata to associate with the knowledge
|
|
140
|
-
* Used for storing additional information like source URL
|
|
141
|
-
*/
|
|
142
|
-
metadata?: Record<string, unknown>;
|
|
143
|
-
}
|
|
144
|
-
declare module '@elizaos/core' {
|
|
145
|
-
interface ServiceTypeRegistry {
|
|
146
|
-
KNOWLEDGE: 'knowledge';
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
declare const KnowledgeServiceType: {
|
|
150
|
-
KNOWLEDGE: "knowledge";
|
|
151
|
-
};
|
|
152
|
-
interface KnowledgeDocumentMetadata extends Record<string, any> {
|
|
153
|
-
type: string;
|
|
154
|
-
source: string;
|
|
155
|
-
title?: string;
|
|
156
|
-
filename?: string;
|
|
157
|
-
fileExt?: string;
|
|
158
|
-
fileType?: string;
|
|
159
|
-
fileSize?: number;
|
|
160
|
-
}
|
|
161
|
-
interface KnowledgeConfig {
|
|
162
|
-
CTX_KNOWLEDGE_ENABLED: boolean;
|
|
163
|
-
LOAD_DOCS_ON_STARTUP: boolean;
|
|
164
|
-
MAX_INPUT_TOKENS?: string | number;
|
|
165
|
-
MAX_OUTPUT_TOKENS?: string | number;
|
|
166
|
-
EMBEDDING_PROVIDER?: string;
|
|
167
|
-
TEXT_PROVIDER?: string;
|
|
168
|
-
TEXT_EMBEDDING_MODEL?: string;
|
|
169
|
-
RATE_LIMIT_ENABLED?: boolean;
|
|
170
|
-
MAX_CONCURRENT_REQUESTS?: number;
|
|
171
|
-
REQUESTS_PER_MINUTE?: number;
|
|
172
|
-
TOKENS_PER_MINUTE?: number;
|
|
173
|
-
BATCH_DELAY_MS?: number;
|
|
174
|
-
}
|
|
175
|
-
interface LoadResult {
|
|
176
|
-
successful: number;
|
|
177
|
-
failed: number;
|
|
178
|
-
errors?: Array<{
|
|
179
|
-
filename: string;
|
|
180
|
-
error: string;
|
|
181
|
-
}>;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Extends the base MemoryMetadata from @elizaos/core with additional fields
|
|
185
|
-
*/
|
|
186
|
-
interface ExtendedMemoryMetadata extends Record<string, any> {
|
|
187
|
-
type?: string;
|
|
188
|
-
title?: string;
|
|
189
|
-
filename?: string;
|
|
190
|
-
path?: string;
|
|
191
|
-
description?: string;
|
|
192
|
-
fileExt?: string;
|
|
193
|
-
timestamp?: number;
|
|
194
|
-
contentType?: string;
|
|
195
|
-
documentId?: string;
|
|
196
|
-
source?: string;
|
|
197
|
-
fileType?: string;
|
|
198
|
-
fileSize?: number;
|
|
199
|
-
position?: number;
|
|
200
|
-
originalFilename?: string;
|
|
201
|
-
url?: string;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Knowledge Service - Provides retrieval augmented generation capabilities
|
|
206
|
-
*/
|
|
207
|
-
declare class KnowledgeService extends Service {
|
|
208
|
-
static readonly serviceType = "knowledge";
|
|
209
|
-
config: Metadata;
|
|
210
|
-
private knowledgeConfig;
|
|
211
|
-
capabilityDescription: string;
|
|
212
|
-
private knowledgeProcessingSemaphore;
|
|
213
|
-
/**
|
|
214
|
-
* Create a new Knowledge service
|
|
215
|
-
* @param runtime Agent runtime
|
|
216
|
-
*/
|
|
217
|
-
constructor(runtime: IAgentRuntime, config?: Partial<KnowledgeConfig>);
|
|
218
|
-
private loadInitialDocuments;
|
|
219
|
-
/**
|
|
220
|
-
* Start the Knowledge service
|
|
221
|
-
* @param runtime Agent runtime
|
|
222
|
-
* @returns Initialized Knowledge service
|
|
223
|
-
*/
|
|
224
|
-
static start(runtime: IAgentRuntime): Promise<KnowledgeService>;
|
|
225
|
-
/**
|
|
226
|
-
* Stop the Knowledge service
|
|
227
|
-
* @param runtime Agent runtime
|
|
228
|
-
*/
|
|
229
|
-
static stop(runtime: IAgentRuntime): Promise<void>;
|
|
230
|
-
/**
|
|
231
|
-
* Stop the service
|
|
232
|
-
*/
|
|
233
|
-
stop(): Promise<void>;
|
|
234
|
-
/**
|
|
235
|
-
* Add knowledge to the system
|
|
236
|
-
* @param options Knowledge options
|
|
237
|
-
* @returns Promise with document processing result
|
|
238
|
-
*/
|
|
239
|
-
addKnowledge(options: AddKnowledgeOptions): Promise<{
|
|
240
|
-
clientDocumentId: string;
|
|
241
|
-
storedDocumentMemoryId: UUID;
|
|
242
|
-
fragmentCount: number;
|
|
243
|
-
}>;
|
|
244
|
-
/**
|
|
245
|
-
* Process a document regardless of type - Called by public addKnowledge
|
|
246
|
-
* @param options Document options
|
|
247
|
-
* @returns Promise with document processing result
|
|
248
|
-
*/
|
|
249
|
-
private processDocument;
|
|
250
|
-
private handleProcessingError;
|
|
251
|
-
checkExistingKnowledge(knowledgeId: UUID): Promise<boolean>;
|
|
252
|
-
getKnowledge(message: Memory, scope?: {
|
|
253
|
-
roomId?: UUID;
|
|
254
|
-
worldId?: UUID;
|
|
255
|
-
entityId?: UUID;
|
|
256
|
-
}): Promise<KnowledgeItem[]>;
|
|
257
|
-
/**
|
|
258
|
-
* Enrich a conversation memory with RAG metadata
|
|
259
|
-
* This can be called after response generation to add RAG tracking data
|
|
260
|
-
* @param memoryId The ID of the conversation memory to enrich
|
|
261
|
-
* @param ragMetadata The RAG metadata to add
|
|
262
|
-
*/
|
|
263
|
-
enrichConversationMemoryWithRAG(memoryId: UUID, ragMetadata: {
|
|
264
|
-
retrievedFragments: Array<{
|
|
265
|
-
fragmentId: UUID;
|
|
266
|
-
documentTitle: string;
|
|
267
|
-
similarityScore?: number;
|
|
268
|
-
contentPreview: string;
|
|
269
|
-
}>;
|
|
270
|
-
queryText: string;
|
|
271
|
-
totalFragments: number;
|
|
272
|
-
retrievalTimestamp: number;
|
|
273
|
-
}): Promise<void>;
|
|
274
|
-
/**
|
|
275
|
-
* Set the current response memory ID for RAG tracking
|
|
276
|
-
* This is called by the knowledge provider to track which response memory to enrich
|
|
277
|
-
*/
|
|
278
|
-
private pendingRAGEnrichment;
|
|
279
|
-
/**
|
|
280
|
-
* Store RAG metadata for the next conversation memory that gets created
|
|
281
|
-
* @param ragMetadata The RAG metadata to associate with the next memory
|
|
282
|
-
*/
|
|
283
|
-
setPendingRAGMetadata(ragMetadata: any): void;
|
|
284
|
-
/**
|
|
285
|
-
* Try to enrich recent conversation memories with pending RAG metadata
|
|
286
|
-
* This is called periodically to catch memories that were created after RAG retrieval
|
|
287
|
-
*/
|
|
288
|
-
enrichRecentMemoriesWithPendingRAG(): Promise<void>;
|
|
289
|
-
processCharacterKnowledge(items: string[]): Promise<void>;
|
|
290
|
-
_internalAddKnowledge(item: KnowledgeItem, // item.id here is expected to be the ID of the "document"
|
|
291
|
-
options?: {
|
|
292
|
-
targetTokens: number;
|
|
293
|
-
overlap: number;
|
|
294
|
-
modelContextSize: number;
|
|
295
|
-
}, scope?: {
|
|
296
|
-
roomId: `${string}-${string}-${string}-${string}-${string}`;
|
|
297
|
-
entityId: `${string}-${string}-${string}-${string}-${string}`;
|
|
298
|
-
worldId: `${string}-${string}-${string}-${string}-${string}`;
|
|
299
|
-
}): Promise<void>;
|
|
300
|
-
private processDocumentFragment;
|
|
301
|
-
private splitAndCreateFragments;
|
|
302
|
-
/**
|
|
303
|
-
* Retrieves memories, typically documents, for the agent.
|
|
304
|
-
* Corresponds to GET /plugins/knowledge/documents
|
|
305
|
-
*/
|
|
306
|
-
getMemories(params: {
|
|
307
|
-
tableName: string;
|
|
308
|
-
roomId?: UUID;
|
|
309
|
-
count?: number;
|
|
310
|
-
offset?: number;
|
|
311
|
-
end?: number;
|
|
312
|
-
}): Promise<Memory[]>;
|
|
313
|
-
/**
|
|
314
|
-
* Counts memories for pagination.
|
|
315
|
-
* Corresponds to counting documents or fragments.
|
|
316
|
-
*/
|
|
317
|
-
countMemories(params: {
|
|
318
|
-
tableName: string;
|
|
319
|
-
roomId?: UUID;
|
|
320
|
-
unique?: boolean;
|
|
321
|
-
}): Promise<number>;
|
|
322
|
-
/**
|
|
323
|
-
* Deletes a specific memory item (knowledge document) by its ID.
|
|
324
|
-
* Corresponds to DELETE /plugins/knowledge/documents/:knowledgeId
|
|
325
|
-
* Assumes the memoryId corresponds to an item in the 'documents' table or that
|
|
326
|
-
* runtime.deleteMemory can correctly identify it.
|
|
327
|
-
*/
|
|
328
|
-
deleteMemory(memoryId: UUID): Promise<void>;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Represents a knowledge provider that retrieves knowledge from the knowledge base.
|
|
333
|
-
* @type {Provider}
|
|
334
|
-
* @property {string} name - The name of the knowledge provider.
|
|
335
|
-
* @property {string} description - The description of the knowledge provider.
|
|
336
|
-
* @property {boolean} dynamic - Indicates if the knowledge provider is dynamic or static.
|
|
337
|
-
* @property {Function} get - Asynchronously retrieves knowledge from the knowledge base.
|
|
338
|
-
* @param {IAgentRuntime} runtime - The agent runtime object.
|
|
339
|
-
* @param {Memory} message - The message containing the query for knowledge retrieval.
|
|
340
|
-
* @returns {Object} An object containing the retrieved knowledge data, values, and text.
|
|
341
|
-
*/
|
|
342
|
-
declare const knowledgeProvider: Provider;
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Represents a static provider that lists available documents in the knowledge base.
|
|
346
|
-
* This provider helps the agent understand which documents are available for retrieval.
|
|
347
|
-
* @type {Provider}
|
|
348
|
-
* @property {string} name - The name of the documents provider.
|
|
349
|
-
* @property {string} description - The description of the documents provider.
|
|
350
|
-
* @property {boolean} dynamic - Indicates if the provider is static (false).
|
|
351
|
-
* @property {Function} get - Asynchronously retrieves the list of available documents.
|
|
352
|
-
* @param {IAgentRuntime} runtime - The agent runtime object.
|
|
353
|
-
* @returns {Object} An object containing the available documents list.
|
|
354
|
-
*/
|
|
355
|
-
declare const documentsProvider: Provider;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Knowledge Plugin - Main Entry Point
|
|
359
|
-
*
|
|
360
|
-
* This file exports all the necessary functions and types for the Knowledge plugin.
|
|
361
|
-
*/
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Configuration options for the Knowledge Plugin
|
|
365
|
-
*/
|
|
366
|
-
interface KnowledgePluginConfig {
|
|
367
|
-
/**
|
|
368
|
-
* Enable frontend UI and routes
|
|
369
|
-
* Set to false for cloud/server-only deployments
|
|
370
|
-
* @default true
|
|
371
|
-
*/
|
|
1
|
+
import type { Plugin } from "@elizaos/core";
|
|
2
|
+
export interface KnowledgePluginConfig {
|
|
372
3
|
enableUI?: boolean;
|
|
373
|
-
/**
|
|
374
|
-
* Enable HTTP routes for document management
|
|
375
|
-
* Set to false for browser-only or minimal deployments
|
|
376
|
-
* @default true
|
|
377
|
-
*/
|
|
378
4
|
enableRoutes?: boolean;
|
|
379
|
-
/**
|
|
380
|
-
* Enable actions (PROCESS_KNOWLEDGE, SEARCH_KNOWLEDGE)
|
|
381
|
-
* @default true
|
|
382
|
-
*/
|
|
383
5
|
enableActions?: boolean;
|
|
384
|
-
/**
|
|
385
|
-
* Enable tests
|
|
386
|
-
* @default true
|
|
387
|
-
*/
|
|
388
6
|
enableTests?: boolean;
|
|
389
7
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
*
|
|
399
|
-
|
|
400
|
-
* });
|
|
401
|
-
*
|
|
402
|
-
* @example
|
|
403
|
-
* // Browser-only mode (no routes)
|
|
404
|
-
* const plugin = createKnowledgePlugin({
|
|
405
|
-
* enableRoutes: false,
|
|
406
|
-
* });
|
|
407
|
-
*
|
|
408
|
-
* @example
|
|
409
|
-
* // Full mode (default)
|
|
410
|
-
* const plugin = createKnowledgePlugin();
|
|
411
|
-
*/
|
|
412
|
-
declare function createKnowledgePlugin(config?: KnowledgePluginConfig): Plugin;
|
|
413
|
-
/**
|
|
414
|
-
* Knowledge Plugin - Core mode (Service + Provider only)
|
|
415
|
-
* Use this for cloud runtimes or minimal deployments
|
|
416
|
-
*/
|
|
417
|
-
declare const knowledgePluginCore: Plugin;
|
|
418
|
-
/**
|
|
419
|
-
* Knowledge Plugin - Headless mode (Service + Provider + Actions, no UI)
|
|
420
|
-
* Use this for server deployments without frontend
|
|
421
|
-
*/
|
|
422
|
-
declare const knowledgePluginHeadless: Plugin;
|
|
423
|
-
/**
|
|
424
|
-
* Knowledge Plugin - Full mode (default)
|
|
425
|
-
* Includes everything: Service, Provider, Actions, Routes, UI, Tests
|
|
426
|
-
*/
|
|
427
|
-
declare const knowledgePlugin: Plugin;
|
|
428
|
-
|
|
429
|
-
export { type AddKnowledgeOptions, type ExtendedMemoryMetadata, type KnowledgeConfig, type KnowledgeDocumentMetadata, type KnowledgePluginConfig, KnowledgeService, KnowledgeServiceType, type LoadResult, type ModelConfig, ModelConfigSchema, type ProviderRateLimits, type TextGenerationOptions, createKnowledgePlugin, knowledgePlugin as default, documentsProvider, knowledgePlugin, knowledgePluginCore, knowledgePluginHeadless, knowledgeProvider };
|
|
8
|
+
export declare function createKnowledgePlugin(config?: KnowledgePluginConfig): Plugin;
|
|
9
|
+
export declare const knowledgePluginCore: Plugin;
|
|
10
|
+
export declare const knowledgePluginHeadless: Plugin;
|
|
11
|
+
export declare const knowledgePlugin: Plugin;
|
|
12
|
+
export default knowledgePlugin;
|
|
13
|
+
export { documentsProvider } from "./documents-provider";
|
|
14
|
+
export { knowledgeProvider } from "./provider";
|
|
15
|
+
export { KnowledgeService } from "./service";
|
|
16
|
+
export * from "./types";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAO5C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,qBAA0B,GAAG,MAAM,CA2BhF;AAED,eAAO,MAAM,mBAAmB,EAAE,MAKhC,CAAC;AAEH,eAAO,MAAM,uBAAuB,EAAE,MAKpC,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,MAK5B,CAAC;AAEH,eAAe,eAAe,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../index.node.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
package/dist/llm.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
interface TextGenerationResult {
|
|
3
|
+
text: string;
|
|
4
|
+
usage: {
|
|
5
|
+
inputTokens?: number;
|
|
6
|
+
outputTokens?: number;
|
|
7
|
+
totalTokens?: number;
|
|
8
|
+
};
|
|
9
|
+
finishReason?: string;
|
|
10
|
+
response?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
modelId?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
import type { TextGenerationOptions } from "./types";
|
|
16
|
+
export declare function generateTextEmbedding(runtime: IAgentRuntime, text: string): Promise<{
|
|
17
|
+
embedding: number[];
|
|
18
|
+
}>;
|
|
19
|
+
export declare function generateTextEmbeddingsBatch(runtime: IAgentRuntime, texts: string[], batchSize?: number): Promise<Array<{
|
|
20
|
+
embedding: number[] | null;
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: unknown;
|
|
23
|
+
index: number;
|
|
24
|
+
}>>;
|
|
25
|
+
export declare function generateText(runtime: IAgentRuntime, prompt: string, system?: string, overrideConfig?: TextGenerationOptions): Promise<TextGenerationResult>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../llm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,eAAe,CAAC;AAM3D,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACL,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE;QACT,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAGD,OAAO,KAAK,EAAe,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAElE,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAgBlC;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,GAAE,MAAW,GACrB,OAAO,CACR,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CACxF,CAyCA;AA8DD,wBAAsB,YAAY,CAChC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,qBAAqB,GACrC,OAAO,CAAC,oBAAoB,CAAC,CAqC/B"}
|