feat: add title field to synopsis generation requests and update synopsis generation logic
This commit is contained in:
@@ -183,7 +183,7 @@ async def generate_synopsis(
|
||||
"暴力程度和色情程度数值越高,简介中相关情节描写越多、越直接。"
|
||||
"直接输出简介正文,不要加任何前缀标题或说明文字。"
|
||||
)
|
||||
parts = [f"类型:{data.genre}"]
|
||||
parts = [f"书名:{data.title}", f"类型:{data.genre}"]
|
||||
if data.subgenre:
|
||||
parts.append(f"子类型:{data.subgenre}")
|
||||
if data.protagonist_type:
|
||||
@@ -350,7 +350,7 @@ async def generate_synopsis_nsfw(
|
||||
"暴力程度和色情程度数值越高,简介中相关情节描写越多、越露骨直接。"
|
||||
"直接输出简介正文,不要加任何前缀标题或说明文字。"
|
||||
)
|
||||
parts = [f"类型:{data.genre}"]
|
||||
parts = [f"书名:{data.title}", f"类型:{data.genre}"]
|
||||
if data.subgenre:
|
||||
parts.append(f"子类型:{data.subgenre}")
|
||||
if data.protagonist_type:
|
||||
|
||||
@@ -329,7 +329,7 @@ class LLMService:
|
||||
fear = round(0.10 + 0.60 * v, 2)
|
||||
hate = round(0.35 + 0.25 * max(v, e), 2)
|
||||
low = round(0.35 + 0.45 * e, 2)
|
||||
surprise= round(0.15 + 0.35 * max(v, e), 2)
|
||||
surprise= round(0.10 + 0.35 * max(v, e), 2)
|
||||
limits = (
|
||||
f"愤怒={angry}、悲伤={sad}、恐惧={fear}、厌恶={hate}、低沉={low}、惊讶={surprise}、"
|
||||
f"开心:男性角色上限=0.20,女性角色上限={female_happy}"
|
||||
@@ -460,7 +460,7 @@ class LLMService:
|
||||
"emo_text 格式规则:\n"
|
||||
" 单一情感:直接填情感词,用 emo_alpha 设置强度,如 emo_text=\"开心\", emo_alpha=0.3\n"
|
||||
" 混合情感:用 情感词:比重 格式拼接,emo_alpha 设为 1.0,如 emo_text=\"开心:0.6+悲伤:0.2\", emo_alpha=1.0\n"
|
||||
"各情感比重上限(严格不超过):开心=0.20、愤怒=0.15、悲伤=0.1、恐惧=0.1、厌恶=0.35、低沉=0.35、惊讶=0.15。\n"
|
||||
"各情感比重上限(严格不超过):开心=0.20、愤怒=0.15、悲伤=0.1、恐惧=0.1、厌恶=0.35、低沉=0.35、惊讶=0.10。\n"
|
||||
"鼓励用低值(0.05–0.10)表达微弱或内敛的情绪,不要非强即无;完全无情绪色彩时 emo_text 置空。\n"
|
||||
"同一角色的连续台词,情绪应尽量保持一致或仅有微弱变化,避免相邻片段间情绪跳跃。\n"
|
||||
"只输出JSON数组,不要有其他文字,格式如下:\n"
|
||||
|
||||
@@ -10,6 +10,7 @@ class AudiobookProjectCreate(BaseModel):
|
||||
|
||||
|
||||
class SynopsisGenerationRequest(BaseModel):
|
||||
title: str
|
||||
genre: str
|
||||
subgenre: str = ""
|
||||
protagonist_type: str = ""
|
||||
@@ -138,6 +139,7 @@ class LLMConfigResponse(BaseModel):
|
||||
|
||||
|
||||
class NsfwSynopsisGenerationRequest(BaseModel):
|
||||
title: str
|
||||
genre: str
|
||||
subgenre: str = ""
|
||||
protagonist_type: str = ""
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import apiClient from '@/lib/api'
|
||||
|
||||
export interface SynopsisGenerationRequest {
|
||||
title: string
|
||||
genre: string
|
||||
subgenre?: string
|
||||
protagonist_type?: string
|
||||
@@ -83,6 +84,7 @@ export interface LLMConfig {
|
||||
}
|
||||
|
||||
export interface NsfwSynopsisGenerationRequest {
|
||||
title: string
|
||||
genre: string
|
||||
subgenre?: string
|
||||
protagonist_type?: string
|
||||
|
||||
@@ -547,10 +547,12 @@ function AIScriptDialog({ open, onClose, onCreated }: { open: boolean; onClose:
|
||||
}
|
||||
|
||||
const handleGenerateSynopsis = async () => {
|
||||
if (!title) { toast.error('请输入作品标题'); return }
|
||||
if (!genre) { toast.error('请选择故事类型'); return }
|
||||
setGeneratingSynopsis(true)
|
||||
try {
|
||||
const result = await audiobookApi.generateSynopsis({
|
||||
title,
|
||||
genre: subgenre ? `${genre} - ${subgenre}` : genre,
|
||||
subgenre,
|
||||
protagonist_type: protagonistType,
|
||||
@@ -780,10 +782,12 @@ function NSFWScriptDialog({ open, onClose, onCreated }: { open: boolean; onClose
|
||||
}
|
||||
|
||||
const handleGenerateSynopsis = async () => {
|
||||
if (!title) { toast.error('请输入作品标题'); return }
|
||||
if (!genre) { toast.error('请选择故事类型'); return }
|
||||
setGeneratingSynopsis(true)
|
||||
try {
|
||||
const result = await audiobookApi.generateNsfwSynopsis({
|
||||
title,
|
||||
genre: subgenre ? `${genre} - ${subgenre}` : genre,
|
||||
subgenre,
|
||||
protagonist_type: protagonistType,
|
||||
|
||||
Reference in New Issue
Block a user