100 lines
2.8 KiB
Go
100 lines
2.8 KiB
Go
package biz
|
|
|
|
import (
|
|
"context"
|
|
"geo/internal/data/impl"
|
|
"geo/internal/entitys"
|
|
"geo/pkg"
|
|
|
|
volmodle "github.com/volcengine/volcengine-go-sdk/service/arkruntime/model"
|
|
"github.com/volcengine/volcengine-go-sdk/volcengine"
|
|
)
|
|
|
|
type AiBiz struct {
|
|
platImpl *impl.PlatImpl
|
|
articleImpl *impl.ArticleTypeImpl
|
|
}
|
|
|
|
func NewAiBiz(platImpl *impl.PlatImpl, articleImpl *impl.ArticleTypeImpl) *AiBiz {
|
|
return &AiBiz{
|
|
platImpl: platImpl,
|
|
articleImpl: articleImpl,
|
|
}
|
|
}
|
|
|
|
func (a *AiBiz) CreateArticlePrompt(ctx context.Context, data *entitys.BotChat) []*volmodle.ChatCompletionMessage {
|
|
mes := []*volmodle.ChatCompletionMessage{
|
|
{
|
|
Role: volmodle.ChatMessageRoleUser,
|
|
Content: &volmodle.ChatCompletionMessageContent{
|
|
StringValue: volcengine.String(pkg.JsonStringIgonErr(data)),
|
|
},
|
|
},
|
|
}
|
|
|
|
//var plats []*model.Plat
|
|
//cond := builder.NewCond().
|
|
// And(builder.Eq{"plat_type": 1}).
|
|
// And(builder.Eq{"status": 1})
|
|
//_, err := a.platImpl.GetListToStruct(ctx, &cond, nil, &plats, "id asc")
|
|
//if err != nil {
|
|
// return mes
|
|
//}
|
|
//var platList = &entitys.PlatList{
|
|
// Desc: "平台列表",
|
|
// PlatItem: make([]*entitys.PlatItem, 0, len(plats)),
|
|
//}
|
|
//for _, plat := range plats {
|
|
// platList.PlatItem = append(platList.PlatItem, &entitys.PlatItem{
|
|
// Platform: plat.Name,
|
|
// PlatformIndex: plat.Index,
|
|
// })
|
|
//}
|
|
//if len(platList.PlatItem) > 0 {
|
|
// mes = append(mes, &volmodle.ChatCompletionMessage{
|
|
// Role: volmodle.ChatMessageRoleAssistant,
|
|
// Content: &volmodle.ChatCompletionMessageContent{
|
|
// StringValue: volcengine.String(pkg.JsonStringIgonErr(platList)),
|
|
// },
|
|
// })
|
|
//}
|
|
//var articleType []*model.ArticleType
|
|
//cond := builder.NewCond().
|
|
// And(builder.Eq{"status": 1})
|
|
//_, err := a.articleImpl.GetListToStruct(ctx, &cond, nil, &articleType, "id asc")
|
|
//if err != nil {
|
|
// return mes
|
|
//}
|
|
//var articleList = &entitys.ArticleTypeList{
|
|
// Desc: "文章类型以及描述",
|
|
// ArticleItem: make([]*entitys.ArticleItem, 0, len(articleType)),
|
|
//}
|
|
//for _, article := range articleType {
|
|
// articleList.ArticleItem = append(articleList.ArticleItem, &entitys.ArticleItem{
|
|
// ArticleType: article.ArticleName,
|
|
// TypeDesc: article.Desc,
|
|
// })
|
|
//}
|
|
//if len(articleList.ArticleItem) > 0 {
|
|
// mes = append(mes, &volmodle.ChatCompletionMessage{
|
|
// Role: volmodle.ChatMessageRoleAssistant,
|
|
// Content: &volmodle.ChatCompletionMessageContent{
|
|
// StringValue: volcengine.String(pkg.JsonStringIgonErr(articleList)),
|
|
// },
|
|
// })
|
|
//}
|
|
return mes
|
|
}
|
|
|
|
func (a *AiBiz) CreateProjectInfoPrompt(ctx context.Context, content string) []*volmodle.ChatCompletionMessage {
|
|
mes := []*volmodle.ChatCompletionMessage{
|
|
{
|
|
Role: volmodle.ChatMessageRoleUser,
|
|
Content: &volmodle.ChatCompletionMessageContent{
|
|
StringValue: volcengine.String(pkg.JsonStringIgonErr(content)),
|
|
},
|
|
},
|
|
}
|
|
return mes
|
|
}
|