@keo-ai/axiom 0.2.6 → 0.2.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.
@@ -13,7 +13,7 @@ exports.embed = embed;
13
13
  exports.embedBatch = embedBatch;
14
14
  const EMBEDDING_URL = 'https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings';
15
15
  const EMBEDDING_MODEL = 'text-embedding-v4';
16
- const BATCH_SIZE_LIMIT = 25; // DashScope 兼容接口的单次上限
16
+ const BATCH_SIZE_LIMIT = 10; // DashScope 兼容接口的单次上限
17
17
  function getApiKey() {
18
18
  const apiKey = process.env.BAILIAN_API_KEY;
19
19
  if (!apiKey) {
@@ -34,7 +34,7 @@ export declare class EmbeddingSearch {
34
34
  /**
35
35
  * 批量获取文本向量。
36
36
  *
37
- * 调用百炼 embedding 接口,一次最多 25 条文本。
37
+ * 调用百炼 embedding 接口,一次最多 10 条文本。
38
38
  * 返回向量的顺序与输入顺序一致。
39
39
  *
40
40
  * @example
@@ -179,7 +179,7 @@ class EmbeddingSearch {
179
179
  /**
180
180
  * 批量获取文本向量。
181
181
  *
182
- * 调用百炼 embedding 接口,一次最多 25 条文本。
182
+ * 调用百炼 embedding 接口,一次最多 10 条文本。
183
183
  * 返回向量的顺序与输入顺序一致。
184
184
  *
185
185
  * @example
@@ -129,7 +129,7 @@ function createLLMCaller(options) {
129
129
  'Content-Type': 'application/json',
130
130
  Authorization: `Bearer ${options.apiKey}`,
131
131
  },
132
- body: JSON.stringify(body),
132
+ body: (0, llm_provider_1.serializeChatRequest)(body),
133
133
  }));
134
134
  }
135
135
  catch (cause) {
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ export type { PredictConfig, PredictWithMessagesConfig } from './predict';
37
37
  * - `EmbeddingSearch.query()` — 文本 → embedding → pgvector 检索 → 可选 rerank
38
38
  * - `EmbeddingSearch.vectorSearch()` — 已有向量 → pgvector 近邻检索
39
39
  * - `EmbeddingSearch.embed()` — 单条文本转向量
40
- * - `EmbeddingSearch.batchEmbed()` — 批量文本转向量(单次最多 25 条)
40
+ * - `EmbeddingSearch.batchEmbed()` — 批量文本转向量(单次最多 10 条)
41
41
  */
42
42
  export { EmbeddingSearch } from './embedding_search';
43
43
  export type { EmbeddingSearchConfig, SearchResult } from './embedding_search';
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ Object.defineProperty(exports, "MODEL_REGISTRY", { enumerable: true, get: functi
73
73
  * - `EmbeddingSearch.query()` — 文本 → embedding → pgvector 检索 → 可选 rerank
74
74
  * - `EmbeddingSearch.vectorSearch()` — 已有向量 → pgvector 近邻检索
75
75
  * - `EmbeddingSearch.embed()` — 单条文本转向量
76
- * - `EmbeddingSearch.batchEmbed()` — 批量文本转向量(单次最多 25 条)
76
+ * - `EmbeddingSearch.batchEmbed()` — 批量文本转向量(单次最多 10 条)
77
77
  */
78
78
  var embedding_search_1 = require("./embedding_search");
79
79
  Object.defineProperty(exports, "EmbeddingSearch", { enumerable: true, get: function () { return embedding_search_1.EmbeddingSearch; } });
@@ -65,11 +65,9 @@ class BailianProvider {
65
65
  }
66
66
  if (body.model === 'kimi-k2.6') {
67
67
  const { reasoning_effort } = body, rest = __rest(body, ["reasoning_effort"]);
68
- // Kimi 默认开启思考;只有 low 显式禁用,medium/high 走默认(不传 thinking 字段)
69
- if (reasoning_effort === 'low') {
70
- return Object.assign(Object.assign({}, rest), { extra_body: Object.assign(Object.assign({}, ((_d = rest.extra_body) !== null && _d !== void 0 ? _d : {})), { thinking: { type: 'disabled' } }) });
71
- }
72
- return rest;
68
+ // 百炼兼容模式下 Kimi 默认不输出 reasoning_content,
69
+ // 需要显式传 thinking.type:low 禁用,medium/high 显式开启
70
+ return Object.assign(Object.assign({}, rest), { extra_body: Object.assign(Object.assign({}, ((_d = rest.extra_body) !== null && _d !== void 0 ? _d : {})), { thinking: { type: reasoning_effort === 'low' ? 'disabled' : 'enabled' } }) });
73
71
  }
74
72
  // deepseek-v4-pro / deepseek-v4-flash 原生支持 reasoning_effort,直接传递
75
73
  }
@@ -121,7 +119,7 @@ class BailianProvider {
121
119
  'Content-Type': 'application/json',
122
120
  Authorization: `Bearer ${this.config.apiKey}`,
123
121
  },
124
- body: JSON.stringify(body),
122
+ body: (0, index_1.serializeChatRequest)(body),
125
123
  }));
126
124
  }
