会话添加类型,添加制作ppt接口
This commit is contained in:
parent
5fd12a447e
commit
1099401351
|
|
@ -12,6 +12,7 @@ type Session struct {
|
|||
gorm.Model
|
||||
UserID int `gorm:"column:user_id"` //只能由用户创建
|
||||
Name string `gorm:"column:name"`
|
||||
Type int `gorm:"column:type"` //会话类型:1为通用聊天会话,2为提示词会话,3为制作ppt会话
|
||||
Context json.RawMessage `gorm:"column:context;type:json"` //会话上下文
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ func SetUpToolGroup(router *gin.Engine) {
|
|||
toolGroup.POST("/send_mail", SendMailTool)
|
||||
toolGroup.POST("/dashboard", DashBoardStatistics)
|
||||
toolGroup.POST("/spark_ppt_theme_list", GetSparkPPTThemeList)
|
||||
toolGroup.POST("/spark_create_outline", CreateSparkPPTSOutline)
|
||||
toolGroup.POST("/spark_create_ppt", CreateSparkPPT)
|
||||
}
|
||||
|
||||
func SetDeviceStatusV2(c *gin.Context) {
|
||||
|
|
@ -418,6 +420,8 @@ func DashBoardStatistics(c *gin.Context) {
|
|||
}
|
||||
|
||||
func GetSparkPPTThemeList(c *gin.Context) {
|
||||
//id := c.Param("id")
|
||||
//userID, _ := strconv.Atoi(id)
|
||||
var req proto.GetSparkPPTThemeReq
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
if req.Style == "" || req.Color == "" || req.Industry == "" {
|
||||
|
|
@ -456,3 +460,44 @@ func GetSparkPPTThemeList(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
func CreateSparkPPTSOutline(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
userID, _ := strconv.Atoi(id)
|
||||
var req proto.SparkCreateOutlineRequest
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
if req.Function == "" || req.Query == "" {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "function or query is empty", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
if req.FileUrl != "" && req.FileName == "" {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "file name is empty", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
outlineResp, err2 := spark.SparkDoCreateOutline(&req, userID)
|
||||
if err2 != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "create outline error", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": outlineResp})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func CreateSparkPPT(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
userID, _ := strconv.Atoi(id)
|
||||
var req proto.SparkCreatePPTByOutlineUserRequest
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
if req.Function == "" || req.Query == "" {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "function or query is empty", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
spark.SparkDoCreatePPTByOutline(&req, userID)
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ const (
|
|||
UserToModelImageMsgType = 3
|
||||
//模型发送文件对话
|
||||
ModelToUserFileMsgType = 4
|
||||
//用户与模型制作ppt的会话
|
||||
UserToModelPPTMsgType = 5 //用户与模型制作ppt的会话
|
||||
)
|
||||
|
||||
// 豆包返回的数据停止原因
|
||||
|
|
@ -152,3 +154,10 @@ const (
|
|||
UserFileTypeConfig = "config" // 配置文件
|
||||
UserMaxUploadSize = 1024 * 1024 * 100
|
||||
)
|
||||
|
||||
// 会话类型
|
||||
const (
|
||||
SessionTypeUserWithModelGeneration = 1 // 用户与模型通用会话
|
||||
SessionTypeUserPrompt = 2 // 用户与模型提示词
|
||||
SessionTypeUserCreatePPT = 3 // 用户与模型制作PPT
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package spark
|
|||
|
||||
import (
|
||||
"StuAcaWorksAI/proto"
|
||||
"StuAcaWorksAI/service"
|
||||
"StuAcaWorksAI/worker"
|
||||
"encoding/json"
|
||||
"log"
|
||||
|
|
@ -191,3 +192,37 @@ func SparkGetPPTInfoBySID(model *proto.ModelParam, userReq *proto.SparkCreatePPT
|
|||
log.Println("Spark create ppt by outline Response struct:", response)
|
||||
return response, err
|
||||
}
|
||||
|
||||
// 处理制作大纲请求
|
||||
func SparkDoCreateOutline(userReq *proto.SparkCreateOutlineRequest, userID int) (proto.SparkCreateOutlineResponse, error) {
|
||||
var modelParam proto.ModelParam
|
||||
var err error
|
||||
//获取模型
|
||||
models, funcs, mferr := service.FindFuncModelListByFunctionV2(userReq.Function)
|
||||
if mferr != nil {
|
||||
return proto.SparkCreateOutlineResponse{}, mferr
|
||||
}
|
||||
model := models[0]
|
||||
err = json.Unmarshal([]byte(model.Parameter), &modelParam)
|
||||
if err != nil {
|
||||
return proto.SparkCreateOutlineResponse{}, err
|
||||
}
|
||||
modelParam.Url = model.Url
|
||||
modelParam.System = funcs[0].Info //系统功能
|
||||
var outline proto.SparkCreateOutlineResponse
|
||||
|
||||
//获取主题列表
|
||||
if userReq.FileUrl == "" {
|
||||
outline, err = SparkCreateOutline(&modelParam, userReq) //根据query生成大纲
|
||||
} else {
|
||||
outline, err = SparkCreateOutlineByDoc(&modelParam, userReq) //根据文档生成大纲
|
||||
}
|
||||
//进行保存
|
||||
|
||||
return outline, err
|
||||
}
|
||||
|
||||
// 处理制作PPT请求
|
||||
func SparkDoCreatePPTByOutline(userReq *proto.SparkCreatePPTByOutlineUserRequest, userID int) {
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue