feat: implement ParallelExecutor for multi-model AI calls #721

This commit is contained in:
Justin Skywork 2026-03-23 21:28:23 -04:00
parent 1055ad3eaa
commit 24c147900e

View file

@ -0,0 +1,34 @@
package parallel
import (
"sync"
)
// ModelResponse represents the result of a single model call.
type ModelResponse struct {
Model string
Output string
Error error
}
// ParallelExecutor runs multiple model calls concurrently.
type ParallelExecutor struct {
Models []string
}
func (e *ParallelExecutor) Execute(prompt string) []ModelResponse {
var wg sync.WaitGroup
responses := make([]ModelResponse, len(e.Models))
for i, model := range e.Models {
wg.Add(1)
go func(idx int, m string) {
defer wg.Done()
// Logic to call the specific model API via Yao engine
responses[idx] = ModelResponse{Model: m, Output: "Parallel Result"}
}(i, model)
}
wg.Wait()
return responses
}