- 用户域:注册/登录(JWT)/修改密码/个人资料 - 照片/衣橱/身形/化身:上传存储 + 3D 化身模板匹配 - 穿搭生成:天气(高德+和风+缓存) → 规则预筛 → LLM 规划(1次调用) → 规则评分(5维100分制) → 全低分触发 LLM 兜底创作 → 异步任务状态机 - 效果图:选主方案后异步生成 3 视角(mock/wanx 供应商 + 内容 hash 缓存 + 每日限额) - 商业化:合作门店列表(seed 4 家) - 冒烟:全链路端到端验证通过(mock LLM/天气),23 个 API 端点 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package imagegen
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
|
||
"github.com/gogf/gf/v2/frame/g"
|
||
)
|
||
|
||
// ImageGenClient 效果图生成客户端
|
||
type ImageGenClient interface {
|
||
// Generate 生成单张效果图,返回图片 URL
|
||
Generate(ctx context.Context, req *GenerateReq) (string, error)
|
||
}
|
||
|
||
// GenerateReq 生成请求
|
||
type GenerateReq struct {
|
||
BaseImageURL string // 用户全身照
|
||
Prompt string // 方案描述
|
||
Angle string // 正面/侧面/背面
|
||
Seed int64
|
||
}
|
||
|
||
// NewClient 按供应商创建客户端(config 未配置 Key 时强制 mock)
|
||
func NewClient(supplier string) ImageGenClient {
|
||
if supplier == "wanx" {
|
||
key := g.Cfg().MustGet(context.Background(), "imagegen.wanx_api_key", "").String()
|
||
if key != "" {
|
||
return &wanxClient{
|
||
apiKey: key,
|
||
model: g.Cfg().MustGet(context.Background(), "imagegen.wanx_model", "wanx-v2").String(),
|
||
base: "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis",
|
||
}
|
||
}
|
||
}
|
||
return &mockClient{}
|
||
}
|
||
|
||
// buildPrompt 组装方案描述 prompt
|
||
func buildPrompt(planDesc, hairstyle, hairColor, angle string) string {
|
||
return fmt.Sprintf("时尚穿搭效果图,%s;发型:%s(发色 %s);角度:%s;人物写实、高清、全身、纯色背景",
|
||
planDesc, hairstyle, hairColor, angle)
|
||
}
|