fix: 修复视频多图请求与历史提示词
This commit is contained in:
1 parent
76d2d625ef
commit
bf86ff98ba
3 files changed
+33
-8
No files matched your search
@@ -59,7 +59,6 @@ def _extract_image_post_id(value: str) -> str:
|
||||
matches = re.findall(r"([0-9a-fA-F-]{32,36})", text)
|
||||
return matches[-1] if matches else ""
|
||||
|
||||
|
||||
async def _try_log_image_share_link(
|
||||
token: str,
|
||||
post_id: str,
|
||||
@@ -793,6 +792,8 @@ class ImageEditService:
|
||||
request_url = raw_source
|
||||
mention_id = original_id
|
||||
attachment_id = ""
|
||||
resolved_url = ""
|
||||
resolved_id = ""
|
||||
should_upload_for_attachment = _needs_image_edit_reference_upload(
|
||||
item, raw_source
|
||||
)
|
||||
|
||||
@@ -39,7 +39,6 @@ from app.services.grok.utils.upload import UploadService
|
||||
|
||||
_VIDEO_SEMAPHORE = None
|
||||
_VIDEO_SEM_VALUE = 0
|
||||
|
||||
def _get_video_semaphore() -> asyncio.Semaphore:
|
||||
"""Reverse 接口并发控制(video 服务)。"""
|
||||
global _VIDEO_SEMAPHORE, _VIDEO_SEM_VALUE
|
||||
@@ -110,7 +109,6 @@ def _normalize_assets_url(value: str) -> str:
|
||||
return f"https://assets.grok.com{raw}"
|
||||
return f"https://assets.grok.com/{raw}"
|
||||
|
||||
|
||||
def _log_final_video_payload(
|
||||
*,
|
||||
message: str,
|
||||
@@ -425,7 +423,10 @@ class VideoService:
|
||||
source_url = await self._resolve_reference_source_url(token, item)
|
||||
if not source_url:
|
||||
raise ValidationException(f"第 {index + 1} 张参考图缺少可用来源")
|
||||
file_id, file_uri = await upload_service.upload_file(source_url, token)
|
||||
uploaded_file_id, file_uri = await upload_service.upload_file(
|
||||
source_url, token
|
||||
)
|
||||
file_id = str(uploaded_file_id or "").strip()
|
||||
asset_url = _normalize_assets_url(file_uri)
|
||||
uploaded.append(
|
||||
{
|
||||
|
||||
@@ -1120,6 +1120,9 @@
|
||||
const title = document.createElement('div');
|
||||
title.className = 'video-item-title';
|
||||
title.textContent = `视频 ${previewCount}`;
|
||||
|
||||
const prompt = document.createElement('div');
|
||||
prompt.className = 'video-item-prompt hidden';
|
||||
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'video-item-actions video-item-actions-overlay';
|
||||
@@ -1146,6 +1149,7 @@
|
||||
actions.appendChild(downloadBtn);
|
||||
actions.appendChild(editBtn);
|
||||
header.appendChild(title);
|
||||
header.appendChild(prompt);
|
||||
|
||||
const body = document.createElement('div');
|
||||
body.className = 'video-item-body';
|
||||
@@ -1387,7 +1391,8 @@
|
||||
mention_alias: String(item && item.mentionLabel ? item.mentionLabel : getReferenceMentionLabel(index)).trim()
|
||||
})).filter((item) => item.parent_post_id || item.image_url || item.source_image_url);
|
||||
|
||||
const primaryRef = referenceItems[0] || null;
|
||||
const hasReferenceItems = referenceItems.length > 0;
|
||||
const primaryRef = hasReferenceItems ? null : (referenceItems[0] || null);
|
||||
const parentPostId = primaryRef ? String(primaryRef.parent_post_id || '').trim() : '';
|
||||
const imageUrl = primaryRef ? String(primaryRef.image_url || primaryRef.source_image_url || '').trim() : '';
|
||||
const sourceImageUrl = primaryRef ? String(primaryRef.source_image_url || primaryRef.image_url || '').trim() : '';
|
||||
@@ -1400,9 +1405,9 @@
|
||||
},
|
||||
body: JSON.stringify({
|
||||
prompt,
|
||||
image_url: parentPostId ? null : (imageUrl || null),
|
||||
parent_post_id: parentPostId || null,
|
||||
source_image_url: parentPostId ? (sourceImageUrl || null) : null,
|
||||
image_url: hasReferenceItems ? null : (parentPostId ? null : (imageUrl || null)),
|
||||
parent_post_id: hasReferenceItems ? null : (parentPostId || null),
|
||||
source_image_url: hasReferenceItems ? null : (parentPostId ? (sourceImageUrl || null) : null),
|
||||
reference_items: referenceItems,
|
||||
reasoning_effort: DEFAULT_REASONING_EFFORT,
|
||||
aspect_ratio: ratioSelect ? ratioSelect.value : '3:2',
|
||||
@@ -1533,6 +1538,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
function setPreviewPrompt(item, text) {
|
||||
if (!item) return;
|
||||
const promptEl = item.querySelector('.video-item-prompt');
|
||||
const promptText = String(text || '').trim();
|
||||
item.dataset.prompt = promptText;
|
||||
if (!promptEl) return;
|
||||
if (promptText) {
|
||||
promptEl.textContent = promptText;
|
||||
promptEl.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
promptEl.textContent = '';
|
||||
promptEl.classList.add('hidden');
|
||||
}
|
||||
|
||||
function getSelectedVideoItem() {
|
||||
if (!selectedVideoItemId || !videoStage) return null;
|
||||
return videoStage.querySelector(`.video-item[data-index="${selectedVideoItemId}"]`);
|
||||
@@ -1942,6 +1962,7 @@
|
||||
updateMeta();
|
||||
resetOutput(true);
|
||||
setStatus('connecting', '连接中');
|
||||
const promptText = promptInput ? String(promptInput.value || '').trim() : '';
|
||||
|
||||
let taskIds = [];
|
||||
try {
|
||||
@@ -1965,6 +1986,7 @@
|
||||
for (const taskId of taskIds) {
|
||||
const previewItem = initPreviewSlot();
|
||||
setPreviewTitle(previewItem, buildHistoryTitle('generated', previewItem && previewItem.dataset ? previewItem.dataset.index : previewCount));
|
||||
setPreviewPrompt(previewItem, promptText);
|
||||
taskStates.set(taskId, {
|
||||
taskId,
|
||||
source: null,
|
||||
@@ -2279,6 +2301,7 @@
|
||||
for (const tid of taskIds) {
|
||||
const placeholder = initPreviewSlot();
|
||||
setPreviewTitle(placeholder, buildHistoryTitle('splice', serial));
|
||||
setPreviewPrompt(placeholder, prompt);
|
||||
if (placeholder) placeholder.dataset.taskId = tid;
|
||||
spliceRun.placeholders.set(tid, placeholder);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user