( parentTask: LLMTask )
| 174 | } |
| 175 | |
| 176 | function createNewAssistantResponseTask( |
| 177 | parentTask: LLMTask |
| 178 | ): partialTaskDraft[] { |
| 179 | // Process the response and create new tasks if necessary |
| 180 | console.log('create new response task'); |
| 181 | const taskListFromResponse: partialTaskDraft[] = []; |
| 182 | const messages = parentTask.result?.assistantResponse || []; |
| 183 | console.log('create a new assistant response tasks...', messages); |
| 184 | for (const tm of messages) { |
| 185 | const allText = tm.content.filter( |
| 186 | (m): m is OpenAI.Beta.Threads.MessageContentText => m.type === 'text' |
| 187 | ); |
| 188 | taskListFromResponse.push({ |
| 189 | role: tm.role, |
| 190 | content: allText.map((textContent) => textContent.text.value).join('\n'), |
| 191 | debugging: { threadMessage: tm }, |
| 192 | }); |
| 193 | } |
| 194 | return taskListFromResponse; |
| 195 | } |
| 196 | |
| 197 | async function parseChatResponse( |
| 198 | message: string, |
no test coverage detected