@keo-ai/axiom 0.1.5 → 0.1.6

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/README.md CHANGED
@@ -179,6 +179,7 @@ for await (const chunk of LLM.streamPredict({ model: 'qwen3.7-max', prompt: '讲
179
179
  - `deepseek-v4-pro`
180
180
  - `deepseek-v4-flash`
181
181
  - `kimi-k2.6`
182
+ - `glm-5.1`
182
183
  - `qwen-vl-plus`
183
184
 
184
185
  > 目前所有模型均路由到百炼 Provider。后续接入其他厂商时,通过 `MODEL_REGISTRY` 扩展映射即可。
@@ -528,6 +529,7 @@ const result = await promise;
528
529
  | `temperature` | `number` | — | 采样温度,范围 0~2 |
529
530
  | `topP` | `number` | — | 核采样概率阈值,范围 0~1 |
530
531
  | `reasoningEffort` | `'low' \| 'medium' \| 'high'` | — | 推理深度。仅部分模型支持(如 o1、o3) |
532
+ | `responseFormat` | `'text' \| 'json'` | — | 响应格式。`json` 时模型输出会被内部 `JSON.parse`,解析结果存到 `parsedContent` |
531
533
 
532
534
  ### 返回结果
533
535
 
@@ -535,8 +537,9 @@ const result = await promise;
535
537
  interface LoopResult {
536
538
  messages: Message[]; // 完整的对话历史
537
539
  harness: HarnessRecord[]; // 执行历史
538
- finalContent: string | null; // 最终回复内容
540
+ finalContent: string | null; // 最终回复内容(原始字符串)
539
541
  turns: number; // 实际执行轮数
542
+ parsedContent?: unknown; // 仅当 responseFormat === 'json' 时存在,JSON.parse 后的结果
540
543
  }
541
544
  ```
542
545
 
@@ -81,6 +81,7 @@ function runLoop(config) {
81
81
  maxTokens: config.maxTokens,
82
82
  topP: config.topP,
83
83
  reasoningEffort: config.reasoningEffort,
84
+ responseFormat: config.responseFormat,
84
85
  });
85
86
  // 第六步:检查 LLM 回复
86
87
  if (!llmResponse.tool_calls || llmResponse.tool_calls.length === 0) {
@@ -88,12 +89,21 @@ function runLoop(config) {
88
89
  role: 'assistant',
89
90
  content: (_f = llmResponse.content) !== null && _f !== void 0 ? _f : '',
90
91
  });
91
- return {
92
+ const result = {
92
93
  messages,
93
94
  harness: harness.getAll(),
94
95
  finalContent: llmResponse.content,
95
96
  turns: turn,
96
97
  };
98
+ if (config.responseFormat === 'json' && llmResponse.content) {
99
+ try {
100
+ Object.assign(result, { parsedContent: JSON.parse(llmResponse.content) });
101
+ }
102
+ catch (_h) {
103
+ // JSON 解析失败时保持 parsedContent 未定义,finalContent 仍为原始字符串
104
+ }
105
+ }
106
+ return result;
97
107
  }
98
108
  // 有 tool_calls,将 assistant message 加入 Messages
99
109
  messages.push({
@@ -54,6 +54,9 @@ function createLLMCaller(options) {
54
54
  max_tokens: callOptions === null || callOptions === void 0 ? void 0 : callOptions.maxTokens,
55
55
  top_p: callOptions === null || callOptions === void 0 ? void 0 : callOptions.topP,
56
56
  tools: tools.length > 0 ? toOpenAITools(tools) : undefined,
57
+ response_format: (callOptions === null || callOptions === void 0 ? void 0 : callOptions.responseFormat)
58
+ ? { type: callOptions.responseFormat === 'json' ? 'json_object' : 'text' }
59
+ : undefined,
57
60
  }, 'llm');
58
61
  const choice = data.choices[0];
59
62
  return {
@@ -144,6 +144,7 @@ export interface LLMCallOptions {
144
144
  readonly maxTokens?: number;
145
145
  readonly topP?: number;
146
146
  readonly reasoningEffort?: 'low' | 'medium' | 'high';
147
+ readonly responseFormat?: 'text' | 'json';
147
148
  }
148
149
  /**
149
150
  * LLM 调用接口。由外部注入,Loop 内部不绑定具体 Provider。
@@ -184,6 +185,8 @@ export interface LoopConfig {
184
185
  readonly topP?: number;
185
186
  /** 推理深度。仅部分模型支持 */
186
187
  readonly reasoningEffort?: 'low' | 'medium' | 'high';
188
+ /** 响应格式。默认 text */
189
+ readonly responseFormat?: 'text' | 'json';
187
190
  }
188
191
  /**
189
192
  * 待审批信息。
@@ -203,4 +206,6 @@ export interface LoopResult {
203
206
  readonly finalContent: string | null;
204
207
  readonly turns: number;
205
208
  readonly pendingApproval?: PendingApprovalInfo;
209
+ /** 当 responseFormat === 'json' 时,finalContent 经 JSON.parse 后的结果 */
210
+ readonly parsedContent?: unknown;
206
211
  }
@@ -170,5 +170,6 @@ BailianProvider.SUPPORTED_MODELS = new Set([
170
170
  'deepseek-v4-pro',
171
171
  'deepseek-v4-flash',
172
172
  'kimi-k2.6',
173
+ 'glm-5.1',
173
174
  'qwen-vl-plus',
174
175
  ]);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 支持的模型枚举。项目层通过此枚举选择模型,Axiom 内部路由到对应 Provider。
3
3
  */
4
- export type Model = 'qwen3.7-max' | 'qwen-plus' | 'qwen-turbo' | 'qwq-plus' | 'deepseek-v4-pro' | 'deepseek-v4-flash' | 'kimi-k2.6' | 'qwen-vl-plus';
4
+ export type Model = 'qwen3.7-max' | 'qwen-plus' | 'qwen-turbo' | 'qwq-plus' | 'deepseek-v4-pro' | 'deepseek-v4-flash' | 'kimi-k2.6' | 'glm-5.1' | 'qwen-vl-plus';
5
5
  /** 模型到 Provider 的映射配置 */
6
6
  export interface ModelConfig {
7
7
  readonly model: string;
@@ -13,5 +13,6 @@ exports.MODEL_REGISTRY = {
13
13
  'deepseek-v4-pro': [{ model: 'deepseek-v4-pro', provider: 'bailian' }],
14
14
  'deepseek-v4-flash': [{ model: 'deepseek-v4-flash', provider: 'bailian' }],
15
15
  'kimi-k2.6': [{ model: 'kimi-k2.6', provider: 'bailian' }],
16
+ 'glm-5.1': [{ model: 'glm-5.1', provider: 'bailian' }],
16
17
  'qwen-vl-plus': [{ model: 'qwen-vl-plus', provider: 'bailian' }],
17
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keo-ai/axiom",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "基于 LLM 的预测与推理库,支持多 Provider 切换",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",