@xsai/generate-text 0.3.0-beta.6 → 0.3.0-beta.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/dist/index.d.ts +5 -14
- package/dist/index.js +4 -9
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { ChatOptions,
|
|
1
|
+
import { ChatOptions, CompletionStep, FinishReason, AssistantMessageResponse, Usage, Message, CompletionToolCall, CompletionToolResult } from '@xsai/shared-chat';
|
|
2
2
|
|
|
3
3
|
interface GenerateTextOptions extends ChatOptions {
|
|
4
4
|
/** @default 1 */
|
|
5
5
|
maxSteps?: number;
|
|
6
|
-
onStepFinish?: (step:
|
|
6
|
+
onStepFinish?: (step: CompletionStep<true>) => Promise<unknown> | unknown;
|
|
7
7
|
/** @internal */
|
|
8
|
-
steps?:
|
|
8
|
+
steps?: CompletionStep<true>[];
|
|
9
9
|
/** if you want to enable stream, use `@xsai/stream-{text,object}` */
|
|
10
10
|
stream?: never;
|
|
11
|
-
tools?: Tool[];
|
|
12
11
|
}
|
|
13
12
|
interface GenerateTextResponse {
|
|
14
13
|
choices: {
|
|
@@ -26,15 +25,7 @@ interface GenerateTextResponse {
|
|
|
26
25
|
interface GenerateTextResult {
|
|
27
26
|
finishReason: FinishReason;
|
|
28
27
|
messages: Message[];
|
|
29
|
-
steps:
|
|
30
|
-
text?: string;
|
|
31
|
-
toolCalls: CompletionToolCall[];
|
|
32
|
-
toolResults: CompletionToolResult[];
|
|
33
|
-
usage: Usage;
|
|
34
|
-
}
|
|
35
|
-
interface GenerateTextStepResult {
|
|
36
|
-
finishReason: FinishReason;
|
|
37
|
-
stepType: StepType;
|
|
28
|
+
steps: CompletionStep<true>[];
|
|
38
29
|
text?: string;
|
|
39
30
|
toolCalls: CompletionToolCall[];
|
|
40
31
|
toolResults: CompletionToolResult[];
|
|
@@ -42,4 +33,4 @@ interface GenerateTextStepResult {
|
|
|
42
33
|
}
|
|
43
34
|
declare const generateText: (options: GenerateTextOptions) => Promise<GenerateTextResult>;
|
|
44
35
|
|
|
45
|
-
export { type GenerateTextOptions, type GenerateTextResponse, type GenerateTextResult,
|
|
36
|
+
export { type GenerateTextOptions, type GenerateTextResponse, type GenerateTextResult, generateText };
|
package/dist/index.js
CHANGED
|
@@ -47,20 +47,15 @@ const rawGenerateText = async (options) => chat({
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
for (const toolCall of msgToolCalls) {
|
|
50
|
-
const {
|
|
50
|
+
const { completionToolCall, completionToolResult, message: message2 } = await executeTool({
|
|
51
51
|
abortSignal: options.abortSignal,
|
|
52
52
|
messages,
|
|
53
53
|
toolCall,
|
|
54
54
|
tools: options.tools
|
|
55
55
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
messages.push({
|
|
60
|
-
content: result,
|
|
61
|
-
role: "tool",
|
|
62
|
-
tool_call_id: toolCall.id
|
|
63
|
-
});
|
|
56
|
+
toolCalls.push(completionToolCall);
|
|
57
|
+
toolResults.push(completionToolResult);
|
|
58
|
+
messages.push(message2);
|
|
64
59
|
}
|
|
65
60
|
const step = {
|
|
66
61
|
finishReason,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsai/generate-text",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.0-beta.
|
|
4
|
+
"version": "0.3.0-beta.7",
|
|
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": "~0.3.0-beta.
|
|
33
|
-
"@xsai/shared-chat": "~0.3.0-beta.
|
|
32
|
+
"@xsai/shared": "~0.3.0-beta.7",
|
|
33
|
+
"@xsai/shared-chat": "~0.3.0-beta.7"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"valibot": "^1.0.0",
|
|
37
|
-
"@xsai/tool": "~0.3.0-beta.
|
|
37
|
+
"@xsai/tool": "~0.3.0-beta.7"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "pkgroll",
|