diff --git a/main.go b/main.go index 95a341f..56b69dd 100644 --- a/main.go +++ b/main.go @@ -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() }