feat(prompt): AI 提示词优化双栏交互
新增 prompt API 模块调用后端 /api/v1/prompt/optimize,PromptEditor 重构为左右双栏布局支持原始/优化提示词对比编辑,默认开启 AI 优化, 用户可关闭开关或手动编辑优化结果后再提交生成。
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { post } from './client'
|
||||
import { STYLE_CATEGORIES } from '../utils/style'
|
||||
|
||||
interface OptimizePromptParams {
|
||||
tags: string[]
|
||||
assetType: string
|
||||
prompt: string
|
||||
userNote?: string
|
||||
}
|
||||
|
||||
interface OptimizePromptResponse {
|
||||
prompt: string
|
||||
rawText: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 从风格键值对中提取标签的中文名称作为 tags
|
||||
*/
|
||||
export function extractTags(style: Record<string, string>): string[] {
|
||||
return STYLE_CATEGORIES.flatMap(cat => {
|
||||
const value = style[cat.key]
|
||||
if (!value) return []
|
||||
const option = cat.options.find(o => o.value === value)
|
||||
return option ? [option.label] : []
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用后端提示词优化接口
|
||||
*/
|
||||
export async function optimizePrompt(
|
||||
params: OptimizePromptParams,
|
||||
): Promise<OptimizePromptResponse> {
|
||||
return post<OptimizePromptResponse>('/api/v1/prompt/optimize', params)
|
||||
}
|
||||
Reference in New Issue
Block a user