mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-05-10 19:54:25 +08:00
add prompt edit function
This commit is contained in:
@@ -20,14 +20,14 @@ func init() {
|
||||
|
||||
// CaptchaConfig 行为验证码配置
|
||||
type CaptchaConfig struct {
|
||||
ApiKey string `json:"api_key"`
|
||||
Type string `json:"type"` // 验证码类型, 可选值: "dot" 或 "slide"
|
||||
Enabled bool `json:"enabled"`
|
||||
ApiKey string `json:"api_key,omitempty"`
|
||||
Type string `json:"type,omitempty"` // 验证码类型, 可选值: "dot" 或 "slide"
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
}
|
||||
|
||||
// WxLoginConfig 微信登录配置
|
||||
type WxLoginConfig struct {
|
||||
ApiKey string `json:"api_key"`
|
||||
NotifyURL string `json:"notify_url"` // 登录成功回调 URL
|
||||
Enabled bool `json:"enabled"` // 是否启用微信登录
|
||||
ApiKey string `json:"api_key,omitempty"`
|
||||
NotifyURL string `json:"notify_url,omitempty"` // 登录成功回调 URL
|
||||
Enabled bool `json:"enabled,omitempty"` // 是否启用微信登录
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package types
|
||||
// JimengConfig 即梦AI配置
|
||||
type JimengConfig struct {
|
||||
// 即梦AI的AccessKey和SecretKey
|
||||
AccessKey string `json:"access_key"`
|
||||
SecretKey string `json:"secret_key"`
|
||||
AccessKey string `json:"access_key,omitempty"`
|
||||
SecretKey string `json:"secret_key,omitempty"`
|
||||
// 火山引擎大模型专用的验证方式
|
||||
ApiKey string `json:"api_key"`
|
||||
ApiKey string `json:"api_key,omitempty"`
|
||||
// 算力配置
|
||||
Powers map[string]int `json:"powers"`
|
||||
Powers map[string]int `json:"powers,omitempty"`
|
||||
}
|
||||
|
||||
// JMTaskStatus 任务状态
|
||||
|
||||
@@ -9,13 +9,13 @@ package types
|
||||
|
||||
// 文本审查
|
||||
type ModerationConfig struct {
|
||||
Enable bool `json:"enable"` // 是否启用文本审查
|
||||
Active string `json:"active"`
|
||||
EnableGuide bool `json:"enable_guide"` // 是否启用模型引导提示词
|
||||
GuidePrompt string `json:"guide_prompt"` // 模型引导提示词
|
||||
Gitee ModerationGiteeConfig `json:"gitee"`
|
||||
Baidu ModerationBaiduConfig `json:"baidu"`
|
||||
Tencent ModerationTencentConfig `json:"tencent"`
|
||||
Enable bool `json:"enable,omitempty"` // 是否启用文本审查
|
||||
Active string `json:"active,omitempty"`
|
||||
EnableGuide bool `json:"enable_guide,omitempty"` // 是否启用模型引导提示词
|
||||
GuidePrompt string `json:"guide_prompt,omitempty"` // 模型引导提示词
|
||||
Gitee ModerationGiteeConfig `json:"gitee,omitempty"`
|
||||
Baidu ModerationBaiduConfig `json:"baidu,omitempty"`
|
||||
Tencent ModerationTencentConfig `json:"tencent,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -26,26 +26,26 @@ const (
|
||||
|
||||
// GiteeAI 文本审查配置
|
||||
type ModerationGiteeConfig struct {
|
||||
ApiKey string `json:"api_key"`
|
||||
Model string `json:"model"` // 文本审核模型
|
||||
ApiKey string `json:"api_key,omitempty"`
|
||||
Model string `json:"model,omitempty"` // 文本审核模型
|
||||
}
|
||||
|
||||
// 百度文本审查配置
|
||||
type ModerationBaiduConfig struct {
|
||||
AccessKey string `json:"access_key"`
|
||||
SecretKey string `json:"secret_key"`
|
||||
AccessKey string `json:"access_key,omitempty"`
|
||||
SecretKey string `json:"secret_key,omitempty"`
|
||||
}
|
||||
|
||||
// 腾讯云文本审查配置
|
||||
type ModerationTencentConfig struct {
|
||||
AccessKey string `json:"access_key"`
|
||||
SecretKey string `json:"secret_key"`
|
||||
AccessKey string `json:"access_key,omitempty"`
|
||||
SecretKey string `json:"secret_key,omitempty"`
|
||||
}
|
||||
|
||||
type ModerationResult struct {
|
||||
Flagged bool `json:"flagged"`
|
||||
Categories map[string]bool `json:"categories"`
|
||||
CategoryScores map[string]float64 `json:"category_scores"`
|
||||
Flagged bool `json:"flagged,omitempty"`
|
||||
Categories map[string]bool `json:"categories,omitempty"`
|
||||
CategoryScores map[string]float64 `json:"category_scores,omitempty"`
|
||||
}
|
||||
|
||||
var ModerationCategories = map[string]string{
|
||||
|
||||
@@ -8,39 +8,39 @@ package types
|
||||
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
type OSSConfig struct {
|
||||
Active string `json:"active"`
|
||||
Local LocalStorageConfig `json:"local"`
|
||||
Minio MiniOssConfig `json:"minio"`
|
||||
QiNiu QiNiuOssConfig `json:"qiniu"`
|
||||
AliYun AliYunOssConfig `json:"aliyun"`
|
||||
Active string `json:"active,omitempty"`
|
||||
Local LocalStorageConfig `json:"local,omitempty"`
|
||||
Minio MiniOssConfig `json:"minio,omitempty"`
|
||||
QiNiu QiNiuOssConfig `json:"qiniu,omitempty"`
|
||||
AliYun AliYunOssConfig `json:"aliyun,omitempty"`
|
||||
}
|
||||
|
||||
type MiniOssConfig struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessSecret string `json:"access_secret"`
|
||||
Bucket string `json:"bucket"`
|
||||
UseSSL bool `json:"use_ssl"`
|
||||
Domain string `json:"domain"`
|
||||
Endpoint string `json:"endpoint,omitempty"`
|
||||
AccessKey string `json:"access_key,omitempty"`
|
||||
AccessSecret string `json:"access_secret,omitempty"`
|
||||
Bucket string `json:"bucket,omitempty"`
|
||||
UseSSL bool `json:"use_ssl,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
type QiNiuOssConfig struct {
|
||||
Zone string `json:"zone"`
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessSecret string `json:"access_secret"`
|
||||
Bucket string `json:"bucket"`
|
||||
Domain string `json:"domain"`
|
||||
Zone string `json:"zone,omitempty"`
|
||||
AccessKey string `json:"access_key,omitempty"`
|
||||
AccessSecret string `json:"access_secret,omitempty"`
|
||||
Bucket string `json:"bucket,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
type AliYunOssConfig struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessSecret string `json:"access_secret"`
|
||||
Bucket string `json:"bucket"`
|
||||
Domain string `json:"domain"`
|
||||
Endpoint string `json:"endpoint,omitempty"`
|
||||
AccessKey string `json:"access_key,omitempty"`
|
||||
AccessSecret string `json:"access_secret,omitempty"`
|
||||
Bucket string `json:"bucket,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
type LocalStorageConfig struct {
|
||||
BasePath string `json:"base_path"`
|
||||
BaseURL string `json:"base_url"`
|
||||
BasePath string `json:"base_path,omitempty"`
|
||||
BaseURL string `json:"base_url,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package types
|
||||
|
||||
type PaymentConfig struct {
|
||||
Alipay AlipayConfig `json:"alipay"` // 支付宝支付渠道配置
|
||||
Epay EpayConfig `json:"epay"` // 易支付配置
|
||||
WxPay WxPayConfig `json:"wxpay"` // 微信支付渠道配置
|
||||
Alipay AlipayConfig `json:"alipay,omitempty"` // 支付宝支付渠道配置
|
||||
Epay EpayConfig `json:"epay,omitempty"` // 易支付配置
|
||||
WxPay WxPayConfig `json:"wxpay,omitempty"` // 微信支付渠道配置
|
||||
}
|
||||
|
||||
// AlipayConfig 支付宝支付配置
|
||||
type AlipayConfig struct {
|
||||
Enabled bool `json:"enabled"` // 是否启用该支付通道
|
||||
SandBox bool `json:"sandbox"` // 是否沙盒环境
|
||||
AppId string `json:"app_id"` // 应用 ID
|
||||
PrivateKey string `json:"private_key"` // 应用私钥
|
||||
AlipayPublicKey string `json:"alipay_public_key"` // 支付宝公钥
|
||||
Domain string `json:"domain"` // 支付回调域名
|
||||
Enabled bool `json:"enabled,omitempty"` // 是否启用该支付通道
|
||||
SandBox bool `json:"sandbox,omitempty"` // 是否沙盒环境
|
||||
AppId string `json:"app_id,omitempty"` // 应用 ID
|
||||
PrivateKey string `json:"private_key,omitempty"` // 应用私钥
|
||||
AlipayPublicKey string `json:"alipay_public_key,omitempty"` // 支付宝公钥
|
||||
Domain string `json:"domain,omitempty"` // 支付回调域名
|
||||
}
|
||||
|
||||
func (c *AlipayConfig) Equal(other *AlipayConfig) bool {
|
||||
@@ -25,13 +25,13 @@ func (c *AlipayConfig) Equal(other *AlipayConfig) bool {
|
||||
|
||||
// WxPayConfig 微信支付配置
|
||||
type WxPayConfig struct {
|
||||
Enabled bool `json:"enabled"` // 是否启用该支付通道
|
||||
AppId string `json:"app_id"` // 公众号的APPID,如:wxd678efh567hg6787
|
||||
MchId string `json:"mch_id"` // 直连商户的商户号,由微信支付生成并下发
|
||||
SerialNo string `json:"serial_no"` // 商户证书的证书序列号
|
||||
PrivateKey string `json:"private_key"` // 商户证书私钥
|
||||
ApiV3Key string `json:"api_v3_key"` // API V3 秘钥
|
||||
Domain string `json:"domain"` // 支付回调域名
|
||||
Enabled bool `json:"enabled,omitempty"` // 是否启用该支付通道
|
||||
AppId string `json:"app_id,omitempty"` // 公众号的APPID,如:wxd678efh567hg6787
|
||||
MchId string `json:"mch_id,omitempty"` // 直连商户的商户号,由微信支付生成并下发
|
||||
SerialNo string `json:"serial_no,omitempty"` // 商户证书的证书序列号
|
||||
PrivateKey string `json:"private_key,omitempty"` // 商户证书私钥
|
||||
ApiV3Key string `json:"api_v3_key,omitempty"` // API V3 秘钥
|
||||
Domain string `json:"domain,omitempty"` // 支付回调域名
|
||||
}
|
||||
|
||||
func (c *WxPayConfig) Equal(other *WxPayConfig) bool {
|
||||
@@ -45,11 +45,11 @@ func (c *WxPayConfig) Equal(other *WxPayConfig) bool {
|
||||
|
||||
// EpayConfig 易支付配置
|
||||
type EpayConfig struct {
|
||||
Enabled bool `json:"enabled"` // 是否启用该支付通道
|
||||
AppId string `json:"app_id"` // 商户 ID
|
||||
PrivateKey string `json:"private_key"` // 私钥
|
||||
ApiURL string `json:"api_url"` // z支付 API 网关
|
||||
Domain string `json:"domain"` // 支付回调域名
|
||||
Enabled bool `json:"enabled,omitempty"` // 是否启用该支付通道
|
||||
AppId string `json:"app_id,omitempty"` // 商户 ID
|
||||
PrivateKey string `json:"private_key,omitempty"` // 私钥
|
||||
ApiURL string `json:"api_url,omitempty"` // z支付 API 网关
|
||||
Domain string `json:"domain,omitempty"` // 支付回调域名
|
||||
}
|
||||
|
||||
func (c *EpayConfig) Equal(other *EpayConfig) bool {
|
||||
|
||||
@@ -8,23 +8,23 @@ package types
|
||||
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
type SMSConfig struct {
|
||||
Active string `json:"active"`
|
||||
Ali SmsConfigAli `json:"aliyun"`
|
||||
Bao SmsConfigBao `json:"bao"`
|
||||
Active string `json:"active,omitempty"`
|
||||
Ali SmsConfigAli `json:"aliyun,omitempty"`
|
||||
Bao SmsConfigBao `json:"bao,omitempty"`
|
||||
}
|
||||
|
||||
// SmsConfigAli 阿里云短信平台配置
|
||||
type SmsConfigAli struct {
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessSecret string `json:"access_secret"`
|
||||
Sign string `json:"sign"` // 短信签名
|
||||
CodeTempId string `json:"code_temp_id"` // 验证码短信模板 ID
|
||||
AccessKey string `json:"access_key,omitempty"`
|
||||
AccessSecret string `json:"access_secret,omitempty"`
|
||||
Sign string `json:"sign,omitempty"` // 短信签名
|
||||
CodeTempId string `json:"code_temp_id,omitempty"` // 验证码短信模板 ID
|
||||
}
|
||||
|
||||
// SmsConfigBao 短信宝平台配置
|
||||
type SmsConfigBao struct {
|
||||
Username string `json:"username"` //短信宝平台注册的用户名
|
||||
Password string `json:"password"` //短信宝平台注册的密码
|
||||
Sign string `json:"sign"` // 短信签名
|
||||
CodeTemplate string `json:"code_template"` // 验证码短信模板 匹配
|
||||
Username string `json:"username,omitempty"` //短信宝平台注册的用户名
|
||||
Password string `json:"password,omitempty"` //短信宝平台注册的密码
|
||||
Sign string `json:"sign,omitempty"` // 短信签名
|
||||
CodeTemplate string `json:"code_template,omitempty"` // 验证码短信模板 匹配
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ package types
|
||||
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
type SmtpConfig struct {
|
||||
UseTls bool `json:"use_tls"` // 是否使用 TLS 发送
|
||||
Host string `json:"host"` // 邮件服务器地址
|
||||
Port int `json:"port"` // 邮件服务器端口
|
||||
AppName string `json:"app_name"` // 应用名称
|
||||
From string `json:"from"` // 发件人邮箱地址
|
||||
Password string `json:"password"` // 发件人邮箱密码
|
||||
UseTls bool `json:"use_tls,omitempty"` // 是否使用 TLS 发送
|
||||
Host string `json:"host,omitempty"` // 邮件服务器地址
|
||||
Port int `json:"port,omitempty"` // 邮件服务器端口
|
||||
AppName string `json:"app_name,omitempty"` // 应用名称
|
||||
From string `json:"from,omitempty"` // 发件人邮箱地址
|
||||
Password string `json:"password,omitempty"` // 发件人邮箱密码
|
||||
}
|
||||
|
||||
func (s *SmtpConfig) Equal(other *SmtpConfig) bool {
|
||||
|
||||
@@ -272,9 +272,9 @@ func (h *ChatHandler) sendMessage(ctx context.Context, input ChatInput, c *gin.C
|
||||
if h.App.SysConfig.Base.ContextDeep > 0 {
|
||||
var historyMessages []model.ChatMessage
|
||||
dbSession := h.DB.Session(&gorm.Session{}).Where("chat_id", input.ChatId)
|
||||
if input.LastMsgId > 0 { // 重新生成逻辑
|
||||
if input.LastMsgId > 0 { // 重新生成和编辑逻辑
|
||||
var lastMessage model.ChatMessage
|
||||
err = dbSession.Where("id <= ?", input.LastMsgId).Where("type", types.PromptMsg).First(&lastMessage).Error
|
||||
err = dbSession.Where("id < ?", input.LastMsgId).Where("type", types.ReplyMsg).Order("id DESC").First(&lastMessage).Error
|
||||
if err != nil {
|
||||
input.LastMsgId = 0
|
||||
} else {
|
||||
@@ -282,7 +282,7 @@ func (h *ChatHandler) sendMessage(ctx context.Context, input ChatInput, c *gin.C
|
||||
}
|
||||
dbSession = dbSession.Where("id < ?", input.LastMsgId)
|
||||
// 删除对应的聊天记录
|
||||
h.DB.Debug().Where("chat_id", input.ChatId).Where("id >= ?", input.LastMsgId).Delete(&model.ChatMessage{})
|
||||
h.DB.Debug().Where("chat_id", input.ChatId).Where("id > ?", input.LastMsgId).Delete(&model.ChatMessage{})
|
||||
}
|
||||
err = dbSession.Limit(h.App.SysConfig.Base.ContextDeep).Order("id DESC").Find(&historyMessages).Error
|
||||
if err == nil {
|
||||
|
||||
@@ -179,6 +179,10 @@ func (h *JimengHandler) Jobs(c *gin.Context) {
|
||||
query = query.Where("type = ?", types.JMTaskTypeImage)
|
||||
case "video":
|
||||
query = query.Where("type = ?", types.JMTaskTypeVideo)
|
||||
case "virtual_human":
|
||||
query = query.Where("type = ?", types.JMTaskTypeVirtualHuman)
|
||||
case "action_transfer":
|
||||
query = query.Where("type = ?", types.JMTaskTypeActionTransfer)
|
||||
}
|
||||
|
||||
if len(req.Ids) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user