@cloudbase/agent-adapter-adp 0.0.13 → 0.0.15
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/CHANGELOG.md +18 -0
- package/README.md +41 -27
- package/dist/index.d.mts +195 -3
- package/dist/index.d.ts +195 -3
- package/dist/index.js +112 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @cloudbase/agent-adapter-adp
|
|
2
2
|
|
|
3
|
+
## 1.0.1-alpha.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- alpha release 0.1.2-alpha.1
|
|
8
|
+
- Update all public packages to version 0.1.2-alpha.1
|
|
9
|
+
- Trigger automated alpha release workflow
|
|
10
|
+
- Includes latest features and improvements
|
|
11
|
+
|
|
12
|
+
## 1.0.1-alpha.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- alpha release 0.1.2-alpha.1
|
|
17
|
+
- Update all public packages to version 0.1.2-alpha.1
|
|
18
|
+
- Trigger automated alpha release workflow
|
|
19
|
+
- Includes latest features and improvements
|
|
20
|
+
|
|
3
21
|
## 1.0.1-alpha.6
|
|
4
22
|
|
|
5
23
|
### Features
|
package/README.md
CHANGED
|
@@ -12,8 +12,8 @@ npm install @cloudbase/agent-agents @cloudbase/agent-adapter-adp
|
|
|
12
12
|
|
|
13
13
|
- **AdpAgent**: Agent implementation that connects to Tencent Cloud ADP chatbot services
|
|
14
14
|
- **Streaming Support**: Real-time SSE (Server-Sent Events) streaming responses
|
|
15
|
+
- **Thinking Events**: Support for thinking/reasoning process events from the model
|
|
15
16
|
- **Workflow Integration**: Support for ADP workflows with tool call events
|
|
16
|
-
- **Document Parsing**: Built-in document extraction support (PDF, Word, PPT, TXT)
|
|
17
17
|
- **Custom Variables**: Pass custom parameters to workflows and knowledge base
|
|
18
18
|
|
|
19
19
|
## Environment Variables
|
|
@@ -21,9 +21,10 @@ npm install @cloudbase/agent-agents @cloudbase/agent-adapter-adp
|
|
|
21
21
|
Configure the following environment variables:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
ADP_APP_KEY=your-adp-app-key
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
ADP_APP_KEY=your-adp-app-key # ADP application key, required if not passed in config when creating the agent
|
|
25
|
+
TENCENTCLOUD_SECRETID=your-tencent-cloud-secret-id
|
|
26
|
+
TENCENTCLOUD_SECRETKEY=your-tencent-cloud-secret-key
|
|
27
|
+
TENCENTCLOUD_SESSIONTOKEN=your-tencent-cloud-session-token # Optional, for temporary credentials
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
## Usage
|
|
@@ -39,7 +40,6 @@ const agent = new AdpAgent({
|
|
|
39
40
|
description: "A Tencent Cloud ADP chatbot agent",
|
|
40
41
|
adpConfig: {
|
|
41
42
|
appKey: process.env.ADP_APP_KEY, // Optional if set in env
|
|
42
|
-
historyCount: 30, // Number of history messages to retrieve
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
```
|
|
@@ -54,16 +54,17 @@ const agent = new AdpAgent({
|
|
|
54
54
|
description: "An ADP agent with inline credentials",
|
|
55
55
|
adpConfig: {
|
|
56
56
|
appKey: "your-app-key", // Optional if ADP_APP_KEY env is set
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
credential: {
|
|
58
|
+
secretId: "your-secret-id", // Optional if TENCENTCLOUD_SECRETID env is set
|
|
59
|
+
secretKey: "your-secret-key", // Optional if TENCENTCLOUD_SECRETKEY env is set
|
|
60
|
+
token: "your-session-token", // Optional if TENCENTCLOUD_SESSIONTOKEN env is set
|
|
61
|
+
},
|
|
59
62
|
},
|
|
60
63
|
});
|
|
61
64
|
```
|
|
62
65
|
|
|
63
66
|
### With Custom Request Options
|
|
64
67
|
|
|
65
|
-
For further information, please check the [official documentation](https://cloud.tencent.com/document/product/1759/105561#ba7e0c00-8616-468c-8734-6cc13b4c51af).
|
|
66
|
-
|
|
67
68
|
```typescript
|
|
68
69
|
import { AdpAgent } from "@cloudbase/agent-adapter-adp";
|
|
69
70
|
|
|
@@ -73,11 +74,14 @@ const agent = new AdpAgent({
|
|
|
73
74
|
adpConfig: {
|
|
74
75
|
appKey: "your-app-key",
|
|
75
76
|
request: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
baseUrl: "https://wss.lke.cloud.tencent.com", // Custom base URL (leave empty for default value)
|
|
78
|
+
endpoint: "/v1/qbot/chat/sse", // Custom endpoint (leave empty for default value)
|
|
79
|
+
body: {
|
|
80
|
+
modelName: "gpt-4", // Specify model
|
|
81
|
+
searchNetwork: "enable", // Enable web search
|
|
82
|
+
workflowStatus: "enable", // Enable workflows
|
|
83
|
+
systemRole: "You are a helpful assistant", // Custom system prompt
|
|
84
|
+
},
|
|
81
85
|
},
|
|
82
86
|
},
|
|
83
87
|
});
|
|
@@ -102,7 +106,8 @@ const observable = agent.run({
|
|
|
102
106
|
},
|
|
103
107
|
],
|
|
104
108
|
forwardedProps: {
|
|
105
|
-
|
|
109
|
+
// Request body options
|
|
110
|
+
visitorBizId: "user-123", // Visitor (User) ID
|
|
106
111
|
customVariables: {
|
|
107
112
|
key1: "value1",
|
|
108
113
|
},
|
|
@@ -135,20 +140,30 @@ Configuration options for the ADP adapter.
|
|
|
135
140
|
```typescript
|
|
136
141
|
interface AdpConfig {
|
|
137
142
|
appKey?: string; // ADP application key (optional if ADP_APP_KEY env is set)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
credential?: {
|
|
144
|
+
secretId?: string; // Tencent Cloud secret ID (optional if TENCENTCLOUD_SECRETID env is set)
|
|
145
|
+
secretKey?: string; // Tencent Cloud secret key (optional if TENCENTCLOUD_SECRETKEY env is set)
|
|
146
|
+
token?: string; // Session token (optional if TENCENTCLOUD_SESSIONTOKEN env is set)
|
|
147
|
+
};
|
|
148
|
+
historyCount?: number; // Number of history messages to retrieve (reserved)
|
|
149
|
+
request?: {
|
|
150
|
+
baseUrl?: string; // Base URL for ADP API (default: https://wss.lke.cloud.tencent.com)
|
|
151
|
+
endpoint?: string; // API endpoint (default: /v1/qbot/chat/sse)
|
|
152
|
+
body?: Partial<AdpChatRequest>; // Additional request body options
|
|
153
|
+
};
|
|
142
154
|
}
|
|
143
155
|
```
|
|
144
156
|
|
|
145
157
|
### AdpChatRequest Options
|
|
146
158
|
|
|
159
|
+
For further information, please check the [ADP product documentation](https://cloud.tencent.com/document/product/1759/105561#ba7e0c00-8616-468c-8734-6cc13b4c51af).
|
|
160
|
+
|
|
147
161
|
```typescript
|
|
148
162
|
interface AdpChatRequest {
|
|
149
163
|
streamingThrottle?: number; // Stream reply frequency control
|
|
150
164
|
customVariables?: Record<string, string>; // Custom parameters for workflows
|
|
151
165
|
systemRole?: string; // Role instructions (prompt)
|
|
166
|
+
incremental?: boolean; // Whether to output content incrementally
|
|
152
167
|
searchNetwork?: "" | "enable" | "disable"; // Web search toggle
|
|
153
168
|
modelName?: string; // Specify model name
|
|
154
169
|
stream?: "" | "enable" | "disable"; // Streaming toggle
|
|
@@ -156,23 +171,22 @@ interface AdpChatRequest {
|
|
|
156
171
|
}
|
|
157
172
|
```
|
|
158
173
|
|
|
159
|
-
|
|
174
|
+
### Supported Events
|
|
160
175
|
|
|
161
|
-
The adapter
|
|
176
|
+
The adapter emits the following AG-UI events:
|
|
162
177
|
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
178
|
+
- `RUN_STARTED` / `RUN_FINISHED` / `RUN_ERROR` - Run lifecycle events
|
|
179
|
+
- `TEXT_MESSAGE_CHUNK` (`TEXT_MESSAGE_START` / `TEXT_MESSAGE_CONTENT` / `TEXT_MESSAGE_END`) - Streaming text response chunks
|
|
180
|
+
- `THINKING_START` / `THINKING_END` - Thinking process boundaries
|
|
181
|
+
- `THINKING_TEXT_MESSAGE_START` / `THINKING_TEXT_MESSAGE_CONTENT` / `THINKING_TEXT_MESSAGE_END` - Thinking content events
|
|
182
|
+
- `TOOL_CALL_START` / `TOOL_CALL_ARGS` / `TOOL_CALL_END` / `TOOL_CALL_RESULT` - Workflow tool call events
|
|
167
183
|
|
|
168
184
|
## Requirements
|
|
169
185
|
|
|
170
|
-
- `@cloudbase/agent-agents`: Core agent functionality
|
|
171
186
|
- `@ag-ui/client`: AG-UI client protocol
|
|
172
187
|
- `axios`: HTTP client for API requests
|
|
173
188
|
- `rxjs`: Reactive extensions for JavaScript
|
|
174
189
|
- `tencentcloud-sdk-nodejs-lke`: Tencent Cloud LKE SDK
|
|
175
|
-
- `cos-nodejs-sdk-v5`: Tencent Cloud Object Storage SDK
|
|
176
190
|
|
|
177
191
|
## Related Resources
|
|
178
192
|
|
package/dist/index.d.mts
CHANGED
|
@@ -54,7 +54,11 @@ interface AdpChatRequest {
|
|
|
54
54
|
[key: string]: any;
|
|
55
55
|
}
|
|
56
56
|
type AdpConfig = {
|
|
57
|
-
request?:
|
|
57
|
+
request?: {
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
endpoint?: string;
|
|
60
|
+
body?: Partial<AdpChatRequest>;
|
|
61
|
+
};
|
|
58
62
|
historyCount?: number;
|
|
59
63
|
appKey?: string;
|
|
60
64
|
credential?: {
|
|
@@ -63,14 +67,202 @@ type AdpConfig = {
|
|
|
63
67
|
token?: string;
|
|
64
68
|
};
|
|
65
69
|
};
|
|
70
|
+
type AdpChunk = {
|
|
71
|
+
type: "reply";
|
|
72
|
+
payload: ReplyEvent;
|
|
73
|
+
message_id: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "thought";
|
|
76
|
+
payload: ThoughtEvent;
|
|
77
|
+
message_id: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: "token_stat";
|
|
80
|
+
payload: TokenStatEvent;
|
|
81
|
+
message_id: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: "reference";
|
|
84
|
+
payload: ReferenceEvent;
|
|
85
|
+
message_id: string;
|
|
86
|
+
} | {
|
|
87
|
+
type: "error";
|
|
88
|
+
error: ErrorInfo;
|
|
89
|
+
};
|
|
90
|
+
interface ReplyEvent {
|
|
91
|
+
request_id: string;
|
|
92
|
+
content: string;
|
|
93
|
+
file_infos: FileInfo[];
|
|
94
|
+
record_id: string;
|
|
95
|
+
related_record_id: string;
|
|
96
|
+
session_id: string;
|
|
97
|
+
is_from_self: boolean;
|
|
98
|
+
can_rating: boolean;
|
|
99
|
+
timestamp: number;
|
|
100
|
+
is_final: boolean;
|
|
101
|
+
is_evil: boolean;
|
|
102
|
+
is_llm_generated: boolean;
|
|
103
|
+
reply_method: ReplyMethod;
|
|
104
|
+
knowledge?: Knowledge[];
|
|
105
|
+
option_cards?: string[];
|
|
106
|
+
custom_params?: string[];
|
|
107
|
+
task_flow?: TaskFlow;
|
|
108
|
+
work_flow?: WorkFlow;
|
|
109
|
+
quote_infos?: QuoteInfo[];
|
|
110
|
+
}
|
|
111
|
+
declare enum ReplyMethod {
|
|
112
|
+
LLM_REPLY = 1,
|
|
113
|
+
UNKNOWN_QUESTION_REPLY = 2,
|
|
114
|
+
REJECT_QUESTION_REPLY = 3,
|
|
115
|
+
SENSITIVE_REPLY = 4,
|
|
116
|
+
ADOPTED_QA_PRIORITY_REPLY = 5,
|
|
117
|
+
WELCOME_REPLY = 6,
|
|
118
|
+
CONCURRENCY_LIMIT_REPLY = 7,
|
|
119
|
+
GLOBAL_INTERVENTION_KNOWLEDGE = 8,
|
|
120
|
+
TASK_FLOW_REPLY = 9,
|
|
121
|
+
TASK_FLOW_ANSWER = 10,
|
|
122
|
+
SEARCH_ENGINE_REPLY = 11,
|
|
123
|
+
KNOWLEDGE_POLISHED_REPLY = 12,
|
|
124
|
+
IMAGE_UNDERSTANDING_REPLY = 13,
|
|
125
|
+
REALTIME_DOCUMENT_REPLY = 14,
|
|
126
|
+
CLARIFICATION_CONFIRMATION_REPLY = 15,
|
|
127
|
+
WORKFLOW_REPLY = 16,
|
|
128
|
+
WORKFLOW_EXECUTION_END = 17,
|
|
129
|
+
AGENT_REPLY = 18,
|
|
130
|
+
MULTI_INTENT_REPLY = 19
|
|
131
|
+
}
|
|
132
|
+
interface Knowledge {
|
|
133
|
+
id: string;
|
|
134
|
+
type: number;
|
|
135
|
+
seg_id?: string;
|
|
136
|
+
}
|
|
137
|
+
interface TaskFlow {
|
|
138
|
+
task_flow_name: string;
|
|
139
|
+
task_flow_id: string;
|
|
140
|
+
query_rewrite: string;
|
|
141
|
+
hit_intent: string;
|
|
142
|
+
slot_info: Record<string, any>;
|
|
143
|
+
api_response: Record<string, any>;
|
|
144
|
+
type: number;
|
|
145
|
+
}
|
|
146
|
+
interface WorkFlow {
|
|
147
|
+
workflow_name: string;
|
|
148
|
+
workflow_id: string;
|
|
149
|
+
workflow_run_id: string;
|
|
150
|
+
option_cards: string[];
|
|
151
|
+
current_node: CurrentNode;
|
|
152
|
+
outputs: Array<string>;
|
|
153
|
+
}
|
|
154
|
+
declare enum CurrentNodeStatus {
|
|
155
|
+
Pending = 0,
|
|
156
|
+
Running = 1,
|
|
157
|
+
Succeeded = 2,
|
|
158
|
+
Failed = 3
|
|
159
|
+
}
|
|
160
|
+
interface CurrentNode {
|
|
161
|
+
NodeID: string;
|
|
162
|
+
NodeType: number;
|
|
163
|
+
NodeName: string;
|
|
164
|
+
Status: CurrentNodeStatus;
|
|
165
|
+
Input: string;
|
|
166
|
+
Output: string;
|
|
167
|
+
TaskOutput: string;
|
|
168
|
+
FailMessage: string;
|
|
169
|
+
CostMilliSeconds: string;
|
|
170
|
+
Reply: string;
|
|
171
|
+
BelongNodeID: string;
|
|
172
|
+
StatisticInfo: StatisticInfo;
|
|
173
|
+
}
|
|
174
|
+
interface StatisticInfo {
|
|
175
|
+
ModelName: string;
|
|
176
|
+
FirstTokenCost: number;
|
|
177
|
+
TotalCost: number;
|
|
178
|
+
InputTokens: number;
|
|
179
|
+
OutputTokens: number;
|
|
180
|
+
TotalTokens: number;
|
|
181
|
+
}
|
|
182
|
+
interface QuoteInfo {
|
|
183
|
+
index: number;
|
|
184
|
+
position: number;
|
|
185
|
+
}
|
|
186
|
+
interface TokenStatEvent {
|
|
187
|
+
session_id: string;
|
|
188
|
+
request_id: string;
|
|
189
|
+
record_id: string;
|
|
190
|
+
status_summary: "processing" | "success" | "failed";
|
|
191
|
+
status_summary_title: string;
|
|
192
|
+
elapsed: number;
|
|
193
|
+
token_count: number;
|
|
194
|
+
procedures: TokenStatProcedure[];
|
|
195
|
+
}
|
|
196
|
+
interface TokenStatProcedure {
|
|
197
|
+
name: string;
|
|
198
|
+
title: string;
|
|
199
|
+
status: "processing" | "success" | "failed";
|
|
200
|
+
input_count: number;
|
|
201
|
+
output_count: number;
|
|
202
|
+
count: number;
|
|
203
|
+
}
|
|
204
|
+
interface ReferenceEvent {
|
|
205
|
+
record_id: string;
|
|
206
|
+
references: Reference[];
|
|
207
|
+
}
|
|
208
|
+
interface Reference {
|
|
209
|
+
id: string | number;
|
|
210
|
+
type: number;
|
|
211
|
+
url?: string;
|
|
212
|
+
name: string;
|
|
213
|
+
doc_id: number;
|
|
214
|
+
doc_biz_id: number;
|
|
215
|
+
doc_name: string;
|
|
216
|
+
qa_biz_id: string;
|
|
217
|
+
}
|
|
218
|
+
interface ErrorInfo {
|
|
219
|
+
code: number;
|
|
220
|
+
message: string;
|
|
221
|
+
}
|
|
222
|
+
interface ThoughtEvent {
|
|
223
|
+
elapsed: number;
|
|
224
|
+
is_workflow: boolean;
|
|
225
|
+
procedures: ThoughtProcedure[];
|
|
226
|
+
record_id: string;
|
|
227
|
+
request_id: string;
|
|
228
|
+
session_id: string;
|
|
229
|
+
trace_id: string;
|
|
230
|
+
workflow_name: string;
|
|
231
|
+
}
|
|
232
|
+
interface ThoughtProcedure {
|
|
233
|
+
debugging: Debugging;
|
|
234
|
+
index: number;
|
|
235
|
+
name: string;
|
|
236
|
+
title: string;
|
|
237
|
+
status: "processing" | "success" | "failed";
|
|
238
|
+
icon: string;
|
|
239
|
+
switch: string;
|
|
240
|
+
workflow_name: string;
|
|
241
|
+
plugin_type: number;
|
|
242
|
+
elapsed: number;
|
|
243
|
+
}
|
|
244
|
+
interface Debugging {
|
|
245
|
+
content: string;
|
|
246
|
+
}
|
|
66
247
|
|
|
248
|
+
declare class AdpAgentError extends Error {
|
|
249
|
+
code?: string;
|
|
250
|
+
constructor(message: string, code?: string);
|
|
251
|
+
}
|
|
67
252
|
declare class AdpAgent extends AbstractAgent {
|
|
68
|
-
private adpConfig;
|
|
69
253
|
private reqAppClient;
|
|
70
254
|
private reqLkeClient;
|
|
255
|
+
protected adpConfig: AdpConfig;
|
|
71
256
|
constructor(config: AgentConfig & {
|
|
72
257
|
adpConfig: AdpConfig;
|
|
73
258
|
});
|
|
259
|
+
generateRequestBody({ message, fileInfos, runId, threadId, forwardedProps, }: {
|
|
260
|
+
message: string;
|
|
261
|
+
fileInfos: FileInfo[];
|
|
262
|
+
runId: string;
|
|
263
|
+
threadId: string;
|
|
264
|
+
forwardedProps: Record<string, string>;
|
|
265
|
+
}): AdpChatRequest;
|
|
74
266
|
run(input: RunAgentInput): Observable<{
|
|
75
267
|
type: EventType;
|
|
76
268
|
timestamp?: number | undefined;
|
|
@@ -79,4 +271,4 @@ declare class AdpAgent extends AbstractAgent {
|
|
|
79
271
|
private _run;
|
|
80
272
|
}
|
|
81
273
|
|
|
82
|
-
export { AdpAgent };
|
|
274
|
+
export { AdpAgent, AdpAgentError, type AdpChatRequest, type AdpChunk, type AdpConfig, type CurrentNode, CurrentNodeStatus, type Debugging, type ErrorInfo, type FileInfo, type Knowledge, type QuoteInfo, type Reference, type ReferenceEvent, type ReplyEvent, ReplyMethod, type StatisticInfo, type TaskFlow, type ThoughtEvent, type ThoughtProcedure, type TokenStatEvent, type TokenStatProcedure, type WorkFlow };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,11 @@ interface AdpChatRequest {
|
|
|
54
54
|
[key: string]: any;
|
|
55
55
|
}
|
|
56
56
|
type AdpConfig = {
|
|
57
|
-
request?:
|
|
57
|
+
request?: {
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
endpoint?: string;
|
|
60
|
+
body?: Partial<AdpChatRequest>;
|
|
61
|
+
};
|
|
58
62
|
historyCount?: number;
|
|
59
63
|
appKey?: string;
|
|
60
64
|
credential?: {
|
|
@@ -63,14 +67,202 @@ type AdpConfig = {
|
|
|
63
67
|
token?: string;
|
|
64
68
|
};
|
|
65
69
|
};
|
|
70
|
+
type AdpChunk = {
|
|
71
|
+
type: "reply";
|
|
72
|
+
payload: ReplyEvent;
|
|
73
|
+
message_id: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "thought";
|
|
76
|
+
payload: ThoughtEvent;
|
|
77
|
+
message_id: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: "token_stat";
|
|
80
|
+
payload: TokenStatEvent;
|
|
81
|
+
message_id: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: "reference";
|
|
84
|
+
payload: ReferenceEvent;
|
|
85
|
+
message_id: string;
|
|
86
|
+
} | {
|
|
87
|
+
type: "error";
|
|
88
|
+
error: ErrorInfo;
|
|
89
|
+
};
|
|
90
|
+
interface ReplyEvent {
|
|
91
|
+
request_id: string;
|
|
92
|
+
content: string;
|
|
93
|
+
file_infos: FileInfo[];
|
|
94
|
+
record_id: string;
|
|
95
|
+
related_record_id: string;
|
|
96
|
+
session_id: string;
|
|
97
|
+
is_from_self: boolean;
|
|
98
|
+
can_rating: boolean;
|
|
99
|
+
timestamp: number;
|
|
100
|
+
is_final: boolean;
|
|
101
|
+
is_evil: boolean;
|
|
102
|
+
is_llm_generated: boolean;
|
|
103
|
+
reply_method: ReplyMethod;
|
|
104
|
+
knowledge?: Knowledge[];
|
|
105
|
+
option_cards?: string[];
|
|
106
|
+
custom_params?: string[];
|
|
107
|
+
task_flow?: TaskFlow;
|
|
108
|
+
work_flow?: WorkFlow;
|
|
109
|
+
quote_infos?: QuoteInfo[];
|
|
110
|
+
}
|
|
111
|
+
declare enum ReplyMethod {
|
|
112
|
+
LLM_REPLY = 1,
|
|
113
|
+
UNKNOWN_QUESTION_REPLY = 2,
|
|
114
|
+
REJECT_QUESTION_REPLY = 3,
|
|
115
|
+
SENSITIVE_REPLY = 4,
|
|
116
|
+
ADOPTED_QA_PRIORITY_REPLY = 5,
|
|
117
|
+
WELCOME_REPLY = 6,
|
|
118
|
+
CONCURRENCY_LIMIT_REPLY = 7,
|
|
119
|
+
GLOBAL_INTERVENTION_KNOWLEDGE = 8,
|
|
120
|
+
TASK_FLOW_REPLY = 9,
|
|
121
|
+
TASK_FLOW_ANSWER = 10,
|
|
122
|
+
SEARCH_ENGINE_REPLY = 11,
|
|
123
|
+
KNOWLEDGE_POLISHED_REPLY = 12,
|
|
124
|
+
IMAGE_UNDERSTANDING_REPLY = 13,
|
|
125
|
+
REALTIME_DOCUMENT_REPLY = 14,
|
|
126
|
+
CLARIFICATION_CONFIRMATION_REPLY = 15,
|
|
127
|
+
WORKFLOW_REPLY = 16,
|
|
128
|
+
WORKFLOW_EXECUTION_END = 17,
|
|
129
|
+
AGENT_REPLY = 18,
|
|
130
|
+
MULTI_INTENT_REPLY = 19
|
|
131
|
+
}
|
|
132
|
+
interface Knowledge {
|
|
133
|
+
id: string;
|
|
134
|
+
type: number;
|
|
135
|
+
seg_id?: string;
|
|
136
|
+
}
|
|
137
|
+
interface TaskFlow {
|
|
138
|
+
task_flow_name: string;
|
|
139
|
+
task_flow_id: string;
|
|
140
|
+
query_rewrite: string;
|
|
141
|
+
hit_intent: string;
|
|
142
|
+
slot_info: Record<string, any>;
|
|
143
|
+
api_response: Record<string, any>;
|
|
144
|
+
type: number;
|
|
145
|
+
}
|
|
146
|
+
interface WorkFlow {
|
|
147
|
+
workflow_name: string;
|
|
148
|
+
workflow_id: string;
|
|
149
|
+
workflow_run_id: string;
|
|
150
|
+
option_cards: string[];
|
|
151
|
+
current_node: CurrentNode;
|
|
152
|
+
outputs: Array<string>;
|
|
153
|
+
}
|
|
154
|
+
declare enum CurrentNodeStatus {
|
|
155
|
+
Pending = 0,
|
|
156
|
+
Running = 1,
|
|
157
|
+
Succeeded = 2,
|
|
158
|
+
Failed = 3
|
|
159
|
+
}
|
|
160
|
+
interface CurrentNode {
|
|
161
|
+
NodeID: string;
|
|
162
|
+
NodeType: number;
|
|
163
|
+
NodeName: string;
|
|
164
|
+
Status: CurrentNodeStatus;
|
|
165
|
+
Input: string;
|
|
166
|
+
Output: string;
|
|
167
|
+
TaskOutput: string;
|
|
168
|
+
FailMessage: string;
|
|
169
|
+
CostMilliSeconds: string;
|
|
170
|
+
Reply: string;
|
|
171
|
+
BelongNodeID: string;
|
|
172
|
+
StatisticInfo: StatisticInfo;
|
|
173
|
+
}
|
|
174
|
+
interface StatisticInfo {
|
|
175
|
+
ModelName: string;
|
|
176
|
+
FirstTokenCost: number;
|
|
177
|
+
TotalCost: number;
|
|
178
|
+
InputTokens: number;
|
|
179
|
+
OutputTokens: number;
|
|
180
|
+
TotalTokens: number;
|
|
181
|
+
}
|
|
182
|
+
interface QuoteInfo {
|
|
183
|
+
index: number;
|
|
184
|
+
position: number;
|
|
185
|
+
}
|
|
186
|
+
interface TokenStatEvent {
|
|
187
|
+
session_id: string;
|
|
188
|
+
request_id: string;
|
|
189
|
+
record_id: string;
|
|
190
|
+
status_summary: "processing" | "success" | "failed";
|
|
191
|
+
status_summary_title: string;
|
|
192
|
+
elapsed: number;
|
|
193
|
+
token_count: number;
|
|
194
|
+
procedures: TokenStatProcedure[];
|
|
195
|
+
}
|
|
196
|
+
interface TokenStatProcedure {
|
|
197
|
+
name: string;
|
|
198
|
+
title: string;
|
|
199
|
+
status: "processing" | "success" | "failed";
|
|
200
|
+
input_count: number;
|
|
201
|
+
output_count: number;
|
|
202
|
+
count: number;
|
|
203
|
+
}
|
|
204
|
+
interface ReferenceEvent {
|
|
205
|
+
record_id: string;
|
|
206
|
+
references: Reference[];
|
|
207
|
+
}
|
|
208
|
+
interface Reference {
|
|
209
|
+
id: string | number;
|
|
210
|
+
type: number;
|
|
211
|
+
url?: string;
|
|
212
|
+
name: string;
|
|
213
|
+
doc_id: number;
|
|
214
|
+
doc_biz_id: number;
|
|
215
|
+
doc_name: string;
|
|
216
|
+
qa_biz_id: string;
|
|
217
|
+
}
|
|
218
|
+
interface ErrorInfo {
|
|
219
|
+
code: number;
|
|
220
|
+
message: string;
|
|
221
|
+
}
|
|
222
|
+
interface ThoughtEvent {
|
|
223
|
+
elapsed: number;
|
|
224
|
+
is_workflow: boolean;
|
|
225
|
+
procedures: ThoughtProcedure[];
|
|
226
|
+
record_id: string;
|
|
227
|
+
request_id: string;
|
|
228
|
+
session_id: string;
|
|
229
|
+
trace_id: string;
|
|
230
|
+
workflow_name: string;
|
|
231
|
+
}
|
|
232
|
+
interface ThoughtProcedure {
|
|
233
|
+
debugging: Debugging;
|
|
234
|
+
index: number;
|
|
235
|
+
name: string;
|
|
236
|
+
title: string;
|
|
237
|
+
status: "processing" | "success" | "failed";
|
|
238
|
+
icon: string;
|
|
239
|
+
switch: string;
|
|
240
|
+
workflow_name: string;
|
|
241
|
+
plugin_type: number;
|
|
242
|
+
elapsed: number;
|
|
243
|
+
}
|
|
244
|
+
interface Debugging {
|
|
245
|
+
content: string;
|
|
246
|
+
}
|
|
66
247
|
|
|
248
|
+
declare class AdpAgentError extends Error {
|
|
249
|
+
code?: string;
|
|
250
|
+
constructor(message: string, code?: string);
|
|
251
|
+
}
|
|
67
252
|
declare class AdpAgent extends AbstractAgent {
|
|
68
|
-
private adpConfig;
|
|
69
253
|
private reqAppClient;
|
|
70
254
|
private reqLkeClient;
|
|
255
|
+
protected adpConfig: AdpConfig;
|
|
71
256
|
constructor(config: AgentConfig & {
|
|
72
257
|
adpConfig: AdpConfig;
|
|
73
258
|
});
|
|
259
|
+
generateRequestBody({ message, fileInfos, runId, threadId, forwardedProps, }: {
|
|
260
|
+
message: string;
|
|
261
|
+
fileInfos: FileInfo[];
|
|
262
|
+
runId: string;
|
|
263
|
+
threadId: string;
|
|
264
|
+
forwardedProps: Record<string, string>;
|
|
265
|
+
}): AdpChatRequest;
|
|
74
266
|
run(input: RunAgentInput): Observable<{
|
|
75
267
|
type: EventType;
|
|
76
268
|
timestamp?: number | undefined;
|
|
@@ -79,4 +271,4 @@ declare class AdpAgent extends AbstractAgent {
|
|
|
79
271
|
private _run;
|
|
80
272
|
}
|
|
81
273
|
|
|
82
|
-
export { AdpAgent };
|
|
274
|
+
export { AdpAgent, AdpAgentError, type AdpChatRequest, type AdpChunk, type AdpConfig, type CurrentNode, CurrentNodeStatus, type Debugging, type ErrorInfo, type FileInfo, type Knowledge, type QuoteInfo, type Reference, type ReferenceEvent, type ReplyEvent, ReplyMethod, type StatisticInfo, type TaskFlow, type ThoughtEvent, type ThoughtProcedure, type TokenStatEvent, type TokenStatProcedure, type WorkFlow };
|