feat:以巧妙地方式表达人格
This commit is contained in:
@@ -153,6 +153,7 @@ class BotConfig:
|
|||||||
"用一句话或几句话描述人格的一些侧面",
|
"用一句话或几句话描述人格的一些侧面",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
expression_style = "描述麦麦说话的表达风格,表达习惯"
|
||||||
# identity
|
# identity
|
||||||
identity_detail: List[str] = field(
|
identity_detail: List[str] = field(
|
||||||
default_factory=lambda: [
|
default_factory=lambda: [
|
||||||
@@ -360,6 +361,8 @@ class BotConfig:
|
|||||||
if config.INNER_VERSION in SpecifierSet(">=1.2.4"):
|
if config.INNER_VERSION in SpecifierSet(">=1.2.4"):
|
||||||
config.personality_core = personality_config.get("personality_core", config.personality_core)
|
config.personality_core = personality_config.get("personality_core", config.personality_core)
|
||||||
config.personality_sides = personality_config.get("personality_sides", config.personality_sides)
|
config.personality_sides = personality_config.get("personality_sides", config.personality_sides)
|
||||||
|
if config.INNER_VERSION in SpecifierSet(">=1.7.0"):
|
||||||
|
config.expression_style = personality_config.get("expression_style", config.expression_style)
|
||||||
|
|
||||||
def identity(parent: dict):
|
def identity(parent: dict):
|
||||||
identity_config = parent["identity"]
|
identity_config = parent["identity"]
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ def init_prompt() -> None:
|
|||||||
"""
|
"""
|
||||||
Prompt(personality_expression_prompt, "personality_expression_prompt")
|
Prompt(personality_expression_prompt, "personality_expression_prompt")
|
||||||
|
|
||||||
peronality = "情绪敏感,有时候有些搞怪幽默, 是一个女大学生,现在在读大二,你会刷贴吧"
|
|
||||||
|
|
||||||
class ExpressionLearner:
|
class ExpressionLearner:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
@@ -230,7 +229,7 @@ class ExpressionLearner:
|
|||||||
# 构建prompt
|
# 构建prompt
|
||||||
prompt = await global_prompt_manager.format_prompt(
|
prompt = await global_prompt_manager.format_prompt(
|
||||||
"personality_expression_prompt",
|
"personality_expression_prompt",
|
||||||
personality=peronality,
|
personality=global_config.expression_style,
|
||||||
)
|
)
|
||||||
logger.info(f"个性表达方式提取prompt: {prompt}")
|
logger.info(f"个性表达方式提取prompt: {prompt}")
|
||||||
response, _ = await self.express_learn_model.generate_response_async(prompt)
|
response, _ = await self.express_learn_model.generate_response_async(prompt)
|
||||||
|
|||||||
@@ -246,7 +246,9 @@ async def _build_prompt_focus(
|
|||||||
structured_info_prompt = ""
|
structured_info_prompt = ""
|
||||||
|
|
||||||
# 从/data/expression/对应chat_id/expressions.json中读取表达方式
|
# 从/data/expression/对应chat_id/expressions.json中读取表达方式
|
||||||
learnt_expressions, personality_expressions = await expression_learner.get_expression_by_chat_id(chat_stream.stream_id)
|
learnt_expressions, personality_expressions = await expression_learner.get_expression_by_chat_id(
|
||||||
|
chat_stream.stream_id
|
||||||
|
)
|
||||||
language_habits = []
|
language_habits = []
|
||||||
# 1. learnt_expressions加权随机选5条
|
# 1. learnt_expressions加权随机选5条
|
||||||
if learnt_expressions:
|
if learnt_expressions:
|
||||||
|
|||||||
@@ -247,12 +247,12 @@ async def _build_readable_messages_internal(
|
|||||||
last_end = m.end()
|
last_end = m.end()
|
||||||
new_content += content[last_end:]
|
new_content += content[last_end:]
|
||||||
content = new_content
|
content = new_content
|
||||||
|
|
||||||
target_str = "这是QQ的一个功能,用于提及某人,但没那么明显"
|
target_str = "这是QQ的一个功能,用于提及某人,但没那么明显"
|
||||||
if target_str in content:
|
if target_str in content:
|
||||||
if random.random() < 0.6:
|
if random.random() < 0.6:
|
||||||
content = content.replace(target_str, "")
|
content = content.replace(target_str, "")
|
||||||
|
|
||||||
if content != "":
|
if content != "":
|
||||||
message_details_raw.append((timestamp, person_name, content))
|
message_details_raw.append((timestamp, person_name, content))
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[inner]
|
[inner]
|
||||||
version = "1.6.1"
|
version = "1.7.0"
|
||||||
|
|
||||||
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
||||||
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
||||||
@@ -43,6 +43,10 @@ personality_sides = [
|
|||||||
"用一句话或几句话描述人格的一些细节",
|
"用一句话或几句话描述人格的一些细节",
|
||||||
]# 条数任意,不能为0, 该选项还在调试中,可能未完全生效
|
]# 条数任意,不能为0, 该选项还在调试中,可能未完全生效
|
||||||
|
|
||||||
|
# 表达方式
|
||||||
|
expression_style = "描述麦麦说话的表达风格,表达习惯"
|
||||||
|
|
||||||
|
|
||||||
[identity] #アイデンティティがない 生まれないらららら
|
[identity] #アイデンティティがない 生まれないらららら
|
||||||
# 兴趣爱好 未完善,有些条目未使用
|
# 兴趣爱好 未完善,有些条目未使用
|
||||||
identity_detail = [
|
identity_detail = [
|
||||||
|
|||||||
Reference in New Issue
Block a user