✨Feat: 增添结构体解析函数
This commit is contained in:
+19
-17
@@ -2,6 +2,7 @@ package handle
|
||||
|
||||
import (
|
||||
"agent/agent"
|
||||
"agent/response_struct"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
@@ -18,38 +19,38 @@ var files = []string{
|
||||
".\\prompt\\scenario.txt",
|
||||
}
|
||||
|
||||
func GetCard(llm llms.Model, ctx context.Context, topic string) (response string) {
|
||||
func GetCard(llm llms.Model, ctx context.Context, topic string) (response response_struct.Card) {
|
||||
file := files[0]
|
||||
response = agent.CallWithAgent(llm, ctx, topic, file)
|
||||
response = agent.CallWithAgentDefined(llm, ctx, topic, file, response_struct.Card{})
|
||||
return
|
||||
}
|
||||
|
||||
func GetGuodegang(llm llms.Model, ctx context.Context, topic string) (response string) {
|
||||
func GetGuodegang(llm llms.Model, ctx context.Context, topic string) (response response_struct.Guodegang) {
|
||||
file := files[1]
|
||||
response = agent.CallWithAgent(llm, ctx, topic, file)
|
||||
response = agent.CallWithAgentDefined(llm, ctx, topic, file, response_struct.Guodegang{})
|
||||
return
|
||||
}
|
||||
|
||||
func GetMermaid(llm llms.Model, ctx context.Context, topic string) (response string) {
|
||||
func GetMermaid(llm llms.Model, ctx context.Context, topic string) (response response_struct.Mermaid) {
|
||||
file := files[2]
|
||||
response = agent.CallWithAgent(llm, ctx, topic, file)
|
||||
response = agent.CallWithAgentDefined(llm, ctx, topic, file, response_struct.Mermaid{})
|
||||
return
|
||||
}
|
||||
|
||||
func GetQuiz(llm llms.Model, ctx context.Context, topic string) (response string) {
|
||||
func GetQuiz(llm llms.Model, ctx context.Context, topic string) (response response_struct.Quiz) {
|
||||
file := files[3]
|
||||
response = agent.CallWithAgent(llm, ctx, topic, file)
|
||||
response = agent.CallWithAgentDefined(llm, ctx, topic, file, response_struct.Quiz{})
|
||||
return
|
||||
}
|
||||
|
||||
func GetScenario(llm llms.Model, ctx context.Context, topic string) (response string) {
|
||||
func GetScenario(llm llms.Model, ctx context.Context, topic string) (response response_struct.Scenario) {
|
||||
file := files[4]
|
||||
response = agent.CallWithAgent(llm, ctx, topic, file)
|
||||
response = agent.CallWithAgentDefined(llm, ctx, topic, file, response_struct.Scenario{})
|
||||
return
|
||||
}
|
||||
|
||||
func GetAll(llm llms.Model, ctx context.Context, topic string) (response map[string]string) {
|
||||
response = make(map[string]string)
|
||||
|
||||
func GetAll(llm llms.Model, ctx context.Context, topic string) (response *response_struct.AllStruct) {
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
@@ -57,30 +58,31 @@ func GetAll(llm llms.Model, ctx context.Context, topic string) (response map[str
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
response["card"] = GetCard(llm, ctx, topic)
|
||||
response.CardStruct = GetCard(llm, ctx, topic)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
response["guodegang"] = GetGuodegang(llm, ctx, topic)
|
||||
response.GuodegangStruct = GetGuodegang(llm, ctx, topic)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
response["mermaid"] = GetMermaid(llm, ctx, topic)
|
||||
response.MermaidStruct = GetMermaid(llm, ctx, topic)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
response["quiz"] = GetQuiz(llm, ctx, topic)
|
||||
response.QuizStruct = GetQuiz(llm, ctx, topic)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
response["scenario"] = GetScenario(llm, ctx, topic)
|
||||
response.ScenarioStruct = GetScenario(llm, ctx, topic)
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
|
||||
|
||||
fmt.Println("======== All responses received ========")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user