(
step: AgentStep,
content: string,
subType?: StepContent["subType"]
)
| 105 | let lastModelOutputIndex = -1; |
| 106 | |
| 107 | const appendModelOutputContent = ( |
| 108 | step: AgentStep, |
| 109 | content: string, |
| 110 | subType?: StepContent["subType"] |
| 111 | ) => { |
| 112 | if (!content || !content.trim()) { |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | if ( |
| 117 | lastModelOutputIndex >= 0 && |
| 118 | step.contents[lastModelOutputIndex] && |
| 119 | step.contents[lastModelOutputIndex].type === |
| 120 | chatConfig.messageTypes.MODEL_OUTPUT && |
| 121 | step.contents[lastModelOutputIndex].subType === subType |
| 122 | ) { |
| 123 | step.contents[lastModelOutputIndex].content += content; |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | step.contents.push({ |
| 128 | id: `model-${Date.now()}-${Math.random() |
| 129 | .toString(36) |
| 130 | .substring(2, 7)}`, |
| 131 | type: chatConfig.messageTypes.MODEL_OUTPUT, |
| 132 | subType, |
| 133 | content, |
| 134 | expanded: true, |
| 135 | timestamp: Date.now(), |
| 136 | }); |
| 137 | lastModelOutputIndex = step.contents.length - 1; |
| 138 | }; |
| 139 | |
| 140 | const resetModelOutputTracking = () => { |
| 141 | lastModelOutputIndex = -1; |
no test coverage detected