fix:优化人格prompt提取

This commit is contained in:
SengokuCola
2025-04-06 14:22:34 +08:00
parent 915ad8c61a
commit 88a4db8894
7 changed files with 245 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
from dataclasses import dataclass
from typing import List
import random
@dataclass
class Identity:
@@ -75,6 +76,27 @@ class Identity:
instance.appearance = appearance
return instance
def get_prompt(self,x_person,level):
"""
获取身份特征的prompt
"""
if x_person == 2:
prompt_identity = ""
elif x_person == 1:
prompt_identity = ""
else:
prompt_identity = ""
if level == 1:
identity_detail = self.identity_detail
random.shuffle(identity_detail)
prompt_identity += identity_detail[0]
elif level == 2:
for detail in identity_detail:
prompt_identity += f",{detail}"
prompt_identity += ""
return prompt_identity
def to_dict(self) -> dict:
"""将身份特征转换为字典格式"""
return {