@xsai/generate-text 0.3.5 → 0.4.0-beta.2

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
@@ -1,4 +1,4 @@
1
- import { ChatOptions, CompletionStep, FinishReason, AssistantMessageResponse, Usage, Message, CompletionToolCall, CompletionToolResult } from '@xsai/shared-chat';
1
+ import { ChatOptions, CompletionStep, FinishReason, AssistantMessage, Usage, Message, CompletionToolCall, CompletionToolResult } from '@xsai/shared-chat';
2
2
 
3
3
  interface GenerateTextOptions extends ChatOptions {
4
4
  /** @default 1 */
@@ -13,7 +13,12 @@ interface GenerateTextResponse {
13
13
  choices: {
14
14
  finish_reason: FinishReason;
15
15
  index: number;
16
- message: AssistantMessageResponse;
16
+ message: Omit<AssistantMessage, 'content' | 'name'> & {
17
+ content?: string;
18
+ /** @remarks OpenAI does not support this, but LiteLLM / DeepSeek does. */
19
+ reasoning_content?: string;
20
+ };
21
+ refusal?: string;
17
22
  }[];
18
23
  created: number;
19
24
  id: string;
@@ -25,6 +30,7 @@ interface GenerateTextResponse {
25
30
  interface GenerateTextResult {
26
31
  finishReason: FinishReason;
27
32
  messages: Message[];
33
+ reasoningText?: string;
28
34
  steps: CompletionStep<true>[];
29
35
  text?: string;
30
36
  toolCalls: CompletionToolCall[];
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { trampoline, responseJSON } from '@xsai/shared';
1
+ import { trampoline, responseJSON, clean } from '@xsai/shared';
2
2
  import { chat, determineStepType, executeTool } from '@xsai/shared-chat';
3
3
 
4
4
  const rawGenerateText = async (options) => chat({
@@ -23,7 +23,10 @@ const rawGenerateText = async (options) => chat({
23
23
  stepsLength: steps.length,
24
24
  toolCallsLength: msgToolCalls.length
25
25
  });
26
- messages.push(message);
26
+ messages.push(clean({
27
+ ...message,
28
+ reasoning_content: void 0
29
+ }));
27
30
  if (finishReason === "stop" || stepType === "done") {
28
31
  const step2 = {
29
32
  finishReason,
@@ -39,6 +42,7 @@ const rawGenerateText = async (options) => chat({
39
42
  return {
40
43
  finishReason,
41
44
  messages,
45
+ reasoningText: message.reasoning_content,
42
46
  steps,
43
47
  text: message.content,
44
48
  toolCalls,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/generate-text",
3
3
  "type": "module",
4
- "version": "0.3.5",
4
+ "version": "0.4.0-beta.2",
5
5
  "description": "extra-small AI SDK.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",
@@ -29,12 +29,12 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@xsai/shared-chat": "~0.3.5",
33
- "@xsai/shared": "~0.3.5"
32
+ "@xsai/shared": "~0.4.0-beta.2",
33
+ "@xsai/shared-chat": "~0.4.0-beta.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "valibot": "^1.0.0",
37
- "@xsai/tool": "~0.3.5"
37
+ "@xsai/tool": "~0.4.0-beta.2"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "pkgroll",