✨Feat: 加入协程机制
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user