feat: v0.12.3 种子值支持 + UI 修复
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m10s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m10s
①Seed 种子值全链路(后端传入/保存火山返回的seed/API返回,详情弹窗显示) ②前端种子值控件暂禁用(样式待调整) ③空页面文案改为品牌彩蛋 Every frame was once just air. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
493b30c6b9
commit
aa538443b6
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.29 on 2026-03-22 14:27
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('generation', '0009_generationrecord_is_favorited'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='generationrecord',
|
||||||
|
name='seed',
|
||||||
|
field=models.BigIntegerField(default=-1, verbose_name='种子值'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -45,6 +45,7 @@ class GenerationRecord(models.Model):
|
|||||||
error_message = models.TextField(blank=True, default='', verbose_name='错误信息')
|
error_message = models.TextField(blank=True, default='', verbose_name='错误信息')
|
||||||
reference_urls = models.JSONField(default=list, blank=True, verbose_name='参考素材信息')
|
reference_urls = models.JSONField(default=list, blank=True, verbose_name='参考素材信息')
|
||||||
is_favorited = models.BooleanField(default=False, verbose_name='已收藏')
|
is_favorited = models.BooleanField(default=False, verbose_name='已收藏')
|
||||||
|
seed = models.BigIntegerField(default=-1, verbose_name='种子值')
|
||||||
created_at = models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='创建时间')
|
created_at = models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='创建时间')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@ -162,6 +162,7 @@ def video_generate_view(request):
|
|||||||
model = serializer.validated_data['model']
|
model = serializer.validated_data['model']
|
||||||
aspect_ratio = serializer.validated_data['aspect_ratio']
|
aspect_ratio = serializer.validated_data['aspect_ratio']
|
||||||
search_mode = request.data.get('search_mode', 'off')
|
search_mode = request.data.get('search_mode', 'off')
|
||||||
|
seed = _safe_int(request.data.get('seed', -1), -1)
|
||||||
|
|
||||||
# ── 预估 token 和费用 ──
|
# ── 预估 token 和费用 ──
|
||||||
config = QuotaConfig.objects.get_or_create(pk=1)[0]
|
config = QuotaConfig.objects.get_or_create(pk=1)[0]
|
||||||
@ -329,6 +330,7 @@ def video_generate_view(request):
|
|||||||
cost_amount=0,
|
cost_amount=0,
|
||||||
base_cost_amount=0,
|
base_cost_amount=0,
|
||||||
reference_urls=reference_snapshots,
|
reference_urls=reference_snapshots,
|
||||||
|
seed=seed,
|
||||||
)
|
)
|
||||||
|
|
||||||
locked_team.frozen_amount = F('frozen_amount') + estimated_cost
|
locked_team.frozen_amount = F('frozen_amount') + estimated_cost
|
||||||
@ -346,6 +348,7 @@ def video_generate_view(request):
|
|||||||
aspect_ratio=aspect_ratio,
|
aspect_ratio=aspect_ratio,
|
||||||
duration=duration,
|
duration=duration,
|
||||||
search_mode=search_mode,
|
search_mode=search_mode,
|
||||||
|
seed=seed,
|
||||||
)
|
)
|
||||||
ark_task_id = ark_response.get('id', '')
|
ark_task_id = ark_response.get('id', '')
|
||||||
record.ark_task_id = ark_task_id
|
record.ark_task_id = ark_task_id
|
||||||
@ -479,6 +482,11 @@ def video_task_detail_view(request, task_id):
|
|||||||
new_status = map_status(ark_resp.get('status', ''))
|
new_status = map_status(ark_resp.get('status', ''))
|
||||||
record.status = new_status
|
record.status = new_status
|
||||||
|
|
||||||
|
# 保存火山返回的实际 seed 值
|
||||||
|
returned_seed = ark_resp.get('seed')
|
||||||
|
if returned_seed is not None:
|
||||||
|
record.seed = returned_seed
|
||||||
|
|
||||||
if new_status == 'completed':
|
if new_status == 'completed':
|
||||||
video_url = extract_video_url(ark_resp)
|
video_url = extract_video_url(ark_resp)
|
||||||
if video_url:
|
if video_url:
|
||||||
@ -513,7 +521,7 @@ def video_task_detail_view(request, task_id):
|
|||||||
# Seedance 未计费,释放冻结
|
# Seedance 未计费,释放冻结
|
||||||
_release_freeze(record)
|
_release_freeze(record)
|
||||||
|
|
||||||
record.save(update_fields=['status', 'result_url', 'error_message'])
|
record.save(update_fields=['status', 'result_url', 'error_message', 'seed'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception('AirDrama API query failed for %s', ark_task_id)
|
logger.exception('AirDrama API query failed for %s', ark_task_id)
|
||||||
|
|
||||||
@ -541,6 +549,7 @@ def _serialize_task(record):
|
|||||||
'error_message': d.get('error_message', ''),
|
'error_message': d.get('error_message', ''),
|
||||||
'reference_urls': d.get('reference_urls') or [],
|
'reference_urls': d.get('reference_urls') or [],
|
||||||
'is_favorited': record.is_favorited,
|
'is_favorited': record.is_favorited,
|
||||||
|
'seed': record.seed,
|
||||||
'created_at': record.created_at.isoformat(),
|
'created_at': record.created_at.isoformat(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ def _headers():
|
|||||||
|
|
||||||
|
|
||||||
def create_task(prompt, model, content_items, aspect_ratio, duration,
|
def create_task(prompt, model, content_items, aspect_ratio, duration,
|
||||||
generate_audio=True, search_mode='off'):
|
generate_audio=True, search_mode='off', seed=-1):
|
||||||
"""Create a video generation task.
|
"""Create a video generation task.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -106,6 +106,7 @@ def create_task(prompt, model, content_items, aspect_ratio, duration,
|
|||||||
'ratio': aspect_ratio,
|
'ratio': aspect_ratio,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'watermark': False,
|
'watermark': False,
|
||||||
|
'seed': seed,
|
||||||
}
|
}
|
||||||
|
|
||||||
if search_mode and search_mode != 'off':
|
if search_mode and search_mode != 'off':
|
||||||
|
|||||||
@ -383,6 +383,12 @@ export function GenerationCard({ task, onOpenDetail }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{(task.seed ?? -1) > 0 && (
|
||||||
|
<div className={styles.detailRow}>
|
||||||
|
<span>种子值</span>
|
||||||
|
<span>{task.seed}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
/* Hide number input spinners */
|
||||||
|
:global(.hide-spin::-webkit-outer-spin-button),
|
||||||
|
:global(.hide-spin::-webkit-inner-spin-button) {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.wrapper {
|
.wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 8px 16px 20px;
|
padding: 8px 16px 20px;
|
||||||
|
|||||||
@ -76,6 +76,10 @@ export function InputBar() {
|
|||||||
const [assetModalOpen, setAssetModalOpen] = useState(false);
|
const [assetModalOpen, setAssetModalOpen] = useState(false);
|
||||||
const searchMode = useInputBarStore((s) => s.searchMode);
|
const searchMode = useInputBarStore((s) => s.searchMode);
|
||||||
const setSearchMode = useInputBarStore((s) => s.setSearchMode);
|
const setSearchMode = useInputBarStore((s) => s.setSearchMode);
|
||||||
|
const seed = useInputBarStore((s) => s.seed);
|
||||||
|
const seedEnabled = useInputBarStore((s) => s.seedEnabled);
|
||||||
|
const setSeed = useInputBarStore((s) => s.setSeed);
|
||||||
|
const setSeedEnabled = useInputBarStore((s) => s.setSeedEnabled);
|
||||||
const references = useInputBarStore((s) => s.references);
|
const references = useInputBarStore((s) => s.references);
|
||||||
const editorHtml = useInputBarStore((s) => s.editorHtml);
|
const editorHtml = useInputBarStore((s) => s.editorHtml);
|
||||||
const firstFrame = useInputBarStore((s) => s.firstFrame);
|
const firstFrame = useInputBarStore((s) => s.firstFrame);
|
||||||
@ -118,6 +122,18 @@ export function InputBar() {
|
|||||||
>
|
>
|
||||||
联网搜索
|
联网搜索
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
disabled
|
||||||
|
style={{
|
||||||
|
background: 'transparent',
|
||||||
|
border: '1px solid var(--color-border-card)',
|
||||||
|
borderRadius: 6, padding: '4px 12px', fontSize: 12,
|
||||||
|
color: '#3a3a4a', cursor: 'not-allowed', transition: 'all 0.15s',
|
||||||
|
opacity: 0.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
种子值
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -532,6 +532,12 @@ export function VideoDetailModal({ task, onClose, onReEdit, onRegenerate, onDele
|
|||||||
<span>¥{(task.costAmount ?? 0).toFixed(2)}</span>
|
<span>¥{(task.costAmount ?? 0).toFixed(2)}</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{(task.seed ?? -1) > 0 && (
|
||||||
|
<>
|
||||||
|
<span className={styles.infoBarDot} />
|
||||||
|
<span>种子值: {task.seed}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -124,7 +124,7 @@ export function VideoGenerationPage() {
|
|||||||
<div className={styles.contentArea} ref={scrollRef} onScroll={handleScroll}>
|
<div className={styles.contentArea} ref={scrollRef} onScroll={handleScroll}>
|
||||||
{tasks.length === 0 ? (
|
{tasks.length === 0 ? (
|
||||||
<div className={styles.emptyArea}>
|
<div className={styles.emptyArea}>
|
||||||
<p className={styles.emptyHint}>在下方输入提示词,开始创作 AI 视频</p>
|
<p className={styles.emptyHint}>Every frame was once just air.</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={styles.taskList}>
|
<div className={styles.taskList}>
|
||||||
|
|||||||
@ -136,6 +136,7 @@ export const videoApi = {
|
|||||||
duration: number;
|
duration: number;
|
||||||
references: { url: string; type: string; role: string; label: string; thumb_url?: string }[];
|
references: { url: string; type: string; role: string; label: string; thumb_url?: string }[];
|
||||||
search_mode?: string;
|
search_mode?: string;
|
||||||
|
seed?: number;
|
||||||
}) =>
|
}) =>
|
||||||
api.post<{
|
api.post<{
|
||||||
task_id: string;
|
task_id: string;
|
||||||
|
|||||||
@ -106,6 +106,7 @@ function backendToFrontend(bt: BackendTask): GenerationTask {
|
|||||||
tokensConsumed: bt.tokens_consumed || 0,
|
tokensConsumed: bt.tokens_consumed || 0,
|
||||||
costAmount: bt.cost_amount || 0,
|
costAmount: bt.cost_amount || 0,
|
||||||
isFavorited: bt.is_favorited || false,
|
isFavorited: bt.is_favorited || false,
|
||||||
|
seed: bt.seed ?? -1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +169,7 @@ function startPolling(taskId: string, frontendId: string) {
|
|||||||
errorMessage: mapErrorMessage(data.error_message) || t.errorMessage,
|
errorMessage: mapErrorMessage(data.error_message) || t.errorMessage,
|
||||||
tokensConsumed: data.tokens_consumed ?? t.tokensConsumed,
|
tokensConsumed: data.tokens_consumed ?? t.tokensConsumed,
|
||||||
costAmount: data.cost_amount ?? t.costAmount,
|
costAmount: data.cost_amount ?? t.costAmount,
|
||||||
|
seed: data.seed ?? t.seed,
|
||||||
}
|
}
|
||||||
: t
|
: t
|
||||||
),
|
),
|
||||||
@ -373,6 +375,7 @@ export const useGenerationStore = create<GenerationState>((set, get) => ({
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
isFavorited: false,
|
isFavorited: false,
|
||||||
|
seed: input.seed ?? -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
set((s) => ({ tasks: [...s.tasks, placeholderTask] }));
|
set((s) => ({ tasks: [...s.tasks, placeholderTask] }));
|
||||||
@ -450,6 +453,7 @@ export const useGenerationStore = create<GenerationState>((set, get) => ({
|
|||||||
duration: input.duration,
|
duration: input.duration,
|
||||||
references: uploadedRefs,
|
references: uploadedRefs,
|
||||||
search_mode: input.searchMode || 'off',
|
search_mode: input.searchMode || 'off',
|
||||||
|
seed: input.seed ?? -1,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update task with real backend IDs
|
// Update task with real backend IDs
|
||||||
@ -552,6 +556,8 @@ export const useGenerationStore = create<GenerationState>((set, get) => ({
|
|||||||
label: r.label,
|
label: r.label,
|
||||||
tosUrl: r.previewUrl,
|
tosUrl: r.previewUrl,
|
||||||
}));
|
}));
|
||||||
|
const taskSeed = task.seed ?? -1;
|
||||||
|
const currentSeedEnabled = useInputBarStore.getState().seedEnabled;
|
||||||
useInputBarStore.setState({
|
useInputBarStore.setState({
|
||||||
prompt: task.prompt,
|
prompt: task.prompt,
|
||||||
editorHtml: task.editorHtml || task.prompt,
|
editorHtml: task.editorHtml || task.prompt,
|
||||||
@ -559,6 +565,8 @@ export const useGenerationStore = create<GenerationState>((set, get) => ({
|
|||||||
duration: task.duration,
|
duration: task.duration,
|
||||||
references,
|
references,
|
||||||
assetMentions: task.assetMentions || [],
|
assetMentions: task.assetMentions || [],
|
||||||
|
// 如果 seed 开关打开且 task 有有效 seed,填入;否则不动
|
||||||
|
...(currentSeedEnabled && taskSeed > 0 ? { seed: taskSeed } : {}),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Keyframe mode: restore firstFrame and lastFrame
|
// Keyframe mode: restore firstFrame and lastFrame
|
||||||
|
|||||||
@ -60,6 +60,12 @@ interface InputBarState {
|
|||||||
searchMode: 'smart' | 'off';
|
searchMode: 'smart' | 'off';
|
||||||
setSearchMode: (mode: 'smart' | 'off') => void;
|
setSearchMode: (mode: 'smart' | 'off') => void;
|
||||||
|
|
||||||
|
// Seed (种子值)
|
||||||
|
seed: number;
|
||||||
|
seedEnabled: boolean;
|
||||||
|
setSeed: (seed: number) => void;
|
||||||
|
setSeedEnabled: (enabled: boolean) => void;
|
||||||
|
|
||||||
// Asset mentions (for reEdit/regenerate to pass asset data to PromptInput rebuild)
|
// Asset mentions (for reEdit/regenerate to pass asset data to PromptInput rebuild)
|
||||||
assetMentions: { groupId: string; label: string; thumbUrl: string }[];
|
assetMentions: { groupId: string; label: string; thumbUrl: string }[];
|
||||||
|
|
||||||
@ -212,6 +218,11 @@ export const useInputBarStore = create<InputBarState>((set, get) => ({
|
|||||||
searchMode: 'off',
|
searchMode: 'off',
|
||||||
setSearchMode: (searchMode) => set({ searchMode }),
|
setSearchMode: (searchMode) => set({ searchMode }),
|
||||||
|
|
||||||
|
seed: -1,
|
||||||
|
seedEnabled: false,
|
||||||
|
setSeed: (seed) => set({ seed }),
|
||||||
|
setSeedEnabled: (seedEnabled) => set({ seedEnabled, seed: -1 }),
|
||||||
|
|
||||||
assetMentions: [],
|
assetMentions: [],
|
||||||
|
|
||||||
insertAtTrigger: 0,
|
insertAtTrigger: 0,
|
||||||
|
|||||||
@ -50,6 +50,7 @@ export interface GenerationTask {
|
|||||||
tokensConsumed?: number;
|
tokensConsumed?: number;
|
||||||
costAmount?: number;
|
costAmount?: number;
|
||||||
isFavorited?: boolean;
|
isFavorited?: boolean;
|
||||||
|
seed?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BackendTask {
|
export interface BackendTask {
|
||||||
@ -70,6 +71,7 @@ export interface BackendTask {
|
|||||||
error_message: string;
|
error_message: string;
|
||||||
reference_urls: { url: string; type: string; role: string; label: string }[];
|
reference_urls: { url: string; type: string; role: string; label: string }[];
|
||||||
is_favorited: boolean;
|
is_favorited: boolean;
|
||||||
|
seed: number;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user