✨Feat: 加入协程机制

This commit is contained in:
2026-03-23 13:12:31 +08:00
parent b0ad820ccd
commit 05105525e8
+20 -5
View File
@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"sync"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"github.com/tmc/langchaingo/llms" "github.com/tmc/langchaingo/llms"
@@ -44,10 +45,24 @@ func init() {
} }
func main() { func main() {
var wg sync.WaitGroup
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\card.txt") files := []string{
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\guodegang.txt") ".\\prompt\\card.txt",
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\mermaid.txt") ".\\prompt\\guodegang.txt",
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\quiz.txt") ".\\prompt\\mermaid.txt",
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\scenario.txt") ".\\prompt\\quiz.txt",
".\\prompt\\scenario.txt",
}
wg.Add(len(files))
for _, file := range files {
go func(f string) {
defer wg.Done()
agent.CallWithAgent(llm, ctx, "文件", f)
}(file)
}
wg.Wait()
} }