feat: midjourney drawing image function is ready

This commit is contained in:
RockYang
2023-08-14 17:59:21 +08:00
parent 6e40f92aaf
commit 5d2a1d21d5
13 changed files with 357 additions and 30 deletions

View File

@@ -27,7 +27,6 @@ import (
)
const ErrorMsg = "抱歉AI 助手开小差了,请稍后再试。"
const TaskStorePrefix = "/tasks/"
type ChatHandler struct {
BaseHandler
@@ -342,16 +341,16 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session types.ChatSession
content := data
if functionName == types.FuncMidJourney {
key := utils.Sha256(data)
//logger.Info(data, ",", key)
// add task for MidJourney
h.App.MjTaskClients.Put(key, ws)
task := types.MjTask{
UserId: userVo.Id,
RoleId: role.Id,
Icon: role.Icon,
Client: ws,
Icon: "/images/avatar/mid_journey.png",
ChatId: session.ChatId,
}
err := h.leveldb.Put(TaskStorePrefix+key, task)
err := h.leveldb.Put(types.TaskStorePrefix+key, task)
if err != nil {
logger.Error("error with store MidJourney task: ", err)
}