fix: Ensure explicit returns and correct async calls
Adds explicit `return None` statements in several functions across different modules to improve code clarity and prevent potential issues where functions might implicitly return None. Corrects an async call in `Heartflow.deactivate_chat` by adding `await`. Updates type hints in `heartflow_prompt_builder.py`. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from src.plugins.utils.chat_message_builder import build_readable_messages, get_
|
||||
from src.plugins.person_info.relationship_manager import relationship_manager
|
||||
from src.plugins.chat.utils import get_embedding, parse_text_timestamps
|
||||
import time
|
||||
from typing import Union
|
||||
from typing import Union, Optional
|
||||
from ...common.database import db
|
||||
from ..chat.utils import get_recent_group_speaker
|
||||
from ..moods.moods import MoodManager
|
||||
@@ -80,12 +80,13 @@ class PromptBuilder:
|
||||
|
||||
async def build_prompt(
|
||||
self, build_mode, reason, current_mind_info, message_txt: str, sender_name: str = "某人", chat_stream=None
|
||||
) -> tuple[str, str]:
|
||||
) -> Optional[tuple[str, str]]:
|
||||
if build_mode == "normal":
|
||||
return await self._build_prompt_normal(chat_stream, message_txt, sender_name)
|
||||
|
||||
elif build_mode == "focus":
|
||||
return await self._build_prompt_focus(reason, current_mind_info, chat_stream, message_txt, sender_name)
|
||||
return None
|
||||
|
||||
async def _build_prompt_focus(
|
||||
self, reason, current_mind_info, chat_stream, message_txt: str, sender_name: str = "某人"
|
||||
|
||||
@@ -689,7 +689,7 @@ class LLMRequest:
|
||||
stream_mode = request_content["stream_mode"]
|
||||
if response.status in policy["retry_codes"] or response.status in policy["abort_codes"]:
|
||||
await self._handle_error_response(response, retry_count, policy)
|
||||
return
|
||||
return None
|
||||
|
||||
response.raise_for_status()
|
||||
result = {}
|
||||
|
||||
Reference in New Issue
Block a user