mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-04-28 22:14:28 +08:00
Dalle supported image to image
This commit is contained in:
@@ -70,17 +70,18 @@ type SdTaskParams struct {
|
|||||||
|
|
||||||
// DallTask DALL-E task
|
// DallTask DALL-E task
|
||||||
type DallTask struct {
|
type DallTask struct {
|
||||||
ModelId uint `json:"model_id"`
|
ModelId uint `json:"model_id"`
|
||||||
ModelName string `json:"model_name"`
|
ModelName string `json:"model_name"`
|
||||||
Id uint `json:"id"`
|
Image []string `json:"image,omitempty"`
|
||||||
UserId uint `json:"user_id"`
|
Id uint `json:"id"`
|
||||||
Prompt string `json:"prompt"`
|
UserId uint `json:"user_id"`
|
||||||
N int `json:"n"`
|
Prompt string `json:"prompt"`
|
||||||
Quality string `json:"quality"`
|
N int `json:"n"`
|
||||||
Size string `json:"size"`
|
Quality string `json:"quality"`
|
||||||
Style string `json:"style"`
|
Size string `json:"size"`
|
||||||
Power int `json:"power"`
|
Style string `json:"style"`
|
||||||
TranslateModelId int `json:"translate_model_id"` // 提示词翻译模型ID
|
Power int `json:"power"`
|
||||||
|
TranslateModelId int `json:"translate_model_id"` // 提示词翻译模型ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type SunoTask struct {
|
type SunoTask struct {
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ func (h *DallJobHandler) Image(c *gin.Context) {
|
|||||||
UserId: uint(userId),
|
UserId: uint(userId),
|
||||||
ModelId: chatModel.Id,
|
ModelId: chatModel.Id,
|
||||||
ModelName: chatModel.Value,
|
ModelName: chatModel.Value,
|
||||||
|
Image: data.Image,
|
||||||
Prompt: data.Prompt,
|
Prompt: data.Prompt,
|
||||||
Quality: data.Quality,
|
Quality: data.Quality,
|
||||||
Size: data.Size,
|
Size: data.Size,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"geekai/store"
|
"geekai/store"
|
||||||
"geekai/store/model"
|
"geekai/store/model"
|
||||||
"geekai/utils"
|
"geekai/utils"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
@@ -94,12 +95,14 @@ func (s *Service) Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type imgReq struct {
|
type imgReq struct {
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Prompt string `json:"prompt"`
|
Image []string `json:"image,omitempty"`
|
||||||
N int `json:"n,omitempty"`
|
Prompt string `json:"prompt"`
|
||||||
Size string `json:"size,omitempty"`
|
N int `json:"n,omitempty"`
|
||||||
Quality string `json:"quality,omitempty"`
|
Size string `json:"size,omitempty"`
|
||||||
Style string `json:"style,omitempty"`
|
Quality string `json:"quality,omitempty"`
|
||||||
|
Style string `json:"style,omitempty"`
|
||||||
|
ResponseFormat string `json:"response_format,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type imgRes struct {
|
type imgRes struct {
|
||||||
@@ -157,6 +160,11 @@ func (s *Service) Image(task types.DallTask, sync bool) (string, error) {
|
|||||||
Style: task.Style,
|
Style: task.Style,
|
||||||
Quality: task.Quality,
|
Quality: task.Quality,
|
||||||
}
|
}
|
||||||
|
// 图片编辑
|
||||||
|
if len(task.Image) > 0 {
|
||||||
|
reqBody.Prompt = fmt.Sprintf("%s, %s", strings.Join(task.Image, " "), task.Prompt)
|
||||||
|
}
|
||||||
|
|
||||||
logger.Infof("Channel:%s, API KEY:%s, BODY: %+v", apiURL, apiKey.Value, reqBody)
|
logger.Infof("Channel:%s, API KEY:%s, BODY: %+v", apiURL, apiKey.Value, reqBody)
|
||||||
r, err := s.httpClient.R().SetHeader("Body-Type", "application/json").
|
r, err := s.httpClient.R().SetHeader("Body-Type", "application/json").
|
||||||
SetHeader("Authorization", "Bearer "+apiKey.Value).
|
SetHeader("Authorization", "Bearer "+apiKey.Value).
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ const copyContent = (text) => {
|
|||||||
flex-flow: row;
|
flex-flow: row;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
justify-content: start;
|
||||||
|
|
||||||
.el-image {
|
.el-image {
|
||||||
border: 1px solid #e3e3e3;
|
border: 1px solid #e3e3e3;
|
||||||
@@ -365,6 +366,7 @@ const copyContent = (text) => {
|
|||||||
flex-flow: row;
|
flex-flow: row;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
justify-content: end;
|
||||||
|
|
||||||
.el-image {
|
.el-image {
|
||||||
border: 1px solid #e3e3e3;
|
border: 1px solid #e3e3e3;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
<el-icon :size="40" class="el-icon--upload"><UploadFilled /></el-icon>
|
<el-icon :size="40" class="el-icon--upload"><UploadFilled /></el-icon>
|
||||||
<div class="el-upload__text">拖拽图片到此处,或 <em>点击上传</em></div>
|
<div class="el-upload__text">拖拽图片到此处,或 <em>点击上传</em></div>
|
||||||
<template #tip>
|
<template #tip>
|
||||||
<div class="el-upload__tip text-center">
|
<div class="el-upload__tip text-gray-500 text-sm">
|
||||||
支持 JPG、PNG 格式,最多上传 {{ maxCount }} 张,单张最大 5MB
|
支持 JPG、PNG 格式,最多上传 {{ maxCount }} 张,单张最大 5MB
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -101,6 +101,13 @@
|
|||||||
<span v-else>生成中...</span>
|
<span v-else>生成中...</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2 mb-2">
|
||||||
|
<label class="text-gray-700 font-semibold">参考图(可选)</label>
|
||||||
|
<div class="py-2">
|
||||||
|
<ImageUpload v-model="params.image" :max-count="5" :multiple="true" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-4">
|
<div class="py-4">
|
||||||
@@ -295,6 +302,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
|||||||
import { onMounted, onUnmounted, ref } from 'vue'
|
import { onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { LazyImg, Waterfall } from 'vue-waterfall-plugin-next'
|
import { LazyImg, Waterfall } from 'vue-waterfall-plugin-next'
|
||||||
import 'vue-waterfall-plugin-next/dist/style.css'
|
import 'vue-waterfall-plugin-next/dist/style.css'
|
||||||
|
import ImageUpload from '@/components/ImageUpload.vue'
|
||||||
|
|
||||||
const listBoxHeight = ref(0)
|
const listBoxHeight = ref(0)
|
||||||
// const paramBoxHeight = ref(0)
|
// const paramBoxHeight = ref(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user