增加ai配置和ai广场功能

This commit is contained in:
hero920103 committed 2026-11-09 16:44:11 +08:00
1 parent 244b4bd9fd
commit d9a50e23dd
27 files changed
+3808 -57

No files matched your search

+4
View File
@@ -148,6 +148,10 @@ func Init(_ string) {
new(ErpFundBill),
new(ErpFundSettle),
new(BackendAiProvider),
// 平台级 AI 服务商配置(docs/sql/create_platform_ai_provider.sql)
new(PlatformAiProvider),
new(PlatformAiChatSession),
new(PlatformAiChatMessage),
new(BackendAiChatSession),
new(BackendAiChatMessage),
new(BackendAiChatPreset),
+30
View File
@@ -0,0 +1,30 @@
package models
import "time"
// PlatformAiChatSession 平台 AI Playground 会话
type PlatformAiChatSession struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Title string `orm:"column(title);size(100)" json:"title"`
ProviderID uint64 `orm:"column(provider_id)" json:"provider_id"`
Model string `orm:"column(model);size(100)" json:"model"`
IsTop int8 `orm:"column(is_top);default(0)" json:"is_top"` // 1-置顶
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
}
func (m *PlatformAiChatSession) TableName() string { return "yz_platform_ai_chat_session" }
// PlatformAiChatMessage 平台 AI 会话消息
type PlatformAiChatMessage struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
SessionID uint64 `orm:"column(session_id)" json:"session_id"`
Role string `orm:"column(role);size(20)" json:"role"`
Content string `orm:"column(content);type(text)" json:"content"` // user 存原始 content JSON(含附件);assistant 存纯文本
Think string `orm:"column(think);type(text)" json:"think"` // assistant 思考过程
Seq int `orm:"column(seq)" json:"seq"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
}
func (m *PlatformAiChatMessage) TableName() string { return "yz_platform_ai_chat_message" }
+34
View File
@@ -0,0 +1,34 @@
package models
import "time"
// AiModelItem 模型条目:模型 ID + 展示名称
type AiModelItem struct {
ID string `json:"id"`
Name string `json:"name"`
}
// PlatformAiProvider 平台级 AI 服务商配置(DeepSeek / 豆包 / Codex 等)
// 表:yz_platform_ai_provider,建表 SQL 见 docs/sql/create_platform_ai_provider.sql
type PlatformAiProvider struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
ProviderType string `orm:"column(provider_type);size(30)" json:"provider_type"` // 预设分类:deepseek / doubao / codex / custom
ApiType string `orm:"column(api_type);size(30)" json:"api_type"` // 协议类型:chat_completions / responses / anthropic
Name string `orm:"column(name);size(100)" json:"name"`
ApiBase string `orm:"column(api_base);size(255)" json:"api_base"`
ApiKey string `orm:"column(api_key);size(500)" json:"-"` // 不回传前端
ApiKeyMasked string `orm:"-" json:"api_key_masked"` // 回显掩码,如 sk-***abcd
Models string `orm:"column(models);type(text)" json:"-"` // JSON数组
ModelsList []AiModelItem `orm:"-" json:"models"`
DefaultModel string `orm:"column(default_model);size(255)" json:"default_model"`
IsDefault int8 `orm:"column(is_default);default(0)" json:"is_default"`
Status int8 `orm:"column(status);default(1)" json:"status"` // 0-禁用 1-启用
Remark string `orm:"column(remark);size(255)" json:"remark"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
}
func (m *PlatformAiProvider) TableName() string {
return "yz_platform_ai_provider"
}