@xsai/shared-chat 0.4.0-beta.9 → 0.4.0
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/dist/index.d.ts +4 -0
- package/dist/index.js +10 -8
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ interface ToolCallFunctionWithoutName {
|
|
|
56
56
|
interface AssistantMessage {
|
|
57
57
|
content?: (RefusalContentPart | TextContentPart)[] | string;
|
|
58
58
|
name?: string;
|
|
59
|
+
/** @remarks OpenAI doesn't support this, but some providers do. */
|
|
60
|
+
reasoning_content?: string;
|
|
59
61
|
refusal?: string;
|
|
60
62
|
role: 'assistant';
|
|
61
63
|
tool_calls?: ToolCall[];
|
|
@@ -169,6 +171,8 @@ interface ChatOptions extends CommonRequestOptions {
|
|
|
169
171
|
temperature?: number;
|
|
170
172
|
toolChoice?: ToolChoice;
|
|
171
173
|
tools?: Tool[];
|
|
174
|
+
/** @remarks OpenAI doesn't support this, but some providers do. */
|
|
175
|
+
topK?: number;
|
|
172
176
|
/** @default 1 */
|
|
173
177
|
topP?: number;
|
|
174
178
|
}
|
package/dist/index.js
CHANGED
|
@@ -49,30 +49,32 @@ const executeTool = async ({ abortSignal, messages, toolCall, tools }) => {
|
|
|
49
49
|
const availableToolsErrorMsg = availableTools == null || availableTools.length === 0 ? "No tools are available" : `Available tools: ${availableTools.join(", ")}`;
|
|
50
50
|
throw new Error(`Model tried to call unavailable tool "${toolCall.function.name}", ${availableToolsErrorMsg}.`);
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
if (toolCall.function.name == null)
|
|
53
|
+
throw new Error(`Missing toolCall.function.name: ${JSON.stringify(toolCall)}`);
|
|
54
|
+
if (toolCall.function.arguments == null)
|
|
55
|
+
throw new Error(`Missing toolCall.function.arguments: ${JSON.stringify(toolCall)}`);
|
|
54
56
|
const parsedArgs = JSON.parse(toolCall.function.arguments);
|
|
55
57
|
const result = wrapToolResult(await tool.execute(parsedArgs, {
|
|
56
58
|
abortSignal,
|
|
57
59
|
messages,
|
|
58
|
-
toolCallId
|
|
60
|
+
toolCallId: toolCall.id
|
|
59
61
|
}));
|
|
60
62
|
const completionToolCall = {
|
|
61
63
|
args: toolCall.function.arguments,
|
|
62
|
-
toolCallId,
|
|
64
|
+
toolCallId: toolCall.id,
|
|
63
65
|
toolCallType: toolCall.type,
|
|
64
|
-
toolName
|
|
66
|
+
toolName: toolCall.function.name
|
|
65
67
|
};
|
|
66
68
|
const completionToolResult = {
|
|
67
69
|
args: parsedArgs,
|
|
68
70
|
result,
|
|
69
|
-
toolCallId,
|
|
70
|
-
toolName
|
|
71
|
+
toolCallId: toolCall.id,
|
|
72
|
+
toolName: toolCall.function.name
|
|
71
73
|
};
|
|
72
74
|
const message = {
|
|
73
75
|
content: result,
|
|
74
76
|
role: "tool",
|
|
75
|
-
tool_call_id:
|
|
77
|
+
tool_call_id: toolCall.id
|
|
76
78
|
};
|
|
77
79
|
return {
|
|
78
80
|
completionToolCall,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsai/shared-chat",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.0
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "extra-small AI SDK.",
|
|
6
6
|
"author": "Moeru AI",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xsai/shared": "~0.4.0
|
|
32
|
+
"@xsai/shared": "~0.4.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "pkgroll"
|