🔥 移除配置文件里的AI配置,改为数据库配置,且支持配置多个AI助手
This commit is contained in:
parent
79fa7196af
commit
379e2bdb54
@ -13,12 +13,3 @@ redis:
|
||||
port: 6379 # Redis端口
|
||||
password: mNhgeSk32fUf69C6
|
||||
db: 0
|
||||
|
||||
# AI回复
|
||||
ai:
|
||||
# 模型,不填默认gpt-3.5-turbo-0613
|
||||
model: gpt-3.5-turbo-0613
|
||||
# 接口代理域名,不填默认ChatGPT官方地址
|
||||
baseUrl: https://sxxx
|
||||
# 人设
|
||||
personality: 你的名字叫张三,你是一个百科机器人,你的爱好是看电影,你的性格是开朗的,你的专长是讲故事,你的梦想是当一名童话故事作家。你对政治没有一点儿兴趣,也不会讨论任何与政治相关的话题,你甚至可以拒绝回答这一类话题。
|
||||
|
@ -1,9 +0,0 @@
|
||||
package config
|
||||
|
||||
// ai
|
||||
// @description: AI配置
|
||||
type ai struct {
|
||||
Model string `json:"model" yaml:"model"` // 模型
|
||||
BaseUrl string `json:"baseUrl" yaml:"baseUrl"` // API地址
|
||||
Personality string `json:"personality" yaml:"personality"` // 默认人设
|
||||
}
|
@ -8,5 +8,4 @@ var Conf conf
|
||||
type conf struct {
|
||||
Database db `json:"database" yaml:"database"` // 数据库 配置
|
||||
Redis redis `json:"redis" yaml:"redis"` // Redis 配置
|
||||
Ai ai `json:"ai" yaml:"ai"` // AI配置
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ func databaseTable() {
|
||||
new(entity.Role), // 角色表
|
||||
new(entity.RoleMenu), // 角色菜单表
|
||||
new(entity.AdminUserRole), // 用户角色表
|
||||
new(entity.SystemConfig), // 系统配置表
|
||||
new(entity.Robot), // 机器人表
|
||||
new(entity.AiAssistant), // AI助手表
|
||||
}
|
||||
|
||||
// 同步表结构
|
||||
|
20
model/entity/aiassistant.go
Normal file
20
model/entity/aiassistant.go
Normal file
@ -0,0 +1,20 @@
|
||||
package entity
|
||||
|
||||
import "wechat-robot/pkg/types"
|
||||
|
||||
// AiAssistant
|
||||
// @description: AI助手表
|
||||
type AiAssistant struct {
|
||||
types.BaseDbModel
|
||||
Name string `json:"name" gorm:"type:varchar(10);not null;comment:'名称'"`
|
||||
Personality string `json:"personality" gorm:"type:varchar(999);not null;comment:'人设'"`
|
||||
Model string `json:"setting" gorm:"type:varchar(50);not null;comment:'使用的模型'"`
|
||||
}
|
||||
|
||||
// TableName
|
||||
// @description: 表名
|
||||
// @receiver AiAssistant
|
||||
// @return string
|
||||
func (AiAssistant) TableName() string {
|
||||
return "t_ai_assistant"
|
||||
}
|
19
model/entity/systemconfig.go
Normal file
19
model/entity/systemconfig.go
Normal file
@ -0,0 +1,19 @@
|
||||
package entity
|
||||
|
||||
import "wechat-robot/pkg/types"
|
||||
|
||||
// SystemConfig
|
||||
// @description: 系统配置
|
||||
type SystemConfig struct {
|
||||
types.BaseDbModelWithReal
|
||||
Code string `json:"code" gorm:"type:varchar(255);not null;comment:'配置编码'"`
|
||||
Content string `json:"content" gorm:"type:text;comment:'配置内容'"`
|
||||
}
|
||||
|
||||
// TableName
|
||||
// @description: 表名
|
||||
// @receiver SystemConfig
|
||||
// @return string
|
||||
func (SystemConfig) TableName() string {
|
||||
return "t_system_config"
|
||||
}
|
@ -64,7 +64,7 @@ func ExtensionFields(ti oauth2.TokenInfo) (fieldsValue map[string]any) {
|
||||
_ = database.Client.Take(&ui, "id = ?", ti.GetUserID()).Error
|
||||
fieldsValue["username"] = ui.Username
|
||||
fieldsValue["id"] = ui.Id
|
||||
//fieldsValue["roles"] = strings.Split(ui.Role, ",")
|
||||
fieldsValue["roles"] = []string{"admin"}
|
||||
return
|
||||
}
|
||||
|
||||
|
25
pkg/types/userinfo.go
Normal file
25
pkg/types/userinfo.go
Normal file
@ -0,0 +1,25 @@
|
||||
package types
|
||||
|
||||
import "fmt"
|
||||
|
||||
// UserSex 用户性别
|
||||
type UserSex int
|
||||
|
||||
const (
|
||||
UserSexMale UserSex = iota + 1 // 男
|
||||
UserSexFemale // 女
|
||||
UserSexUnknown // 未知
|
||||
)
|
||||
|
||||
var userSexMap = map[UserSex]string{
|
||||
UserSexMale: "男",
|
||||
UserSexFemale: "女",
|
||||
UserSexUnknown: "未知",
|
||||
}
|
||||
|
||||
func (u UserSex) String() string {
|
||||
if v, ok := userSexMap[u]; ok {
|
||||
return v
|
||||
}
|
||||
return fmt.Sprintf("性别<%d>", u)
|
||||
}
|
@ -25,9 +25,10 @@ func toTree(records []menuRecordItem, pid string) (tree []menu.Item) {
|
||||
var node menu.Item
|
||||
node.Id = record.Id
|
||||
node.Path = record.Path
|
||||
node.Name = record.Name
|
||||
|
||||
var meta menu.ItemMeta
|
||||
meta.Title = record.Name
|
||||
meta.Title = record.Title
|
||||
meta.Icon = record.Icon
|
||||
meta.Rank = record.Sort
|
||||
if record.RoleCode != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user