@kevisual/ai 0.0.13 → 0.0.15

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.
@@ -41,7 +41,7 @@ declare class AIUtils {
41
41
  * @param str 包含 JSON 的字符串
42
42
  * @returns 解析后的对象或 null
43
43
  */
44
- extractJsonFromMarkdown(str: string): any | null;
44
+ static extractJsonFromMarkdown(str: string): any | null;
45
45
  /**
46
46
  * 从 Markdown 代码块中提取代码
47
47
  * @param str Markdown 字符串
@@ -145,7 +145,7 @@ declare class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
145
145
  total_tokens: number;
146
146
  completion_tokens: number;
147
147
  responseText: string;
148
- utils: AIUtils;
148
+ utils: typeof AIUtils;
149
149
  constructor(options: BaseChatOptions);
150
150
  post(url?: string, opts?: {
151
151
  headers?: Record<string, string>;
@@ -527,5 +527,5 @@ declare class AIConfigParser {
527
527
  };
528
528
  }
529
529
 
530
- export { AIConfigParser, BailianProvider, BaseChat, ChatProviderMap, CustomProvider, DeepSeekProvider, KimiProvider, KnowledgeBase, ModelScopeProvider, OllamaProvider, ProviderManager, SiliconFlowKnowledge, SiliconFlowProvider, VolcesProvider, ZhipuProvider, decryptAES, encryptAES, readStream };
530
+ export { AIConfigParser, AIUtils, BailianChat, BailianProvider, BaseChat, ChatProviderMap, Custom, CustomProvider, DeepSeek, DeepSeekProvider, Kimi, KimiProvider, KnowledgeBase, ModelScope, ModelScopeProvider, Ollama, OllamaProvider, ProviderManager, SiliconFlow, SiliconFlowKnowledge, SiliconFlowProvider, Volces, VolcesProvider, Zhipu, ZhipuProvider, decryptAES, encryptAES, readStream };
531
531
  export type { AIConfig, AIModel, BaseChatInterface, BaseChatOptions, BaseChatUsageInterface, ChatMessage, ChatMessageComplete, ChatMessageOptions, ChatMessageStream, ChatStream, EmbeddingMessage, EmbeddingMessageComplete, GetProviderOpts, KnowledgeOptions, ProviderResult, RerankOptions, SecretKey };
@@ -18677,7 +18677,7 @@ var require_enc_utf8 = __commonJS((exports, module) => {
18677
18677
 
18678
18678
  // src/provider/core/utils/index.ts
18679
18679
  class AIUtils {
18680
- extractJsonFromMarkdown(str) {
18680
+ static extractJsonFromMarkdown(str) {
18681
18681
  const jsonRegex = /```json\s*([\s\S]*?)\s*```/;
18682
18682
  const match = str.match(jsonRegex);
18683
18683
  let jsonStr = match && match[1] ? match[1] : str;
@@ -18794,12 +18794,11 @@ class BaseChat {
18794
18794
  total_tokens;
18795
18795
  completion_tokens;
18796
18796
  responseText;
18797
- utils;
18797
+ utils = AIUtils;
18798
18798
  constructor(options) {
18799
18799
  this.baseURL = options.baseURL;
18800
18800
  this.model = options.model;
18801
18801
  this.apiKey = options.apiKey;
18802
- this.utils = new AIUtils;
18803
18802
  }
18804
18803
  post(url = "", opts = {}) {
18805
18804
  let _url = url.startsWith("http") ? url : this.baseURL + url;
@@ -19268,18 +19267,28 @@ export {
19268
19267
  encryptAES,
19269
19268
  decryptAES,
19270
19269
  ZhipuProvider,
19270
+ Zhipu,
19271
19271
  VolcesProvider,
19272
+ Volces,
19272
19273
  SiliconFlowProvider,
19273
19274
  SiliconFlowKnowledge,
19275
+ SiliconFlow,
19274
19276
  ProviderManager,
19275
19277
  OllamaProvider,
19278
+ Ollama,
19276
19279
  ModelScopeProvider,
19280
+ ModelScope,
19277
19281
  KnowledgeBase,
19278
19282
  KimiProvider,
19283
+ Kimi,
19279
19284
  DeepSeekProvider,
19285
+ DeepSeek,
19280
19286
  CustomProvider,
19287
+ Custom,
19281
19288
  ChatProviderMap,
19282
19289
  BaseChat,
19283
19290
  BailianProvider,
19291
+ BailianChat,
19292
+ AIUtils,
19284
19293
  AIConfigParser
19285
19294
  };
@@ -41,7 +41,7 @@ declare class AIUtils {
41
41
  * @param str 包含 JSON 的字符串
42
42
  * @returns 解析后的对象或 null
43
43
  */
44
- extractJsonFromMarkdown(str: string): any | null;
44
+ static extractJsonFromMarkdown(str: string): any | null;
45
45
  /**
46
46
  * 从 Markdown 代码块中提取代码
47
47
  * @param str Markdown 字符串
@@ -145,7 +145,7 @@ declare class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
145
145
  total_tokens: number;
146
146
  completion_tokens: number;
147
147
  responseText: string;
148
- utils: AIUtils;
148
+ utils: typeof AIUtils;
149
149
  constructor(options: BaseChatOptions);
150
150
  post(url?: string, opts?: {
151
151
  headers?: Record<string, string>;
@@ -527,5 +527,5 @@ declare class AIConfigParser {
527
527
  };
528
528
  }
529
529
 
530
- export { AIConfigParser, BailianProvider, BaseChat, ChatProviderMap, CustomProvider, DeepSeekProvider, KimiProvider, KnowledgeBase, ModelScopeProvider, OllamaProvider, ProviderManager, SiliconFlowKnowledge, SiliconFlowProvider, VolcesProvider, ZhipuProvider, decryptAES, encryptAES, readStream };
530
+ export { AIConfigParser, AIUtils, BailianChat, BailianProvider, BaseChat, ChatProviderMap, Custom, CustomProvider, DeepSeek, DeepSeekProvider, Kimi, KimiProvider, KnowledgeBase, ModelScope, ModelScopeProvider, Ollama, OllamaProvider, ProviderManager, SiliconFlow, SiliconFlowKnowledge, SiliconFlowProvider, Volces, VolcesProvider, Zhipu, ZhipuProvider, decryptAES, encryptAES, readStream };
531
531
  export type { AIConfig, AIModel, BaseChatInterface, BaseChatOptions, BaseChatUsageInterface, ChatMessage, ChatMessageComplete, ChatMessageOptions, ChatMessageStream, ChatStream, EmbeddingMessage, EmbeddingMessageComplete, GetProviderOpts, KnowledgeOptions, ProviderResult, RerankOptions, SecretKey };
@@ -1237,7 +1237,7 @@ var require_enc_utf8 = __commonJS((exports, module) => {
1237
1237
 
1238
1238
  // src/provider/core/utils/index.ts
1239
1239
  class AIUtils {
1240
- extractJsonFromMarkdown(str) {
1240
+ static extractJsonFromMarkdown(str) {
1241
1241
  const jsonRegex = /```json\s*([\s\S]*?)\s*```/;
1242
1242
  const match = str.match(jsonRegex);
1243
1243
  let jsonStr = match && match[1] ? match[1] : str;
@@ -1354,12 +1354,11 @@ class BaseChat {
1354
1354
  total_tokens;
1355
1355
  completion_tokens;
1356
1356
  responseText;
1357
- utils;
1357
+ utils = AIUtils;
1358
1358
  constructor(options) {
1359
1359
  this.baseURL = options.baseURL;
1360
1360
  this.model = options.model;
1361
1361
  this.apiKey = options.apiKey;
1362
- this.utils = new AIUtils;
1363
1362
  }
1364
1363
  post(url = "", opts = {}) {
1365
1364
  let _url = url.startsWith("http") ? url : this.baseURL + url;
@@ -1828,18 +1827,28 @@ export {
1828
1827
  encryptAES,
1829
1828
  decryptAES,
1830
1829
  ZhipuProvider,
1830
+ Zhipu,
1831
1831
  VolcesProvider,
1832
+ Volces,
1832
1833
  SiliconFlowProvider,
1833
1834
  SiliconFlowKnowledge,
1835
+ SiliconFlow,
1834
1836
  ProviderManager,
1835
1837
  OllamaProvider,
1838
+ Ollama,
1836
1839
  ModelScopeProvider,
1840
+ ModelScope,
1837
1841
  KnowledgeBase,
1838
1842
  KimiProvider,
1843
+ Kimi,
1839
1844
  DeepSeekProvider,
1845
+ DeepSeek,
1840
1846
  CustomProvider,
1847
+ Custom,
1841
1848
  ChatProviderMap,
1842
1849
  BaseChat,
1843
1850
  BailianProvider,
1851
+ BailianChat,
1852
+ AIUtils,
1844
1853
  AIConfigParser
1845
1854
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/ai",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "AI Center Services",
5
5
  "main": "index.js",
6
6
  "basename": "/root/ai-center-services",
@@ -13,6 +13,19 @@ import { Kimi } from './chat-adapter/kimi.ts';
13
13
 
14
14
  import { ChatMessage } from './core/type.ts';
15
15
 
16
+ export {
17
+ Ollama,
18
+ SiliconFlow,
19
+ Custom,
20
+ Volces,
21
+ DeepSeek,
22
+ ModelScope,
23
+ BaseChat,
24
+ BailianChat,
25
+ Zhipu,
26
+ Kimi,
27
+ ChatMessage,
28
+ }
16
29
  export const OllamaProvider = Ollama;
17
30
  export const SiliconFlowProvider = SiliconFlow;
18
31
  export const CustomProvider = Custom;
@@ -1,4 +1,3 @@
1
- import { OpenAI } from 'openai';
2
1
  import type {
3
2
  BaseChatInterface,
4
3
  ChatMessageComplete,
@@ -51,12 +50,11 @@ export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
51
50
  total_tokens: number;
52
51
  completion_tokens: number;
53
52
  responseText: string;
54
- utils: AIUtils;
53
+ utils = AIUtils;
55
54
  constructor(options: BaseChatOptions) {
56
55
  this.baseURL = options.baseURL;
57
56
  this.model = options.model;
58
57
  this.apiKey = options.apiKey;
59
- this.utils = new AIUtils();
60
58
  }
61
59
  post(url = '', opts: { headers?: Record<string, string>, data?: any } = {}) {
62
60
  let _url = url.startsWith('http') ? url : this.baseURL + url;
@@ -4,7 +4,7 @@ export class AIUtils {
4
4
  * @param str 包含 JSON 的字符串
5
5
  * @returns 解析后的对象或 null
6
6
  */
7
- extractJsonFromMarkdown(str: string): any | null {
7
+ static extractJsonFromMarkdown(str: string): any | null {
8
8
  // Try to extract JSON from ```json ... ```
9
9
  const jsonRegex = /```json\s*([\s\S]*?)\s*```/;
10
10
  const match = str.match(jsonRegex);
@@ -3,3 +3,5 @@ export * from './chat.ts';
3
3
  export * from './knowledge.ts';
4
4
 
5
5
  export * from './utils/index.ts';
6
+
7
+ export { AIUtils } from './core/utils/index.ts';