fix:修复大纲世界观编辑bug update:更新不再限制最大token数
This commit is contained in:
@@ -732,22 +732,22 @@ async def outline_generator(
|
||||
db: AsyncSession,
|
||||
user_ai_service: AIService
|
||||
) -> AsyncGenerator[str, None]:
|
||||
"""大纲生成流式生成器 - 向导固定生成前8章作为开局"""
|
||||
"""大纲生成流式生成器 - 向导固定生成前5章作为开局"""
|
||||
db_committed = False
|
||||
try:
|
||||
yield await SSEResponse.send_progress("开始生成大纲...", 5)
|
||||
|
||||
project_id = data.get("project_id")
|
||||
# 向导固定生成8章,忽略传入的chapter_count
|
||||
chapter_count = 8
|
||||
# 向导固定生成5章,忽略传入的chapter_count
|
||||
chapter_count = 5
|
||||
narrative_perspective = data.get("narrative_perspective")
|
||||
target_words = data.get("target_words", 100000)
|
||||
requirements = data.get("requirements", "")
|
||||
provider = data.get("provider")
|
||||
model = data.get("model")
|
||||
|
||||
# 8章一次性生成,不需要分批
|
||||
BATCH_SIZE = 8
|
||||
# 5章一次性生成,不需要分批
|
||||
BATCH_SIZE = 5
|
||||
MAX_RETRIES = 3
|
||||
|
||||
# 获取项目信息
|
||||
@@ -809,7 +809,7 @@ async def outline_generator(
|
||||
previous_context += f"\n请确保第{start_chapter}-{end_chapter}章与前文情节自然衔接,保持故事连贯性。\n"
|
||||
|
||||
# 向导专用的开局大纲要求
|
||||
batch_requirements = f"{requirements}\n\n【重要说明】这是小说的开局部分,请生成前8章大纲,重点关注:\n"
|
||||
batch_requirements = f"{requirements}\n\n【重要说明】这是小说的开局部分,请生成前5章大纲,重点关注:\n"
|
||||
batch_requirements += "1. 引入主要角色和世界观设定\n"
|
||||
batch_requirements += "2. 建立主线冲突和故事钩子\n"
|
||||
batch_requirements += "3. 展开初期情节,为后续发展埋下伏笔\n"
|
||||
@@ -820,9 +820,9 @@ async def outline_generator(
|
||||
title=project.title,
|
||||
theme=project.theme or "未设定",
|
||||
genre=project.genre or "通用",
|
||||
chapter_count=8, # 固定8章
|
||||
chapter_count=5, # 固定5章
|
||||
narrative_perspective=narrative_perspective,
|
||||
target_words=target_words // 10, # 开局约占总字数的1/10
|
||||
target_words=target_words // 20, # 开局约占总字数的1/20
|
||||
time_period=project.world_time_period or "未设定",
|
||||
location=project.world_location or "未设定",
|
||||
atmosphere=project.world_atmosphere or "未设定",
|
||||
@@ -940,8 +940,8 @@ async def outline_generator(
|
||||
)
|
||||
db.add(chapter)
|
||||
|
||||
# 更新项目(向导固定生成8章作为开局)
|
||||
project.chapter_count = 8
|
||||
# 更新项目(向导固定生成5章作为开局)
|
||||
project.chapter_count = 5
|
||||
project.narrative_perspective = narrative_perspective
|
||||
project.target_words = target_words
|
||||
project.status = "writing"
|
||||
|
||||
@@ -13,7 +13,7 @@ class SettingsBase(BaseModel):
|
||||
api_base_url: Optional[str] = Field(default=None, description="自定义API地址")
|
||||
model_name: Optional[str] = Field(default="gpt-4", description="模型名称")
|
||||
temperature: Optional[float] = Field(default=0.7, ge=0.0, le=2.0, description="温度参数")
|
||||
max_tokens: Optional[int] = Field(default=2000, ge=1, le=32000, description="最大token数")
|
||||
max_tokens: Optional[int] = Field(default=2000, ge=1, description="最大token数")
|
||||
preferences: Optional[str] = Field(default=None, description="其他偏好设置(JSON)")
|
||||
|
||||
|
||||
|
||||
@@ -136,10 +136,6 @@ class PromptService:
|
||||
2. 不要在JSON字符串值中使用中文引号(""''),请使用英文引号或直接省略引号
|
||||
3. 专有名词和强调内容可以使用【】或《》标记,不要用引号
|
||||
|
||||
**正确示例**:
|
||||
- ✅ "距离【大灾变】爆发" 或 "距离大灾变爆发"
|
||||
- ❌ "距离"大灾变"爆发" (会导致JSON解析失败)
|
||||
|
||||
请严格按照以下JSON格式返回(每个字段为200-300字的文本描述):
|
||||
{{
|
||||
"time_period": "时间背景的详细描述,包括时代设定、时间特点、历史事件",
|
||||
|
||||
@@ -685,6 +685,7 @@ export default function ProjectWizardNew() {
|
||||
rules: worldBuilding.rules,
|
||||
});
|
||||
}}
|
||||
disabled={isEditingWorld}
|
||||
size={isMobile ? 'middle' : 'middle'}
|
||||
style={isMobile ? { minWidth: 100 } : undefined}
|
||||
>
|
||||
@@ -696,10 +697,12 @@ export default function ProjectWizardNew() {
|
||||
onConfirm={handleRegenerateWorldBuilding}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
disabled={isEditingWorld}
|
||||
>
|
||||
<Button
|
||||
icon={<RedoOutlined />}
|
||||
loading={isRegeneratingWorld}
|
||||
disabled={isEditingWorld}
|
||||
size={isMobile ? 'middle' : 'middle'}
|
||||
style={isMobile ? { minWidth: 100 } : undefined}
|
||||
>
|
||||
@@ -771,6 +774,7 @@ export default function ProjectWizardNew() {
|
||||
size="large"
|
||||
block
|
||||
onClick={handlePrev}
|
||||
disabled={isEditingWorld}
|
||||
style={{ height: isMobile ? 44 : 40 }}
|
||||
>
|
||||
上一步
|
||||
@@ -1019,12 +1023,12 @@ export default function ProjectWizardNew() {
|
||||
<Text strong style={{ marginLeft: 24 }}>目标字数:</Text>{basicInfo.target_words?.toLocaleString()} 字
|
||||
</Paragraph>
|
||||
<Paragraph type="secondary">
|
||||
向导将为您生成前8章的开局大纲,建立故事框架和主要冲突。后续您可以在大纲管理页面继续扩展故事。
|
||||
向导将为您生成前5章的开局大纲,建立故事框架和主要冲突。后续您可以在大纲管理页面继续扩展故事。
|
||||
</Paragraph>
|
||||
</div>
|
||||
|
||||
<Form layout="vertical" onFinish={() => handleGenerateOutline({
|
||||
chapter_count: 8, // 固定8章
|
||||
chapter_count: 5, // 固定5章
|
||||
narrative_perspective: basicInfo.narrative_perspective,
|
||||
target_words: basicInfo.target_words
|
||||
})}>
|
||||
@@ -1048,7 +1052,7 @@ export default function ProjectWizardNew() {
|
||||
loading={loading}
|
||||
style={{ height: isMobile ? 44 : 40 }}
|
||||
>
|
||||
{loading ? '生成开局大纲(8章)' : '生成开局大纲(8章)'}
|
||||
{loading ? '生成开局大纲(5章)' : '生成开局大纲(5章)'}
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -1086,7 +1090,7 @@ export default function ProjectWizardNew() {
|
||||
paddingLeft: isMobile ? 8 : 0,
|
||||
paddingRight: isMobile ? 8 : 0
|
||||
}}>
|
||||
《{basicInfo.title}》已成功创建,包含{characters.length}个角色和8章开局大纲
|
||||
《{basicInfo.title}》已成功创建,包含{characters.length}个角色和5章开局大纲
|
||||
</Paragraph>
|
||||
|
||||
<Space
|
||||
|
||||
@@ -480,14 +480,13 @@ export default function SettingsPage() {
|
||||
name="max_tokens"
|
||||
rules={[
|
||||
{ required: true, message: '请输入最大token数' },
|
||||
{ type: 'number', min: 1, max: 32000, message: '请输入1-32000之间的数字' }
|
||||
{ type: 'number', min: 1, message: '请输入大于0的数字' }
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
size={isMobile ? 'middle' : 'large'}
|
||||
style={{ width: '100%' }}
|
||||
min={1}
|
||||
max={32000}
|
||||
placeholder="2000"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
Reference in New Issue
Block a user