refactor(*): 代码质量治理 - 收敛接口客户端、模型职责与异步计费巡检
This commit is contained in:
1 parent
9ca9dd9df6
commit
b3199c5e7e
42 files changed
+3051
-2271
No files matched your search
@@ -164,20 +164,20 @@ type agentStoryboardPlan struct {
|
||||
}
|
||||
|
||||
type agentStoryboardShot struct {
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Duration int `json:"durationSeconds"`
|
||||
Dialogue string `json:"dialogue"`
|
||||
ShotSize string `json:"shotSize"`
|
||||
Emotion string `json:"emotion"`
|
||||
Lighting string `json:"lightingAndAtmosphere"`
|
||||
AudioEffects string `json:"audioEffects"`
|
||||
VisualPrompt string `json:"visualPrompt"`
|
||||
VideoPrompt string `json:"videoPrompt"`
|
||||
Camera string `json:"camera"`
|
||||
Motion string `json:"motion"`
|
||||
TimeBeats string `json:"timeBeats"`
|
||||
Negative string `json:"negativePrompt"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Duration int `json:"durationSeconds"`
|
||||
Dialogue string `json:"dialogue"`
|
||||
ShotSize string `json:"shotSize"`
|
||||
Emotion string `json:"emotion"`
|
||||
Lighting string `json:"lightingAndAtmosphere"`
|
||||
AudioEffects string `json:"audioEffects"`
|
||||
VisualPrompt string `json:"visualPrompt"`
|
||||
VideoPrompt string `json:"videoPrompt"`
|
||||
Camera string `json:"camera"`
|
||||
Motion string `json:"motion"`
|
||||
TimeBeats string `json:"timeBeats"`
|
||||
Negative string `json:"negativePrompt"`
|
||||
AssetTags []string `json:"assetTags"`
|
||||
CharacterIDs []string `json:"characterIds"`
|
||||
Intent string `json:"narrativeIntent"`
|
||||
@@ -196,6 +196,7 @@ func New(repo *repository.Repository, dataDir string) *Service {
|
||||
func (s *Service) StartWorker() {
|
||||
s.startTextReplayCleanup()
|
||||
s.startProviderCancellationReconciliation()
|
||||
s.startBillingReviewAudit()
|
||||
go func() {
|
||||
slots := make(chan struct{}, maxChannelConcurrencyLimit)
|
||||
dispatch := func() {
|
||||
@@ -1763,10 +1764,10 @@ func shotDescription(shot agentStoryboardShot) string {
|
||||
func storyboardImagePromptValues(projectStyle string, styleGuide string, shot agentStoryboardShot) map[string]string {
|
||||
negative := defaultString(strings.TrimSpace(shot.Negative), "禁止换脸、服装变化、手部畸形、乱码、风格突变和塑料材质")
|
||||
return map[string]string{
|
||||
"项目视觉": storyboardProjectVisualSummary(projectStyle, styleGuide),
|
||||
"首帧构图": compactPromptText(shot.VisualPrompt+";光影:"+shot.Lighting, 360),
|
||||
"项目视觉": storyboardProjectVisualSummary(projectStyle, styleGuide),
|
||||
"首帧构图": compactPromptText(shot.VisualPrompt+";光影:"+shot.Lighting, 360),
|
||||
"表演起始状态": compactPromptText(shot.Performance, 180),
|
||||
"负面要求": compactPromptText(negative, 140),
|
||||
"负面要求": compactPromptText(negative, 140),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1787,15 +1788,15 @@ func storyboardVideoPromptValues(projectStyle string, styleGuide string, shot ag
|
||||
timeBeats := defaultString(strings.TrimSpace(shot.TimeBeats), fmt.Sprintf("0-%d秒:%s", shot.Duration, strings.TrimSpace(shot.Description)))
|
||||
negative := defaultString(strings.TrimSpace(shot.Negative), "禁止换脸、服装变化、手部畸形、乱码、闪烁、风格突变和动作僵硬")
|
||||
values := map[string]string{
|
||||
"项目视觉": storyboardProjectVisualSummary(projectStyle, styleGuide),
|
||||
"镜头意图": compactPromptText(shot.Intent+";观众视点:"+shot.ViewerPOV+";情绪:"+shot.Emotion, 150),
|
||||
"首帧构图": compactPromptText(shot.VisualPrompt+";光影:"+shot.Lighting, 280),
|
||||
"项目视觉": storyboardProjectVisualSummary(projectStyle, styleGuide),
|
||||
"镜头意图": compactPromptText(shot.Intent+";观众视点:"+shot.ViewerPOV+";情绪:"+shot.Emotion, 150),
|
||||
"首帧构图": compactPromptText(shot.VisualPrompt+";光影:"+shot.Lighting, 280),
|
||||
"表演与调度": compactPromptText(shot.Performance, 180),
|
||||
"摄影机": compactPromptText(strings.TrimSpace(shot.ShotSize)+";"+camera+";主运镜:"+motion, 220),
|
||||
"时间节拍": compactPromptText(timeBeats, 240),
|
||||
"摄影机": compactPromptText(strings.TrimSpace(shot.ShotSize)+";"+camera+";主运镜:"+motion, 220),
|
||||
"时间节拍": compactPromptText(timeBeats, 240),
|
||||
"运动与结尾": compactPromptText(shot.VideoPrompt+";连续性结尾:"+shot.ContinuityOut, 240),
|
||||
"声音": compactPromptText(strings.TrimSpace(shot.Dialogue)+";音效:"+strings.TrimSpace(shot.AudioEffects), 160),
|
||||
"负面要求": compactPromptText(negative, 160),
|
||||
"声音": compactPromptText(strings.TrimSpace(shot.Dialogue)+";音效:"+strings.TrimSpace(shot.AudioEffects), 160),
|
||||
"负面要求": compactPromptText(negative, 160),
|
||||
}
|
||||
if len(shot.MustHave) > 0 {
|
||||
priority := "必须完成:" + strings.Join(shot.MustHave, ";")
|
||||
@@ -1945,65 +1946,6 @@ func (s *Service) markSessionFailed(task model.Task, message string) error {
|
||||
}
|
||||
return s.repo.Create(&model.Message{ID: newID(), UserID: task.UserID, SessionID: task.SessionID, Role: "assistant", Content: defaultString(message, "会话任务失败。")})
|
||||
}
|
||||
|
||||
func buildAgentResult(task model.Task) (map[string]any, []map[string]any) {
|
||||
title := strings.TrimSpace(task.Prompt)
|
||||
if len([]rune(title)) > 28 {
|
||||
title = string([]rune(title)[:28]) + "..."
|
||||
}
|
||||
result := map[string]any{
|
||||
"taskId": task.ID,
|
||||
"operation": task.Operation,
|
||||
"provider": defaultString(task.Provider, "internal-agent"),
|
||||
"model": defaultString(task.Model, "workflow-router"),
|
||||
"plan": []map[string]any{
|
||||
{"kind": "script", "title": "创意脚本", "content": task.Prompt},
|
||||
{"kind": "scene", "title": "主场景", "content": "根据用户输入拆解为可生成的视频场景。"},
|
||||
{"kind": "shot", "title": "镜头 1", "content": "建立画面、主体、风格和运镜。"},
|
||||
{"kind": "final", "title": "成片", "content": "等待视频生成 Provider 回填成片结果。"},
|
||||
},
|
||||
}
|
||||
ops := []map[string]any{
|
||||
nodeOp("script-"+task.ID, "text", "剧本 · "+title, 0, 0, "script", task.Prompt),
|
||||
nodeOp("scene-"+task.ID, "text", "场景 · 主场景", 380, 0, "scene", "主场景设定、角色关系、视觉风格。"),
|
||||
nodeOpWithMetadata("shot-"+task.ID, "video", "分镜 · 镜头 1", 760, 0, map[string]any{"workflowKind": "shot", "status": "idle", "generationMode": "video", "prompt": task.Prompt, "composerContent": task.Prompt, "videoEditOperation": "text_to_video"}),
|
||||
nodeOp("final-"+task.ID, "video", "成片 · 待生成", 1140, 0, "final", ""),
|
||||
connectOp("script-"+task.ID, "scene-"+task.ID),
|
||||
connectOp("scene-"+task.ID, "shot-"+task.ID),
|
||||
connectOp("shot-"+task.ID, "final-"+task.ID),
|
||||
}
|
||||
return result, ops
|
||||
}
|
||||
|
||||
func buildVideoWorkflowResult(task model.Task) (map[string]any, []map[string]any) {
|
||||
title := strings.TrimSpace(task.Prompt)
|
||||
if len([]rune(title)) > 28 {
|
||||
title = string([]rune(title)[:28]) + "..."
|
||||
}
|
||||
operation := defaultString(task.Operation, strings.TrimPrefix(task.Type, "video_"))
|
||||
result := map[string]any{
|
||||
"taskId": task.ID,
|
||||
"operation": operation,
|
||||
"provider": defaultString(task.Provider, "internal-agent"),
|
||||
"model": defaultString(task.Model, "workflow-router"),
|
||||
"plan": []map[string]any{
|
||||
{"kind": "reference_set", "title": "参考素材组", "content": "收集原视频、参考图、参考音频和版本样片。"},
|
||||
{"kind": "shot", "title": "编辑镜头", "content": task.Prompt},
|
||||
{"kind": "final", "title": "结果版本", "content": "等待 provider 生成或人工确认后回填版本结果。"},
|
||||
},
|
||||
}
|
||||
ops := []map[string]any{
|
||||
nodeOp("video-brief-"+task.ID, "text", "编辑需求 · "+title, 0, 0, "script", task.Prompt),
|
||||
nodeOpWithMetadata("video-ref-"+task.ID, "text", "参考素材组", 380, 0, map[string]any{"workflowKind": "reference_set", "status": "idle", "content": "原片、参考图、参考音频、风格板或历史版本。", "videoEditOperation": operation}),
|
||||
nodeOpWithMetadata("video-shot-"+task.ID, "video", "视频任务 · "+operation, 760, 0, map[string]any{"workflowKind": "shot", "status": "idle", "generationMode": "video", "prompt": task.Prompt, "composerContent": task.Prompt, "videoEditOperation": operation}),
|
||||
nodeOpWithMetadata("video-result-"+task.ID, "video", "结果版本 · 待回填", 1140, 0, map[string]any{"workflowKind": "final", "status": "idle", "videoEditOperation": operation, "versionLabel": "v1"}),
|
||||
connectOp("video-brief-"+task.ID, "video-ref-"+task.ID),
|
||||
connectOp("video-ref-"+task.ID, "video-shot-"+task.ID),
|
||||
connectOp("video-shot-"+task.ID, "video-result-"+task.ID),
|
||||
}
|
||||
return result, ops
|
||||
}
|
||||
|
||||
func nodeOp(id string, nodeType string, title string, x int, y int, workflowKind string, content string) map[string]any {
|
||||
return nodeOpWithMetadata(id, nodeType, title, x, y, map[string]any{"content": content, "workflowKind": workflowKind, "status": "idle"})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user