@atlisp/agent 0.1.14 → 0.1.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.
package/config.js CHANGED
@@ -135,7 +135,7 @@ function loadConfig() {
135
135
  saveDefaultConfig(jsonPath);
136
136
  }
137
137
 
138
- let merged = deepMerge(getDefaultConfig(), fileConfig);
138
+ let merged = deepMerge(getDefaultConfig(), fileConfig || {});
139
139
  return merged;
140
140
  }
141
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/agent",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "AI Agent for @lisp - Connects to MCP Server for CAD operations",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,12 +1,14 @@
1
1
  import { VllmProvider } from './vllm.js';
2
2
  import { DeepseekProvider } from './deepseek.js';
3
3
  import { OpenAIProvider } from './openai.js';
4
+ import { MinimaxProvider } from './minimax.js';
4
5
  import { getLlmConfig } from '../config.js';
5
6
 
6
7
  const PROVIDERS = {
7
8
  vllm: VllmProvider,
8
9
  deepseek: DeepseekProvider,
9
10
  openai: OpenAIProvider,
11
+ minimax: MinimaxProvider,
10
12
  };
11
13
 
12
14
  export function createProvider(config = {}) {
@@ -0,0 +1,68 @@
1
+ import { getLlmConfig } from '../config.js';
2
+
3
+ export class MinimaxProvider {
4
+ constructor(config = {}) {
5
+ this.config = { ...getLlmConfig(), ...config };
6
+ this.baseURL = this.config.baseURL || 'https://api.minimax.chat/v1';
7
+ this.model = this.config.model || 'abab6.5s-chat';
8
+ this.apiKey = this.config.apiKey;
9
+ this.temperature = this.config.temperature;
10
+ this.maxTokens = this.config.maxTokens;
11
+ }
12
+
13
+ async chat(messages, options = {}) {
14
+ const url = `${this.baseURL}/text/chatcompletion`;
15
+ const body = {
16
+ model: this.model,
17
+ messages: messages,
18
+ temperature: options.temperature ?? this.temperature,
19
+ max_tokens: options.maxTokens ?? this.maxTokens,
20
+ };
21
+
22
+ const headers = {
23
+ 'Content-Type': 'application/json',
24
+ };
25
+
26
+ if (this.apiKey) {
27
+ headers['Authorization'] = `Bearer ${this.apiKey}`;
28
+ }
29
+
30
+ try {
31
+ const response = await fetch(url, {
32
+ method: 'POST',
33
+ headers: headers,
34
+ body: JSON.stringify(body),
35
+ });
36
+
37
+ if (!response.ok) {
38
+ const errorText = await response.text();
39
+ throw new Error(`Minimax API error: ${response.status} ${errorText}`);
40
+ }
41
+
42
+ const data = await response.json();
43
+
44
+ if (data.base_resp?.status_code !== 0 && data.base_resp?.status_code !== 200) {
45
+ const errMsg = data.base_resp?.status_msg || 'Unknown error';
46
+ throw new Error(`Minimax API error: ${errMsg}`);
47
+ }
48
+
49
+ if (data.reply) return data.reply;
50
+ if (data.choices && data.choices.length > 0) {
51
+ return data.choices[0].message.content;
52
+ }
53
+
54
+ throw new Error('No response content from Minimax: ' + JSON.stringify(data));
55
+ } catch (error) {
56
+ if (error.message.includes('fetch')) {
57
+ throw new Error(`无法连接到 Minimax API: ${error.message}`);
58
+ }
59
+ throw error;
60
+ }
61
+ }
62
+
63
+ getName() {
64
+ return 'minimax';
65
+ }
66
+ }
67
+
68
+ export default MinimaxProvider;