fix:优化人格prompt提取
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user