✨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"
"log"
"os"
"sync"
"github.com/joho/godotenv"
"github.com/tmc/langchaingo/llms"
@@ -44,10 +45,24 @@ func init() {
}
func main() {
var wg sync.WaitGroup
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\card.txt")
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\guodegang.txt")
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\mermaid.txt")
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\quiz.txt")
agent.CallWithAgent(llm, ctx, "文件", ".\\prompt\\scenario.txt")
files := []string{
".\\prompt\\card.txt",
".\\prompt\\guodegang.txt",
".\\prompt\\mermaid.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()
}