mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-08-19 22:20:58 +00:00
feat(release): migrate GeekAI v4.3.0 to open source
- Sync backend and frontend from GeekAI Plus v4.3.0 - Remove commercial License flows and update open-source deployment defaults - Preserve Docker Compose deployment and bump image tags to v4.3.0 BREAKING CHANGE: commercial License configuration and related endpoints are removed
This commit is contained in:
+11
-13
@@ -1,18 +1,16 @@
|
||||
package vo
|
||||
|
||||
import "geekai/core/types"
|
||||
|
||||
type ChatApp struct {
|
||||
BaseVo
|
||||
Key string `json:"key"` // 角色唯一标识
|
||||
Tid uint `json:"tid"`
|
||||
Name string `json:"name"` // 角色名称
|
||||
Context []types.Message `json:"context"` // 角色语料信息
|
||||
HelloMsg string `json:"hello_msg"` // 打招呼的消息
|
||||
Icon string `json:"icon"` // 角色聊天图标
|
||||
Enable bool `json:"enable"` // 是否启用被启用
|
||||
SortNum int `json:"sort"` // 排序
|
||||
ModelId uint `json:"model_id"` // 绑定模型 ID
|
||||
ModelName string `json:"model_name"` // 模型名称
|
||||
TypeName string `json:"type_name"` // 分类名称
|
||||
Tid uint `json:"tid"`
|
||||
Name string `json:"name"` // 角色名称
|
||||
UserId uint `json:"user_id"` // 所属用户 ID,0 表示系统内置
|
||||
SystemPrompt string `json:"system_prompt,omitempty"` // 系统提示词(列表接口对内置智能体不下发)
|
||||
HelloMsg string `json:"hello_msg"` // 打招呼的消息
|
||||
Icon string `json:"icon"` // 角色聊天图标
|
||||
Enable bool `json:"enable"` // 是否启用
|
||||
SortNum int `json:"sort"` // 排序
|
||||
ModelId uint `json:"model_id"` // 绑定模型 ID
|
||||
ModelName string `json:"model_name"` // 模型名称
|
||||
TypeName string `json:"type_name"` // 分类名称
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package vo
|
||||
|
||||
type DallJob struct {
|
||||
Id uint `json:"id"`
|
||||
UserId int `json:"user_id"`
|
||||
Prompt string `json:"prompt"`
|
||||
ImgURL string `json:"img_url"`
|
||||
OrgURL string `json:"org_url"`
|
||||
Publish bool `json:"publish"`
|
||||
Power int `json:"power"`
|
||||
Progress int `json:"progress"`
|
||||
ErrMsg string `json:"err_msg"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package vo
|
||||
|
||||
type ImageJob struct {
|
||||
Id uint `json:"id"`
|
||||
UserId int `json:"user_id"`
|
||||
Prompt string `json:"prompt"`
|
||||
Params string `json:"params"`
|
||||
ImgURL string `json:"img_url"`
|
||||
OrgURL string `json:"org_url"`
|
||||
Publish bool `json:"publish"`
|
||||
Power int `json:"power"`
|
||||
Progress int `json:"progress"`
|
||||
ErrMsg string `json:"err_msg"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// PPTSlideImageVersion 单页配图历史中的一条(图片地址 + 文生图/图生图提示)
|
||||
type PPTSlideImageVersion struct {
|
||||
ImageURL string `json:"image_url"`
|
||||
Prompt string `json:"prompt"`
|
||||
}
|
||||
|
||||
// PPTSlideImageVersions 存库 JSON 数组;UnmarshalJSON 兼容旧版仅字符串数组
|
||||
type PPTSlideImageVersions []PPTSlideImageVersion
|
||||
|
||||
// UnmarshalJSON 兼容 ["url1","url2"] 与 [{"image_url":"...","prompt":"..."}]
|
||||
func (v *PPTSlideImageVersions) UnmarshalJSON(data []byte) error {
|
||||
if len(data) == 0 || string(data) == "null" {
|
||||
*v = nil
|
||||
return nil
|
||||
}
|
||||
var raw []json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
return err
|
||||
}
|
||||
out := make([]PPTSlideImageVersion, 0, len(raw))
|
||||
for _, item := range raw {
|
||||
item = bytes.TrimSpace(item)
|
||||
if len(item) == 0 || string(item) == "null" {
|
||||
continue
|
||||
}
|
||||
if item[0] == '"' {
|
||||
var s string
|
||||
if err := json.Unmarshal(item, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
out = append(out, PPTSlideImageVersion{ImageURL: s, Prompt: ""})
|
||||
continue
|
||||
}
|
||||
var o PPTSlideImageVersion
|
||||
if err := json.Unmarshal(item, &o); err != nil {
|
||||
return err
|
||||
}
|
||||
out = append(out, o)
|
||||
}
|
||||
*v = out
|
||||
return nil
|
||||
}
|
||||
|
||||
// PPTParams 生成参数(语言、生成模式、页数)
|
||||
type PPTParams struct {
|
||||
Language string `json:"language"` // 输出语言,如 zh-CN, en
|
||||
Mode string `json:"mode"` // 生成模式:detailed | slides
|
||||
Pages int `json:"pages"` // 目标页数
|
||||
}
|
||||
|
||||
// Value 实现 driver.Valuer,序列化为 JSON 存储
|
||||
func (p PPTParams) Value() (driver.Value, error) {
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
// Scan 实现 sql.Scanner,从数据库读取 JSON
|
||||
func (p *PPTParams) Scan(value any) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
bytes, ok := value.([]byte)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to unmarshal PPTParams value: %v", value)
|
||||
}
|
||||
return json.Unmarshal(bytes, p)
|
||||
}
|
||||
|
||||
// PPTSlideData 单页幻灯片数据(与 service/ppt SlideData 一致)
|
||||
type PPTSlideData struct {
|
||||
SlideIndex int `json:"slide_index"`
|
||||
Theme string `json:"theme"`
|
||||
Title string `json:"title"`
|
||||
Points []string `json:"points"`
|
||||
ImagePrompt string `json:"image_prompt"`
|
||||
ImageURL string `json:"image_url"`
|
||||
ImageHistory PPTSlideImageVersions `json:"image_history,omitempty"`
|
||||
}
|
||||
|
||||
// PPTSlides 幻灯片列表(JSON 数组)
|
||||
type PPTSlides []PPTSlideData
|
||||
|
||||
// Value 实现 driver.Valuer
|
||||
func (s PPTSlides) Value() (driver.Value, error) {
|
||||
if len(s) == 0 {
|
||||
return "[]", nil
|
||||
}
|
||||
return json.Marshal(s)
|
||||
}
|
||||
|
||||
// Scan 实现 sql.Scanner
|
||||
func (s *PPTSlides) Scan(value any) error {
|
||||
if value == nil {
|
||||
*s = nil
|
||||
return nil
|
||||
}
|
||||
bytes, ok := value.([]byte)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to unmarshal PPTSlides value: %v", value)
|
||||
}
|
||||
return json.Unmarshal(bytes, s)
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"geekai/core/types"
|
||||
)
|
||||
|
||||
type SdJob struct {
|
||||
Id uint `json:"id"`
|
||||
Type string `json:"type"`
|
||||
UserId uint `json:"user_id"`
|
||||
TaskId string `json:"task_id"`
|
||||
ImgURL string `json:"img_url"`
|
||||
Params types.SdTaskParams `json:"params"`
|
||||
Progress int `json:"progress"`
|
||||
Prompt string `json:"prompt"`
|
||||
Publish bool `json:"publish"`
|
||||
ErrMsg string `json:"err_msg"`
|
||||
Power int `json:"power"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
}
|
||||
@@ -1,5 +1,41 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SunoParam Suno 任务参数
|
||||
type SunoParam struct {
|
||||
Prompt string `json:"prompt"` // 提示词
|
||||
Instrumental bool `json:"instrumental"` // 是否为纯音乐
|
||||
Tags string `json:"tags"` // 歌曲风格和标签
|
||||
ExtendSecs int `json:"extend_secs"` // 续写秒数
|
||||
Lyrics string `json:"lyrics,omitempty"` // 歌词(可选)
|
||||
Model string `json:"model"` // 模型名称
|
||||
}
|
||||
|
||||
// Value 实现 driver.Valuer 接口,用于将 SunoParam 序列化为 JSON 字符串存储到数据库
|
||||
func (p SunoParam) Value() (driver.Value, error) {
|
||||
if p.Prompt == "" && !p.Instrumental && p.Tags == "" && p.ExtendSecs == 0 && p.Lyrics == "" && p.Model == "" {
|
||||
return nil, nil
|
||||
}
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
// Scan 实现 sql.Scanner 接口,用于从数据库读取 JSON 字符串并反序列化为 SunoParam
|
||||
func (p *SunoParam) Scan(value any) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
bytes, ok := value.([]byte)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to unmarshal SunoParam value: %v", value)
|
||||
}
|
||||
return json.Unmarshal(bytes, p)
|
||||
}
|
||||
|
||||
type SunoJob struct {
|
||||
Id uint `json:"id"`
|
||||
UserId uint `json:"user_id"`
|
||||
@@ -21,7 +57,8 @@ type SunoJob struct {
|
||||
Duration int `json:"duration"` // 银屏时长,秒
|
||||
Publish bool `json:"publish"` // 是否发布
|
||||
ErrMsg string `json:"err_msg"` // 错误信息
|
||||
RawData map[string]interface{} `json:"raw_data"` // 原始数据 json
|
||||
Output map[string]interface{} `json:"output"` // 原始输出数据 json
|
||||
Params SunoParam `json:"params"` // 任务参数
|
||||
Power int `json:"power"` // 消耗算力
|
||||
RefSong map[string]interface{} `json:"ref_song,omitempty"`
|
||||
User map[string]interface{} `json:"user,omitempty"` //关联用户信息
|
||||
|
||||
+16
-16
@@ -2,20 +2,20 @@ package vo
|
||||
|
||||
type User struct {
|
||||
BaseVo
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Mobile string `json:"mobile"`
|
||||
Email string `json:"email"`
|
||||
Avatar string `json:"avatar"`
|
||||
Salt string `json:"salt"` // 密码盐
|
||||
Power int `json:"power"` // 剩余算力
|
||||
ChatRoles []string `json:"chat_roles"` // 聊天角色集合
|
||||
ChatModels []int `json:"chat_models"` // AI模型集合
|
||||
ExpiredTime int64 `json:"expired_time"` // 账户到期时间
|
||||
Status bool `json:"status"` // 当前状态
|
||||
LastLoginAt int64 `json:"last_login_at"` // 最后登录时间
|
||||
LastLoginIp string `json:"last_login_ip"` // 最后登录 IP
|
||||
Vip bool `json:"vip"`
|
||||
OpenId string `json:"openid"` // 第三方登录 OpenID
|
||||
Platform string `json:"platform"` // 第三方登录平台
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Mobile string `json:"mobile"`
|
||||
Email string `json:"email"`
|
||||
Avatar string `json:"avatar"`
|
||||
Salt string `json:"salt"` // 密码盐
|
||||
Power int `json:"power"` // 剩余算力
|
||||
ChatModels []int `json:"chat_models"` // AI模型集合
|
||||
ChatRoles []uint `json:"chat_roles"` // 工作区应用 ID 列表
|
||||
ExpiredTime int64 `json:"expired_time"` // 账户到期时间
|
||||
Status bool `json:"status"` // 当前状态
|
||||
LastLoginAt int64 `json:"last_login_at"`
|
||||
LastLoginIp string `json:"last_login_ip"`
|
||||
Vip bool `json:"vip"`
|
||||
OpenId string `json:"openid"` // 第三方登录 OpenID
|
||||
Platform string `json:"platform"` // 第三方登录平台
|
||||
}
|
||||
|
||||
+15
-16
@@ -1,20 +1,19 @@
|
||||
package vo
|
||||
|
||||
type VideoJob struct {
|
||||
Id uint `json:"id"`
|
||||
UserId uint `json:"user_id"`
|
||||
Channel string `json:"channel"`
|
||||
Type string `json:"type"`
|
||||
TaskId string `json:"task_id"`
|
||||
Prompt string `json:"prompt"` // 提示词
|
||||
PromptExt string `json:"prompt_ext"` // 提示词
|
||||
CoverURL string `json:"cover_url"` // 封面图 URL
|
||||
VideoURL string `json:"video_url"` // 无水印视频 URL
|
||||
WaterURL string `json:"water_url"` // 有水印视频 URL
|
||||
Progress int `json:"progress"` // 任务进度
|
||||
Publish bool `json:"publish"` // 是否发布
|
||||
ErrMsg string `json:"err_msg"` // 错误信息
|
||||
RawData map[string]interface{} `json:"raw_data"` // 原始数据 json
|
||||
Power int `json:"power"` // 消耗算力
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
Id uint `json:"id"`
|
||||
UserId uint `json:"user_id"`
|
||||
Channel string `json:"channel"`
|
||||
Type string `json:"type"`
|
||||
TaskId string `json:"task_id"`
|
||||
Prompt string `json:"prompt"` // 提示词
|
||||
VideoURL string `json:"video_url"` // 视频 URL
|
||||
Status string `json:"status"` // 任务状态
|
||||
Progress int `json:"progress"` // 任务进度(0-100)
|
||||
Publish bool `json:"publish"` // 是否发布
|
||||
ErrMsg string `json:"err_msg"` // 错误信息
|
||||
Params map[string]any `json:"params"` // 任务参数 json(用于前端显示)
|
||||
Output map[string]any `json:"output"` // 任务输出信息 json(管理后台使用)
|
||||
Power int `json:"power"` // 消耗算力
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user