(task: LLMTask)
| 154 | } |
| 155 | |
| 156 | export async function processFunctionTask(task: LLMTask) { |
| 157 | if (task.context?.function) { |
| 158 | const func = task.context.function; |
| 159 | console.log(`Calling function ${func.name}`); |
| 160 | if (tools[func.name]) { |
| 161 | const result = await handleFunctionExecution(func, tools); |
| 162 | task.result = result; |
| 163 | } else { |
| 164 | const toolnames = JSON.stringify(task.allowedTools); |
| 165 | task.result = { |
| 166 | type: 'ToolError', |
| 167 | toolResult: { |
| 168 | error: `The function ${func.name} is not available in tools. Please select a valid function from this list: ${toolnames}`, |
| 169 | }, |
| 170 | }; |
| 171 | } |
| 172 | } |
| 173 | return task; |
| 174 | } |
| 175 | |
| 176 | function createNewAssistantResponseTask( |
| 177 | parentTask: LLMTask |
no test coverage detected