| 115 | } |
| 116 | |
| 117 | private getToolsFromPipe( |
| 118 | pipe: Pipe, |
| 119 | ): Record<string, (...args: any[]) => Promise<any>> { |
| 120 | const tools: Record<string, (...args: any[]) => Promise<any>> = {}; |
| 121 | if (pipe.tools && Array.isArray(pipe.tools)) { |
| 122 | pipe.tools.forEach((tool: Tool) => { |
| 123 | tools[tool.function.name] = tool.run; |
| 124 | }); |
| 125 | } |
| 126 | return tools; |
| 127 | } |
| 128 | |
| 129 | private async runTools(toolCalls: ToolCallResult[]): Promise<Message[]> { |
| 130 | const toolPromises = toolCalls.map(async (toolCall: ToolCallResult) => { |