127
125
  catch (cause) {
@@ -69,6 +69,12 @@ export interface OpenAIChatResponse {
69
69
  };
70
70
  model?: string;
71
71
  }
72
+ /**
73
+ * 序列化 chat completion 请求体。
74
+ * `extra_body` 是 OpenAI SDK 的客户端概念,在 HTTP 协议层面不存在,
75
+ * 必须将其内容展平到请求体顶层,否则服务端会忽略这些扩展参数。
76
+ */
77
+ export declare function serializeChatRequest(body: OpenAIChatRequest): string;
72
78
  /**
73
79
  * 发送 OpenAI 兼容的 chat completions 请求。
74
80
  * 只做 HTTP 层:构造请求、fetch、错误处理、基础解析。
@@ -12,9 +12,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  step((generator = generator.apply(thisArg, _arguments || [])).next());
13
13
  });
14
14
  };
15
+ var __rest = (this && this.__rest) || function (s, e) {
16
+ var t = {};
17
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18
+ t[p] = s[p];
19
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
20
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
21
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
22
+ t[p[i]] = s[p[i]];
23
+ }
24
+ return t;
25
+ };
15
26
  Object.defineProperty(exports, "__esModule", { value: true });
16
27
  exports.BailianProvider = exports.MODEL_REGISTRY = void 0;
28
+ exports.serializeChatRequest = serializeChatRequest;
17
29
  exports.callChatCompletions = callChatCompletions;
30
+ /**
31
+ * 序列化 chat completion 请求体。
32
+ * `extra_body` 是 OpenAI SDK 的客户端概念,在 HTTP 协议层面不存在,
33
+ * 必须将其内容展平到请求体顶层,否则服务端会忽略这些扩展参数。
34
+ */
35
+ function serializeChatRequest(body) {
36
+ const { extra_body } = body, rest = __rest(body, ["extra_body"]);
37
+ return JSON.stringify(Object.assign(Object.assign({}, rest), (extra_body !== null && extra_body !== void 0 ? extra_body : {})));
38
+ }
18
39
  /**
19
40
  * 发送 OpenAI 兼容的 chat completions 请求。
20
41
  * 只做 HTTP 层:构造请求、fetch、错误处理、基础解析。
@@ -32,7 +53,7 @@ function callChatCompletions(baseUrl_1, apiKey_1, body_1) {
32
53
  'Content-Type': 'application/json',
33
54
  Authorization: `Bearer ${apiKey}`,
34
55
  },
35
- body: JSON.stringify(body),
56
+ body: serializeChatRequest(body),
36
57
  });
37
58
  }
38
59
  catch (cause) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keo-ai/axiom",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "基于 LLM 的预测与推理库,支持多 Provider 切换",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",