add get_poignancy_chat

This commit is contained in:
SereneWalden 2023-09-30 15:43:59 +08:00
parent ba72e21028
commit f30946b557
3 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,15 @@
poignancy_event_v1.txt
!<INPUT 1>!: agent name
!<INPUT 1>!: iss
!<INPUT 2>!: name
!<INPUT 3>!: event description
<commentblockmarker>###</commentblockmarker>
Here is a brief description of !<INPUT 0>!.
!<INPUT 1>!
On the scale of 1 to 10, where 1 is purely mundane (e.g., brushing teeth, making bed) and 10 is extremely poignant (e.g., a break up, college acceptance), rate the likely poignancy of the following event for !<INPUT 2>!.
Event: !<INPUT 3>!
Rate (return a number between 1 to 10):

View file

@ -0,0 +1,15 @@
poignancy_thought_v1.txt
!<INPUT 1>!: agent name
!<INPUT 1>!: iss
!<INPUT 2>!: name
!<INPUT 3>!: event description
<commentblockmarker>###</commentblockmarker>
Here is a brief description of !<INPUT 0>!.
!<INPUT 1>!
On the scale of 1 to 10, where 1 is purely mundane (e.g., I need to do the dishes, I need to walk the dog) and 10 is extremely significant (e.g., I wish to become a professor, I love Elie), rate the likely significance of the following thought for !<INPUT 2>!.
Thought: !<INPUT 3>!
Rate (return a number between 1 to 10):

View file

@ -19,6 +19,30 @@ def get_poignancy_action(scratch: Scratch, content: BasicMemory.content) -> str:
content]
return prompt_input
# 1. Prompt构建
# 2. Instruction给出
prompt_template = "poignancy_action_v1.txt" # 保留原来的注释
prompt_input = create_prompt_input(scratch, content) # 保留原来的注释
prompt = prompt_generate(prompt_input, prompt_template)
special_instruction = "The output should ONLY contain ONE integer value on the scale of 1 to 10."
poignancy = special_response_generate(prompt, special_instruction)
try:
poi_dict = json.loads(poignancy)
return str(poi_dict['poignancy']) # 将返回值强制转换为字符串
except json.JSONDecodeError as e:
return poignancy
def get_poignancy_chat(scratch: Scratch, content: BasicMemory.content) -> str:
"""
衡量会话心酸度
"""
def create_prompt_input(scratch, content):
prompt_input = [scratch.name,
scratch.iss,
scratch.name,
content]
return prompt_input
# 1. Prompt构建
# 2. Instruction给出
prompt_template = "poignancy_chat_v1.txt" # 保留原来的注释