From 2832062aad1971d67b42fb1c9802e6587ec66338 Mon Sep 17 00:00:00 2001 From: hhs <386998068.com> Date: Tue, 24 Mar 2026 22:15:30 +0800 Subject: [PATCH] =?UTF-8?q?=20=E2=9C=A8Feat:=20=E6=B7=BB=E5=8A=A0GetAll()?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B9=B6=E8=A1=8C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/handlers/agent.go | 42 +++++++++++++++++++++++++++++++++++++++ backend/main.go | 11 ++++++++++ 2 files changed, 53 insertions(+) diff --git a/backend/handlers/agent.go b/backend/handlers/agent.go index b9ccfef..cee80fd 100644 --- a/backend/handlers/agent.go +++ b/backend/handlers/agent.go @@ -3,6 +3,9 @@ package handle import ( "agent/agent" "context" + "fmt" + + "sync" "github.com/tmc/langchaingo/llms" ) @@ -44,3 +47,42 @@ func GetScenario(llm llms.Model, ctx context.Context, topic string) (response st response = agent.CallWithAgent(llm, ctx, topic, file) return } + +func GetAll(llm llms.Model, ctx context.Context, topic string) (response map[string]string) { + response = make(map[string]string) + + var wg sync.WaitGroup + + wg.Add(len(files)) + + go func() { + defer wg.Done() + response["card"] = GetCard(llm, ctx, topic) + }() + + go func() { + defer wg.Done() + response["guodegang"] = GetGuodegang(llm, ctx, topic) + }() + + go func() { + defer wg.Done() + response["mermaid"] = GetMermaid(llm, ctx, topic) + }() + + go func() { + defer wg.Done() + response["quiz"] = GetQuiz(llm, ctx, topic) + }() + + go func() { + defer wg.Done() + response["scenario"] = GetScenario(llm, ctx, topic) + }() + + wg.Wait() + + fmt.Println("======== All responses received ========") + + return response +} diff --git a/backend/main.go b/backend/main.go index f434702..aeaa867 100644 --- a/backend/main.go +++ b/backend/main.go @@ -1,5 +1,7 @@ package main +// this is 注释 + import ( handle "agent/handlers" "agent/middlewares" @@ -88,6 +90,15 @@ func main() { "message": message, }) }) + route.GET("/agent/all/:topic", func(c *gin.Context) { + topic := c.Param("topic") + message := handle.GetAll(llm, ctx, topic) + c.JSON(200, gin.H{ + "message": message, + }) + }) route.Run() + + }