@xpert-ai/plugin-sdk 3.6.5 → 3.6.7
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/index.cjs.js +3 -47
- package/index.esm.js +3 -47
- package/package.json +1 -1
- package/src/lib/data/datasource/types.d.ts +5 -2
package/index.cjs.js
CHANGED
|
@@ -25,7 +25,7 @@ var documents = require('@langchain/core/documents');
|
|
|
25
25
|
var chat_models = require('@langchain/core/language_models/chat_models');
|
|
26
26
|
var messages = require('@langchain/core/messages');
|
|
27
27
|
var env = require('@langchain/core/utils/env');
|
|
28
|
-
|
|
28
|
+
require('js-tiktoken');
|
|
29
29
|
|
|
30
30
|
function _interopNamespaceDefault(e) {
|
|
31
31
|
var n = Object.create(null);
|
|
@@ -1108,7 +1108,7 @@ exports.DBCreateTableMode = void 0;
|
|
|
1108
1108
|
(function(DBCreateTableMode) {
|
|
1109
1109
|
DBCreateTableMode["ERROR"] = "error";
|
|
1110
1110
|
DBCreateTableMode["IGNORE"] = "ignore";
|
|
1111
|
-
DBCreateTableMode["UPGRADE"] = "upgrade"; //
|
|
1111
|
+
DBCreateTableMode["UPGRADE"] = "upgrade"; // automatically upgrade table structure
|
|
1112
1112
|
})(exports.DBCreateTableMode || (exports.DBCreateTableMode = {}));
|
|
1113
1113
|
exports.DBTableDataAction = void 0;
|
|
1114
1114
|
(function(DBTableDataAction) {
|
|
@@ -2041,56 +2041,12 @@ class Speech2TextChatModel extends chat_models.BaseChatModel {
|
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
2043
|
|
|
2044
|
-
/**
|
|
2045
|
-
* Fallback token estimation method.
|
|
2046
|
-
*
|
|
2047
|
-
* 思路:
|
|
2048
|
-
* - 英文:约 4 chars / token
|
|
2049
|
-
* - 中文:约 1.5 chars / token
|
|
2050
|
-
* - Mixed:按字符区分
|
|
2051
|
-
*/ function estimateTokens(text) {
|
|
2052
|
-
if (!text) return 0;
|
|
2053
|
-
let cn = 0;
|
|
2054
|
-
let en = 0;
|
|
2055
|
-
for (const ch of text){
|
|
2056
|
-
if (/[\u4e00-\u9fa5]/.test(ch)) {
|
|
2057
|
-
cn++;
|
|
2058
|
-
} else {
|
|
2059
|
-
en++;
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
// 中文 1 token ≈ 1.5 chars
|
|
2063
|
-
const cnTokens = cn / 1.5;
|
|
2064
|
-
// 英文 1 token ≈ 4 chars
|
|
2065
|
-
const enTokens = en / 4;
|
|
2066
|
-
return Math.ceil(cnTokens + enTokens);
|
|
2067
|
-
}
|
|
2068
2044
|
/**
|
|
2069
2045
|
* Count tokens in text
|
|
2070
2046
|
* 1) Preferred: js-tiktoken precise encoding
|
|
2071
2047
|
* 2) Fallback: estimated token count
|
|
2072
2048
|
*/ function countTokensSafe(text, opts) {
|
|
2073
|
-
|
|
2074
|
-
let resolvedEncoding;
|
|
2075
|
-
// Decide encoding name
|
|
2076
|
-
if (opts == null ? void 0 : opts.encodingName) {
|
|
2077
|
-
resolvedEncoding = String(opts.encodingName);
|
|
2078
|
-
} else if (opts == null ? void 0 : opts.model) {
|
|
2079
|
-
var _getEncodingNameForModel;
|
|
2080
|
-
resolvedEncoding = (_getEncodingNameForModel = jsTiktoken.getEncodingNameForModel(opts.model)) != null ? _getEncodingNameForModel : 'cl100k_base';
|
|
2081
|
-
} else {
|
|
2082
|
-
resolvedEncoding = 'cl100k_base';
|
|
2083
|
-
}
|
|
2084
|
-
try {
|
|
2085
|
-
// Prefer exact token count via js-tiktoken
|
|
2086
|
-
const enc = (opts == null ? void 0 : opts.model) ? jsTiktoken.encodingForModel(opts.model) : jsTiktoken.getEncoding(resolvedEncoding);
|
|
2087
|
-
const tokens = enc.encode(text);
|
|
2088
|
-
return tokens.length;
|
|
2089
|
-
} catch (e) {
|
|
2090
|
-
// Fallback
|
|
2091
|
-
console.warn('[countTokensSafe] tiktoken failed, fallback estimate', e);
|
|
2092
|
-
return estimateTokens(text);
|
|
2093
|
-
}
|
|
2049
|
+
return 0;
|
|
2094
2050
|
}
|
|
2095
2051
|
|
|
2096
2052
|
Object.defineProperty(exports, "IColumnDef", {
|
package/index.esm.js
CHANGED
|
@@ -27,7 +27,7 @@ import { Document } from '@langchain/core/documents';
|
|
|
27
27
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
28
28
|
import { AIMessage } from '@langchain/core/messages';
|
|
29
29
|
import { getEnvironmentVariable } from '@langchain/core/utils/env';
|
|
30
|
-
import
|
|
30
|
+
import 'js-tiktoken';
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
|
|
@@ -1088,7 +1088,7 @@ var DBCreateTableMode;
|
|
|
1088
1088
|
(function(DBCreateTableMode) {
|
|
1089
1089
|
DBCreateTableMode["ERROR"] = "error";
|
|
1090
1090
|
DBCreateTableMode["IGNORE"] = "ignore";
|
|
1091
|
-
DBCreateTableMode["UPGRADE"] = "upgrade"; //
|
|
1091
|
+
DBCreateTableMode["UPGRADE"] = "upgrade"; // automatically upgrade table structure
|
|
1092
1092
|
})(DBCreateTableMode || (DBCreateTableMode = {}));
|
|
1093
1093
|
var DBTableDataAction;
|
|
1094
1094
|
(function(DBTableDataAction) {
|
|
@@ -2021,56 +2021,12 @@ class Speech2TextChatModel extends BaseChatModel {
|
|
|
2021
2021
|
}
|
|
2022
2022
|
}
|
|
2023
2023
|
|
|
2024
|
-
/**
|
|
2025
|
-
* Fallback token estimation method.
|
|
2026
|
-
*
|
|
2027
|
-
* 思路:
|
|
2028
|
-
* - 英文:约 4 chars / token
|
|
2029
|
-
* - 中文:约 1.5 chars / token
|
|
2030
|
-
* - Mixed:按字符区分
|
|
2031
|
-
*/ function estimateTokens(text) {
|
|
2032
|
-
if (!text) return 0;
|
|
2033
|
-
let cn = 0;
|
|
2034
|
-
let en = 0;
|
|
2035
|
-
for (const ch of text){
|
|
2036
|
-
if (/[\u4e00-\u9fa5]/.test(ch)) {
|
|
2037
|
-
cn++;
|
|
2038
|
-
} else {
|
|
2039
|
-
en++;
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
// 中文 1 token ≈ 1.5 chars
|
|
2043
|
-
const cnTokens = cn / 1.5;
|
|
2044
|
-
// 英文 1 token ≈ 4 chars
|
|
2045
|
-
const enTokens = en / 4;
|
|
2046
|
-
return Math.ceil(cnTokens + enTokens);
|
|
2047
|
-
}
|
|
2048
2024
|
/**
|
|
2049
2025
|
* Count tokens in text
|
|
2050
2026
|
* 1) Preferred: js-tiktoken precise encoding
|
|
2051
2027
|
* 2) Fallback: estimated token count
|
|
2052
2028
|
*/ function countTokensSafe(text, opts) {
|
|
2053
|
-
|
|
2054
|
-
let resolvedEncoding;
|
|
2055
|
-
// Decide encoding name
|
|
2056
|
-
if (opts == null ? void 0 : opts.encodingName) {
|
|
2057
|
-
resolvedEncoding = String(opts.encodingName);
|
|
2058
|
-
} else if (opts == null ? void 0 : opts.model) {
|
|
2059
|
-
var _getEncodingNameForModel;
|
|
2060
|
-
resolvedEncoding = (_getEncodingNameForModel = getEncodingNameForModel(opts.model)) != null ? _getEncodingNameForModel : 'cl100k_base';
|
|
2061
|
-
} else {
|
|
2062
|
-
resolvedEncoding = 'cl100k_base';
|
|
2063
|
-
}
|
|
2064
|
-
try {
|
|
2065
|
-
// Prefer exact token count via js-tiktoken
|
|
2066
|
-
const enc = (opts == null ? void 0 : opts.model) ? encodingForModel(opts.model) : getEncoding(resolvedEncoding);
|
|
2067
|
-
const tokens = enc.encode(text);
|
|
2068
|
-
return tokens.length;
|
|
2069
|
-
} catch (e) {
|
|
2070
|
-
// Fallback
|
|
2071
|
-
console.warn('[countTokensSafe] tiktoken failed, fallback estimate', e);
|
|
2072
|
-
return estimateTokens(text);
|
|
2073
|
-
}
|
|
2029
|
+
return 0;
|
|
2074
2030
|
}
|
|
2075
2031
|
|
|
2076
2032
|
export { AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, AdapterDataSourceStrategy, AiModelNotFoundException, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseTool, BaseToolset, BuiltinToolset, ChatOAICompatReasoningModel, CommonParameterRules, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, LLMUsage, LargeLanguageModel, ModelProvider, OpenAICompatibleReranker, PLUGIN_METADATA, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RerankModel, RetrieverRegistry, RetrieverStrategy, Speech2TextChatModel, SpeechToTextModel, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, VECTOR_STORE_STRATEGY, VectorStoreRegistry, VectorStoreStrategy, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, XpFileSystem, XpertServerPlugin, als, calcTokenUsage, countTokensSafe, createI18nInstance, createPluginLogger, downloadRemoteFile, getErrorMessage, getPositionList, getPositionMap, getRequestContext, isRemoteFile, loadYamlFile, mergeCredentials, mergeParentChildChunks, runWithRequestContext, sumTokenUsage };
|
package/package.json
CHANGED
|
@@ -306,9 +306,12 @@ export interface DBIndexDefinition {
|
|
|
306
306
|
unique?: boolean;
|
|
307
307
|
type?: 'btree' | 'hash' | 'gin' | 'bitmap' | 'fulltext' | string;
|
|
308
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Modes for creating a table, if the table already exists
|
|
311
|
+
*/
|
|
309
312
|
export declare enum DBCreateTableMode {
|
|
310
|
-
ERROR = "error",//
|
|
311
|
-
IGNORE = "ignore",//
|
|
313
|
+
ERROR = "error",// throw error
|
|
314
|
+
IGNORE = "ignore",// do nothing
|
|
312
315
|
UPGRADE = "upgrade"
|
|
313
316
|
}
|
|
314
317
|
export declare enum DBTableDataAction {
|