mirror of
https://github.com/TheSmallHanCat/sora2api.git
synced 2026-03-07 03:07:36 +08:00
fix: 思维链内容输出
This commit is contained in:
@@ -407,7 +407,8 @@ class GenerationHandler:
|
|||||||
image: Optional[str] = None,
|
image: Optional[str] = None,
|
||||||
video: Optional[str] = None,
|
video: Optional[str] = None,
|
||||||
remix_target_id: Optional[str] = None,
|
remix_target_id: Optional[str] = None,
|
||||||
stream: bool = True) -> AsyncGenerator[str, None]:
|
stream: bool = True,
|
||||||
|
show_init_message: bool = True) -> AsyncGenerator[str, None]:
|
||||||
"""Handle generation request
|
"""Handle generation request
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -417,6 +418,7 @@ class GenerationHandler:
|
|||||||
video: Base64 encoded video or video URL
|
video: Base64 encoded video or video URL
|
||||||
remix_target_id: Sora share link video ID for remix
|
remix_target_id: Sora share link video ID for remix
|
||||||
stream: Whether to stream response
|
stream: Whether to stream response
|
||||||
|
show_init_message: Whether to show "Generation Process Begins" message
|
||||||
"""
|
"""
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
log_id = None # Initialize log_id to avoid reference before assignment
|
log_id = None # Initialize log_id to avoid reference before assignment
|
||||||
@@ -552,7 +554,7 @@ class GenerationHandler:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Generate
|
# Generate
|
||||||
if stream:
|
if stream and show_init_message:
|
||||||
if is_first_chunk:
|
if is_first_chunk:
|
||||||
yield self._format_stream_chunk(
|
yield self._format_stream_chunk(
|
||||||
reasoning_content="**Generation Process Begins**\n\nInitializing generation request...\n",
|
reasoning_content="**Generation Process Begins**\n\nInitializing generation request...\n",
|
||||||
@@ -767,7 +769,9 @@ class GenerationHandler:
|
|||||||
while retry_count <= max_retries:
|
while retry_count <= max_retries:
|
||||||
try:
|
try:
|
||||||
# Try generation
|
# Try generation
|
||||||
async for chunk in self.handle_generation(model, prompt, image, video, remix_target_id, stream):
|
# Only show init message on first attempt (not on retries)
|
||||||
|
show_init = (retry_count == 0)
|
||||||
|
async for chunk in self.handle_generation(model, prompt, image, video, remix_target_id, stream, show_init_message=show_init):
|
||||||
yield chunk
|
yield chunk
|
||||||
# If successful, return
|
# If successful, return
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user