2026-03-23 13:44:45 +08:00
|
|
|
package handle
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"agent/agent"
|
|
|
|
|
"context"
|
2026-03-24 22:15:30 +08:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"sync"
|
2026-03-23 13:44:45 +08:00
|
|
|
|
|
|
|
|
"github.com/tmc/langchaingo/llms"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var files = []string{
|
|
|
|
|
".\\prompt\\card.txt",
|
|
|
|
|
".\\prompt\\guodegang.txt",
|
|
|
|
|
".\\prompt\\mermaid.txt",
|
|
|
|
|
".\\prompt\\quiz.txt",
|
|
|
|
|
".\\prompt\\scenario.txt",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetCard(llm llms.Model, ctx context.Context, topic string) (response string) {
|
|
|
|
|
file := files[0]
|
|
|
|
|
response = agent.CallWithAgent(llm, ctx, topic, file)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetGuodegang(llm llms.Model, ctx context.Context, topic string) (response string) {
|
|
|
|
|
file := files[1]
|
|
|
|
|
response = agent.CallWithAgent(llm, ctx, topic, file)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetMermaid(llm llms.Model, ctx context.Context, topic string) (response string) {
|
|
|
|
|
file := files[2]
|
|
|
|
|
response = agent.CallWithAgent(llm, ctx, topic, file)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetQuiz(llm llms.Model, ctx context.Context, topic string) (response string) {
|
|
|
|
|
file := files[3]
|
|
|
|
|
response = agent.CallWithAgent(llm, ctx, topic, file)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetScenario(llm llms.Model, ctx context.Context, topic string) (response string) {
|
|
|
|
|
file := files[4]
|
|
|
|
|
response = agent.CallWithAgent(llm, ctx, topic, file)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-03-24 22:15:30 +08:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|