typing
This commit is contained in:
@@ -72,7 +72,6 @@ class ChatConfig(ConfigBase):
|
|||||||
max_context_size: int = 18
|
max_context_size: int = 18
|
||||||
"""上下文长度"""
|
"""上下文长度"""
|
||||||
|
|
||||||
|
|
||||||
replyer_random_probability: float = 0.5
|
replyer_random_probability: float = 0.5
|
||||||
"""
|
"""
|
||||||
发言时选择推理模型的概率(0-1之间)
|
发言时选择推理模型的概率(0-1之间)
|
||||||
@@ -138,11 +137,7 @@ class ChatConfig(ConfigBase):
|
|||||||
|
|
||||||
# 检查全局时段配置(第一个元素为空字符串的配置)
|
# 检查全局时段配置(第一个元素为空字符串的配置)
|
||||||
global_frequency = self._get_global_frequency()
|
global_frequency = self._get_global_frequency()
|
||||||
if global_frequency is not None:
|
return self.talk_frequency if global_frequency is None else global_frequency
|
||||||
return global_frequency
|
|
||||||
|
|
||||||
# 如果都没有匹配,返回默认值
|
|
||||||
return self.talk_frequency
|
|
||||||
|
|
||||||
def _get_time_based_frequency(self, time_freq_list: list[str]) -> Optional[float]:
|
def _get_time_based_frequency(self, time_freq_list: list[str]) -> Optional[float]:
|
||||||
"""
|
"""
|
||||||
@@ -294,6 +289,7 @@ class NormalChatConfig(ConfigBase):
|
|||||||
willing_mode: str = "classical"
|
willing_mode: str = "classical"
|
||||||
"""意愿模式"""
|
"""意愿模式"""
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ExpressionConfig(ConfigBase):
|
class ExpressionConfig(ConfigBase):
|
||||||
"""表达配置类"""
|
"""表达配置类"""
|
||||||
@@ -374,14 +370,14 @@ class ExpressionConfig(ConfigBase):
|
|||||||
|
|
||||||
# 优先检查聊天流特定的配置
|
# 优先检查聊天流特定的配置
|
||||||
if chat_stream_id:
|
if chat_stream_id:
|
||||||
specific_config = self._get_stream_specific_config(chat_stream_id)
|
specific_expression_config = self._get_stream_specific_config(chat_stream_id)
|
||||||
if specific_config is not None:
|
if specific_expression_config is not None:
|
||||||
return specific_config
|
return specific_expression_config
|
||||||
|
|
||||||
# 检查全局配置(第一个元素为空字符串的配置)
|
# 检查全局配置(第一个元素为空字符串的配置)
|
||||||
global_config = self._get_global_config()
|
global_expression_config = self._get_global_config()
|
||||||
if global_config is not None:
|
if global_expression_config is not None:
|
||||||
return global_config
|
return global_expression_config
|
||||||
|
|
||||||
# 如果都没有匹配,返回默认值
|
# 如果都没有匹配,返回默认值
|
||||||
return True, True, 300
|
return True, True, 300
|
||||||
@@ -417,10 +413,10 @@ class ExpressionConfig(ConfigBase):
|
|||||||
|
|
||||||
# 解析配置
|
# 解析配置
|
||||||
try:
|
try:
|
||||||
use_expression = config_item[1].lower() == "enable"
|
use_expression: bool = config_item[1].lower() == "enable"
|
||||||
enable_learning = config_item[2].lower() == "enable"
|
enable_learning: bool = config_item[2].lower() == "enable"
|
||||||
learning_intensity = float(config_item[3])
|
learning_intensity: float = float(config_item[3])
|
||||||
return use_expression, enable_learning, learning_intensity
|
return use_expression, enable_learning, learning_intensity # type: ignore
|
||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -440,10 +436,10 @@ class ExpressionConfig(ConfigBase):
|
|||||||
# 检查是否为全局配置(第一个元素为空字符串)
|
# 检查是否为全局配置(第一个元素为空字符串)
|
||||||
if config_item[0] == "":
|
if config_item[0] == "":
|
||||||
try:
|
try:
|
||||||
use_expression = config_item[1].lower() == "enable"
|
use_expression: bool = config_item[1].lower() == "enable"
|
||||||
enable_learning = config_item[2].lower() == "enable"
|
enable_learning: bool = config_item[2].lower() == "enable"
|
||||||
learning_intensity = float(config_item[3])
|
learning_intensity = float(config_item[3])
|
||||||
return use_expression, enable_learning, learning_intensity
|
return use_expression, enable_learning, learning_intensity # type: ignore
|
||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -457,6 +453,7 @@ class ToolConfig(ConfigBase):
|
|||||||
enable_tool: bool = False
|
enable_tool: bool = False
|
||||||
"""是否在聊天中启用工具"""
|
"""是否在聊天中启用工具"""
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class VoiceConfig(ConfigBase):
|
class VoiceConfig(ConfigBase):
|
||||||
"""语音识别配置类"""
|
"""语音识别配置类"""
|
||||||
@@ -604,6 +601,7 @@ class KeywordReactionConfig(ConfigBase):
|
|||||||
if not isinstance(rule, KeywordRuleConfig):
|
if not isinstance(rule, KeywordRuleConfig):
|
||||||
raise ValueError(f"规则必须是KeywordRuleConfig类型,而不是{type(rule).__name__}")
|
raise ValueError(f"规则必须是KeywordRuleConfig类型,而不是{type(rule).__name__}")
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CustomPromptConfig(ConfigBase):
|
class CustomPromptConfig(ConfigBase):
|
||||||
"""自定义提示词配置类"""
|
"""自定义提示词配置类"""
|
||||||
@@ -752,4 +750,3 @@ class LPMMKnowledgeConfig(ConfigBase):
|
|||||||
|
|
||||||
embedding_dimension: int = 1024
|
embedding_dimension: int = 1024
|
||||||
"""嵌入向量维度,应该与模型的输出维度一致"""
|
"""嵌入向量维度,应该与模型的输出维度一致"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user