File tree Expand file tree Collapse file tree 3 files changed +45
-4
lines changed
botonic-plugin-ai-agents/src
botonic-plugin-flow-builder/src Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export interface AiAgentRequestDataTest {
19
19
instructions : string
20
20
}
21
21
22
- export type MessageRole = 'user' | 'assistant'
22
+ export type MessageRole = 'user' | 'assistant' | 'tool'
23
23
24
24
export interface AiAgentRequestData {
25
25
message : string
@@ -29,5 +29,23 @@ export interface AiAgentRequestData {
29
29
}
30
30
31
31
export interface AiAgentResponse {
32
- message : { role : string ; content : string }
32
+ message : AgentMessage
33
33
}
34
+
35
+ export interface AssistantMessage {
36
+ role : 'assistant'
37
+ content : string
38
+ }
39
+
40
+ export interface UserMessage {
41
+ role : 'user'
42
+ content : string
43
+ }
44
+
45
+ export interface ToolMessage {
46
+ role : 'tool'
47
+ tool_name : string
48
+ tool_params ?: Record < string , unknown >
49
+ }
50
+
51
+ export type AgentMessage = AssistantMessage | ToolMessage
Original file line number Diff line number Diff line change @@ -42,8 +42,18 @@ function updateContentsWithAiAgentResponse(
42
42
contents : FlowContent [ ] ,
43
43
aiAgentResponse : AiAgentResponse
44
44
) : FlowContent [ ] {
45
+ if (
46
+ aiAgentResponse . message . role === 'tool' &&
47
+ aiAgentResponse . message . tool_name === 'exit_agent'
48
+ ) {
49
+ return [ ]
50
+ }
51
+
45
52
return contents . map ( content => {
46
- if ( content instanceof FlowAiAgent ) {
53
+ if (
54
+ content instanceof FlowAiAgent &&
55
+ aiAgentResponse . message . role === 'assistant'
56
+ ) {
47
57
content . text = aiAgentResponse . message . content
48
58
}
49
59
Original file line number Diff line number Diff line change @@ -89,9 +89,22 @@ export interface KnowledgeBaseResponse {
89
89
}
90
90
91
91
export interface AiAgentResponse {
92
- message : { role : string ; content : string }
92
+ message : AgentMessage
93
93
}
94
94
95
+ interface AssistantMessage {
96
+ role : 'assistant'
97
+ content : string
98
+ }
99
+
100
+ interface ToolMessage {
101
+ role : 'tool'
102
+ tool_name : string
103
+ tool_params ?: Record < string , unknown >
104
+ }
105
+
106
+ export type AgentMessage = AssistantMessage | ToolMessage
107
+
95
108
export interface SmartIntentResponse {
96
109
data : {
97
110
smart_intent_title : string
You can’t perform that action at this time.
0 commit comments