wtfai 1.4.0 → 1.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/client.d.ts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +10 -37
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
package/dist/session.d.ts
CHANGED
package/dist/session.js
CHANGED
|
@@ -52,17 +52,17 @@ class WorkflowSession {
|
|
|
52
52
|
messages: data.messages
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
async send(
|
|
55
|
+
async send({ parts: inputParts, ...rest }) {
|
|
56
56
|
if (this.state.isExecuting) throw new Error('工作流正在执行中');
|
|
57
57
|
this.updateState({
|
|
58
58
|
isExecuting: true,
|
|
59
59
|
currentNodeId: void 0
|
|
60
60
|
});
|
|
61
61
|
try {
|
|
62
|
-
const
|
|
63
|
-
for (const part of
|
|
62
|
+
const parts = [];
|
|
63
|
+
for (const part of inputParts)switch(part.type){
|
|
64
64
|
case 'text':
|
|
65
|
-
|
|
65
|
+
parts.push({
|
|
66
66
|
type: 'text',
|
|
67
67
|
text: part.text
|
|
68
68
|
});
|
|
@@ -75,7 +75,7 @@ class WorkflowSession {
|
|
|
75
75
|
file,
|
|
76
76
|
url
|
|
77
77
|
});
|
|
78
|
-
|
|
78
|
+
parts.push({
|
|
79
79
|
type: 'image',
|
|
80
80
|
url: imageUrl
|
|
81
81
|
});
|
|
@@ -84,7 +84,7 @@ class WorkflowSession {
|
|
|
84
84
|
case 'document':
|
|
85
85
|
{
|
|
86
86
|
const docInfo = await this.resolveDocumentInfo(part);
|
|
87
|
-
|
|
87
|
+
parts.push({
|
|
88
88
|
type: 'document',
|
|
89
89
|
url: docInfo.url,
|
|
90
90
|
filename: docInfo.filename,
|
|
@@ -95,7 +95,7 @@ class WorkflowSession {
|
|
|
95
95
|
case 'video':
|
|
96
96
|
{
|
|
97
97
|
const videoUrl = await this.resolveVideoUrl(part);
|
|
98
|
-
|
|
98
|
+
parts.push({
|
|
99
99
|
type: 'video',
|
|
100
100
|
url: videoUrl
|
|
101
101
|
});
|
|
@@ -105,38 +105,10 @@ class WorkflowSession {
|
|
|
105
105
|
const executionInput = {
|
|
106
106
|
messages: [
|
|
107
107
|
{
|
|
108
|
-
content:
|
|
108
|
+
content: parts
|
|
109
109
|
}
|
|
110
110
|
]
|
|
111
111
|
};
|
|
112
|
-
const parts = contentParts.map((part)=>{
|
|
113
|
-
switch(part.type){
|
|
114
|
-
case 'text':
|
|
115
|
-
return {
|
|
116
|
-
type: 'text',
|
|
117
|
-
text: part.text
|
|
118
|
-
};
|
|
119
|
-
case 'image':
|
|
120
|
-
return {
|
|
121
|
-
type: 'image',
|
|
122
|
-
url: part.url
|
|
123
|
-
};
|
|
124
|
-
case 'video':
|
|
125
|
-
return {
|
|
126
|
-
type: 'video',
|
|
127
|
-
url: part.url
|
|
128
|
-
};
|
|
129
|
-
case 'document':
|
|
130
|
-
return {
|
|
131
|
-
type: 'document',
|
|
132
|
-
filename: part.filename,
|
|
133
|
-
url: part.url,
|
|
134
|
-
mimeType: part.mimeType
|
|
135
|
-
};
|
|
136
|
-
default:
|
|
137
|
-
throw new Error(`Unknown part type: ${part.type}`);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
112
|
const userMessage = {
|
|
141
113
|
type: 'human',
|
|
142
114
|
parts
|
|
@@ -151,7 +123,8 @@ class WorkflowSession {
|
|
|
151
123
|
let currentAiMessageIndex = -1;
|
|
152
124
|
this.abortController = await executeWorkflowSSE(`${this.baseUrl}/workflows/${this.workflowId}/execute`, {
|
|
153
125
|
input: executionInput,
|
|
154
|
-
threadId: this.state.threadId
|
|
126
|
+
threadId: this.state.threadId,
|
|
127
|
+
...rest
|
|
155
128
|
}, {
|
|
156
129
|
onWorkflowStart: (data)=>{
|
|
157
130
|
this.updateState({
|
package/dist/types.d.ts
CHANGED
|
@@ -89,9 +89,9 @@ export type ContentPart = {
|
|
|
89
89
|
url: string;
|
|
90
90
|
};
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* 发送消息的输入,支持传入任何扩展字段,会在发送请求时带上
|
|
93
93
|
*/
|
|
94
|
-
export interface SendInput {
|
|
94
|
+
export interface SendInput extends Record<string, any> {
|
|
95
95
|
/** 内容部件数组,按顺序传递给 LLM */
|
|
96
96
|
parts: ContentPart[];
|
|
97
97
|
}
|