@mlx-node/lm 0.0.6 → 0.0.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/README.md +71 -46
- package/dist/chat-session.d.ts +455 -0
- package/dist/chat-session.d.ts.map +1 -0
- package/dist/chat-session.js +920 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -4
- package/dist/interfaces.d.ts +11 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/models/lfm2-configs.d.ts +6 -0
- package/dist/models/lfm2-configs.d.ts.map +1 -0
- package/dist/models/lfm2-configs.js +48 -0
- package/dist/models/model-loader.d.ts +25 -4
- package/dist/models/model-loader.d.ts.map +1 -1
- package/dist/models/model-loader.js +62 -7
- package/dist/stream.d.ts +154 -26
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +346 -37
- package/dist/tools/index.d.ts +38 -11
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +38 -11
- package/dist/tools/types.d.ts +5 -25
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +5 -30
- package/package.json +3 -3
package/dist/tools/types.js
CHANGED
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
* @param description - Description of what the function does
|
|
41
41
|
* @param properties - Object defining the function parameters (will be JSON stringified)
|
|
42
42
|
* @param required - Array of required parameter names
|
|
43
|
-
* @returns A properly formatted ToolDefinition ready
|
|
43
|
+
* @returns A properly formatted ToolDefinition ready to pass via `ChatConfig.tools`
|
|
44
|
+
* on `ChatSession.send()` / `sendToolResult()`.
|
|
44
45
|
*
|
|
45
46
|
* @example
|
|
46
47
|
* ```typescript
|
|
@@ -49,12 +50,12 @@
|
|
|
49
50
|
* 'Get weather information for a location',
|
|
50
51
|
* {
|
|
51
52
|
* location: { type: 'string', description: 'City name' },
|
|
52
|
-
* units: { type: 'string', enum: ['celsius', 'fahrenheit'] }
|
|
53
|
+
* units: { type: 'string', enum: ['celsius', 'fahrenheit'] },
|
|
53
54
|
* },
|
|
54
|
-
* ['location']
|
|
55
|
+
* ['location'],
|
|
55
56
|
* );
|
|
56
57
|
*
|
|
57
|
-
* const result = await
|
|
58
|
+
* const result = await session.send(userPrompt, { config: { tools: [weatherTool] } });
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
61
|
export function createToolDefinition(name, description, properties, required) {
|
|
@@ -73,29 +74,3 @@ export function createToolDefinition(name, description, properties, required) {
|
|
|
73
74
|
},
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Format a tool response for inclusion in a message
|
|
78
|
-
*
|
|
79
|
-
* Creates a properly formatted tool response string that can be used
|
|
80
|
-
* in tool messages when continuing a conversation after a tool call.
|
|
81
|
-
*
|
|
82
|
-
* @param content - The response content (will be JSON stringified if object)
|
|
83
|
-
* @returns Formatted tool response string wrapped in `<tool_response>` tags
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* // After executing a tool call from model.chat()
|
|
88
|
-
* const toolResult = await executeMyTool(call.arguments);
|
|
89
|
-
* const responseMessage = {
|
|
90
|
-
* role: 'user',
|
|
91
|
-
* content: formatToolResponse(toolResult)
|
|
92
|
-
* };
|
|
93
|
-
* const finalResult = await model.chat([...messages, responseMessage]);
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
export function formatToolResponse(content) {
|
|
97
|
-
const contentStr = typeof content === 'string' ? content : JSON.stringify(content);
|
|
98
|
-
// Qwen3/3.5 expects <tool_response> XML wrapping for tool results.
|
|
99
|
-
// Other model families may require a different format.
|
|
100
|
-
return `<tool_response>\n${contentStr}\n</tool_response>`;
|
|
101
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlx-node/lm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"homepage": "https://github.com/mlx-node/mlx-node",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/mlx-node/mlx-node/issues"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"test": "vite test run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@mlx-node/core": "0.0.
|
|
31
|
+
"@mlx-node/core": "0.0.7"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "
|
|
34
|
+
"@types/node": "^25.6.0"
|
|
35
35
|
}
|
|
36
36
|
}
|