@xsai/shared-chat 0.4.0-beta.9 → 0.4.1

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 CHANGED
@@ -56,6 +56,10 @@ interface ToolCallFunctionWithoutName {
56
56
  interface AssistantMessage {
57
57
  content?: (RefusalContentPart | TextContentPart)[] | string;
58
58
  name?: string;
59
+ /** @see {@link https://cookbook.openai.com/articles/gpt-oss/handle-raw-cot#chat-completions-api} */
60
+ reasoning?: string;
61
+ /** @remarks OpenAI doesn't support this, but some providers do. */
62
+ reasoning_content?: string;
59
63
  refusal?: string;
60
64
  role: 'assistant';
61
65
  tool_calls?: ToolCall[];
@@ -159,6 +163,8 @@ interface ChatOptions extends CommonRequestOptions {
159
163
  * @default 0
160
164
  */
161
165
  presencePenalty?: number;
166
+ /** Constrains effort on reasoning for reasoning models. */
167
+ reasoningEffort?: 'high' | 'medium' | 'minimal' | 'none' | 'xhigh';
162
168
  seed?: number;
163
169
  /** up to 4 sequences where the API will stop generating further tokens. */
164
170
  stop?: [string, string, string, string] | [string, string, string] | [string, string] | [string] | string;
@@ -167,8 +173,12 @@ interface ChatOptions extends CommonRequestOptions {
167
173
  * @default 1
168
174
  */
169
175
  temperature?: number;
176
+ /** Controls which (if any) tool is called by the model. */
170
177
  toolChoice?: ToolChoice;
178
+ /** A list of tools the model may call. */
171
179
  tools?: Tool[];
180
+ /** @remarks OpenAI doesn't support this, but some providers do. */
181
+ topK?: number;
172
182
  /** @default 1 */
173
183
  topP?: number;
174
184
  }
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
- const toolCallId = toolCall.id;
53
- const toolName = toolCall.function.name;
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: toolCallId
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-beta.9",
4
+ "version": "0.4.1",
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-beta.9"
32
+ "@xsai/shared": "~0.4.1"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "pkgroll"