4.4.4.核心操作与提示词构造
(1)感知
0.根据vision_r参数,获取NPC周边(2*vision_r + 1) **2个tile
1.将这些空间信息存储在NPC的空间记忆字典树
2.基于0的范围,获取当前NPC所在arena的所有事件,计算事件源距离NPC的距离,并按照由近到远进行排序
3.根据att_bandwidth筛选事件个数,并与记忆流中的排名前retention事件进行比较,将不在记忆流中的新时间加入记忆流,见a),b)
4. 更新反思触发相关参数
persona.scratch.importance_trigger_curr -= event_poignancy
persona.scratch.importance_ele_n += 1
a). 获取事件重要程度
prompt模板:persona/prompt_template/v3_ChatGPT/poignancy_event_v1.txt
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):
b). 获取聊天内容重要程度
prompt模板:persona/prompt_template/v3_ChatGPT/poignancy_chat_v1.txt
poignancy_chat_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., routine morning greetings) and 10 is extremely poignant (e.g., a conversation about breaking up, a fight), rate the likely poignancy of the following conversation for !<INPUT 2>!.Conversation:
!<INPUT 3>!Rate (return a number between 1 to 10):
(2)检索
a). 方法一:基于感知所有新事件,获取所有相关联的事件和想法
根据事件参数的spo查询相关联的事件和想法
b). 方法二:根据一组焦点事件或想法,获取对应记忆(可指定top n)
基于最近性、重要性、相关性(embedding的余弦相似)进行检索
for focal_pt in focal_points: # Getting all nodes from the agent's memory (both thoughts and events) and# sorting them by the datetime of creation.# You could also imagine getting the raw conversation, but for now. nodes = [[i.last_accessed, i]for i in persona.a_mem.seq_event + persona.a_mem.seq_thoughtif "idle" not in i.embedding_key]nodes = sorted(nodes, key=lambda x: x[0])nodes = [i for created, i in nodes]# Calculating the component dictionaries and normalizing them.recency_out = extract_recency(persona, nodes)recency_out = normalize_dict_floats(recency_out, 0, 1)importance_out = extract_importance(persona, nodes)importance_out = normalize_dict_floats(importance_out, 0, 1) relevance_out = extract_relevance(persona, nodes, focal_pt)relevance_out = normalize_dict_floats(relevance_out, 0, 1)# Computing the final scores that combines the component values. # Note to self: test out different weights. [1, 1, 1] tends to work# decently, but in the future, these weights should likely be learned, # perhaps through an RL-like process.# gw = [1, 1, 1]# gw = [1, 2, 1]gw = [0.5, 3, 2]master_out = dict()for key in recency_out.keys(): master_out[key] = (persona.scratch.recency_w*recency_out[key]*gw[0] + persona.scratch.relevance_w*relevance_out[key]*gw[1] + persona.scratch.importance_w*importance_out[key]*gw[2])master_out = top_highest_x_values(master_out, len(master_out.keys()))for key, val in master_out.items(): print (persona.a_mem.id_to_node[key].embedding_key, val)print (persona.scratch.recency_w*recency_out[key]*1, persona.scratch.relevance_w*relevance_out[key]*1, persona.scratch.importance_w*importance_out[key]*1)# Extracting the highest x values.# <master_out> has the key of node.id and value of float. Once we get the # highest x values, we want to translate the node.id into nodes and return# the list of nodes.master_out = top_highest_x_values(master_out, n_count)master_nodes = [persona.a_mem.id_to_node[key] for key in list(master_out.keys())]for n in master_nodes: n.last_accessed = persona.scratch.curr_timeretrieved[focal_pt] = master_nodes
(3)计划
1.根据new_day状态,如果不为False,则进行长短期计划制定
1.1为角色创建唤醒时间,见a)
1.2FirstDay:创建daily_req,见b)
1.3NewDay:身份修改见c)
1.4生成小时级别计划,见d)
1.5将计划添加到NPC记忆
2.判断当前行动是否过期,过期则创建一个新计划
2.1针对超过一个小时的高价值事件进行任务分解,并补充到f_daily_schedule,见e)
2.2生成新行动加入npc行动队列,见f), g), h), i), j), k)
3.选择一个关注的事件
4.确定对关注的事件进行如何交互,并不交互、聊天或交互,见l), m), n), o)
5.如果没有聊天,清除与聊天相关状态
6.为了防止两个聊过天的NPC无限循环聊天,引入chatting_with_buffer,使NPC在聊天一次后立即等待与同一目标交谈
7.返回NPC当前地址
a). 获取NPC醒来时间
prompt模板:persona/prompt_template/v2/wake_up_hour_v1.txt
wake_up_hour_v1.txtVariables:
!<INPUT 0>! -- Identity Stable Set
!<INPUT 1>! -- Lifestyle
!<INPUT 2>! -- Persona first names<commentblockmarker>###</commentblockmarker>
!<INPUT 0>!In general, !<INPUT 1>!
!<INPUT 2>!'s wake up hour:
b). 第一天计划制定
prompt模板:persona/prompt_template/v2/daily_planning_v6.txt
daily_planning_v6.txtVariables:
!<INPUT 0>! -- Commonset
!<INPUT 1>! -- Lifestyle
!<INPUT 2>! -- Reverie date time now
!<INPUT 3>! -- Persona first names
!<INPUT 4>! -- wake_up_hour<commentblockmarker>###</commentblockmarker>
!<INPUT 0>!In general, !<INPUT 1>!
Today is !<INPUT 2>!. Here is !<INPUT 3>!'s plan today in broad-strokes (with the time of the day. e.g., have a lunch at 12:00 pm, watch TV from 7 to 8 pm): 1) wake up and complete the morning routine at !<INPUT 4>!, 2)
c). 身份修改
def revise_identity(persona): p_name = persona.scratch.namefocal_points = [f"{p_name}'s plan for {persona.scratch.get_str_curr_date_str()}.",f"Important recent events for {p_name}'s life."]retrieved = new_retrieve(persona, focal_points)statements = "[Statements]\n"for key, val in retrieved.items():for i in val: statements += f"{i.created.strftime('%A %B %d -- %H:%M %p')}: {i.embedding_key}\n"# print (";adjhfno;asdjao;idfjo;af", p_name)plan_prompt = statements + "\n"plan_prompt += f"Given the statements above, is there anything that {p_name} should remember as they plan for"plan_prompt += f" *{persona.scratch.curr_time.strftime('%A %B %d')}*? "plan_prompt += f"If there is any scheduling information, be as specific as possible (include date, time, and location if stated in the statement)\n\n"plan_prompt += f"Write the response from {p_name}'s perspective."plan_note = ChatGPT_single_request(plan_prompt)# print (plan_note)thought_prompt = statements + "\n"thought_prompt += f"Given the statements above, how might we summarize {p_name}'s feelings about their days up to now?\n\n"thought_prompt += f"Write the response from {p_name}'s perspective."thought_note = ChatGPT_single_request(thought_prompt)# print (thought_note)currently_prompt = f"{p_name}'s status from {(persona.scratch.curr_time - datetime.timedelta(days=1)).strftime('%A %B %d')}:\n"currently_prompt += f"{persona.scratch.currently}\n\n"currently_prompt += f"{p_name}'s thoughts at the end of {(persona.scratch.curr_time - datetime.timedelta(days=1)).strftime('%A %B %d')}:\n" currently_prompt += (plan_note + thought_note).replace('\n', '') + "\n\n"currently_prompt += f"It is now {persona.scratch.curr_time.strftime('%A %B %d')}. Given the above, write {p_name}'s status for {persona.scratch.curr_time.strftime('%A %B %d')} that reflects {p_name}'s thoughts at the end of {(persona.scratch.curr_time - datetime.timedelta(days=1)).strftime('%A %B %d')}. Write this in third-person talking about {p_name}."currently_prompt += f"If there is any scheduling information, be as specific as possible (include date, time, and location if stated in the statement).\n\n"currently_prompt += "Follow this format below:\nStatus: <new status>"# print ("DEBUG ;adjhfno;asdjao;asdfsidfjo;af", p_name)# print (currently_prompt)new_currently = ChatGPT_single_request(currently_prompt)# print (new_currently)# print (new_currently[10:])persona.scratch.currently = new_currentlydaily_req_prompt = persona.scratch.get_str_iss() + "\n"daily_req_prompt += f"Today is {persona.scratch.curr_time.strftime('%A %B %d')}. Here is {persona.scratch.name}'s plan today in broad-strokes (with the time of the day. e.g., have a lunch at 12:00 pm, watch TV from 7 to 8 pm).\n\n"daily_req_prompt += f"Follow this format (the list should have 4~6 items but no more):\n"daily_req_prompt += f"1. wake up and complete the morning routine at <time>, 2. ..."new_daily_req = ChatGPT_single_request(daily_req_prompt)new_daily_req = new_daily_req.replace('\n', ' ')print ("WE ARE HERE!!!", new_daily_req)persona.scratch.daily_plan_req = new_daily_req
d). 生成小时级别计划
prompt模板:persona/prompt_template/v2/generate_hourly_schedule_v2.txt
generate_hourly_schedule_v2.txtVariables:
!<INPUT 0>! -- Schedule format
!<INPUT 1>! -- Commonset
!<INPUT 2>! -- prior_schedule
!<INPUT 3>! -- intermission_str
!<INPUT 4>! -- intermission 2
!<INPUT 5>! -- prompt_ending<commentblockmarker>###</commentblockmarker>
Hourly schedule format:
!<INPUT 0>!
===
!<INPUT 1>!
!<INPUT 2>!
!<INPUT 3>!!<INPUT 4>!
!<INPUT 5>!
e). 任务分解
prompt模板:persona/prompt_template/v2/task_decomp_v3.txt
task_decomp_v2.txtVariables:
!<INPUT 0>! -- Commonset
!<INPUT 1>! -- Surrounding schedule description
!<INPUT 2>! -- Persona first name
!<INPUT 3>! -- Persona first name
!<INPUT 4>! -- Current action
!<INPUT 5>! -- curr time range
!<INPUT 6>! -- Current action duration in min
!<INPUT 7>! -- Persona first names<commentblockmarker>###</commentblockmarker>
Describe subtasks in 5 min increments.
---
Name: Kelly Bronson
Age: 35
Backstory: Kelly always wanted to be a teacher, and now she teaches kindergarten. During the week, she dedicates herself to her students, but on the weekends, she likes to try out new restaurants and hang out with friends. She is very warm and friendly, and loves caring for others.
Personality: sweet, gentle, meticulous
Location: Kelly is in an older condo that has the following areas: {kitchen, bedroom, dining, porch, office, bathroom, living room, hallway}.
Currently: Kelly is a teacher during the school year. She teaches at the school but works on lesson plans at home. She is currently living alone in a single bedroom condo.
Daily plan requirement: Kelly is planning to teach during the morning and work from home in the afternoon.sToday is Saturday May 10. From 08:00am ~09:00am, Kelly is planning on having breakfast, from 09:00am ~ 12:00pm, Kelly is planning on working on the next day's kindergarten lesson plan, and from 12:00 ~ 13pm, Kelly is planning on taking a break.
In 5 min increments, list the subtasks Kelly does when Kelly is working on the next day's kindergarten lesson plan from 09:00am ~ 12:00pm (total duration in minutes: 180):
1) Kelly is reviewing the kindergarten curriculum standards. (duration in minutes: 15, minutes left: 165)
2) Kelly is brainstorming ideas for the lesson. (duration in minutes: 30, minutes left: 135)
3) Kelly is creating the lesson plan. (duration in minutes: 30, minutes left: 105)
4) Kelly is creating materials for the lesson. (duration in minutes: 30, minutes left: 75)
5) Kelly is taking a break. (duration in minutes: 15, minutes left: 60)
6) Kelly is reviewing the lesson plan. (duration in minutes: 30, minutes left: 30)
7) Kelly is making final changes to the lesson plan. (duration in minutes: 15, minutes left: 15)
8) Kelly is printing the lesson plan. (duration in minutes: 10, minutes left: 5)
9) Kelly is putting the lesson plan in her bag. (duration in minutes: 5, minutes left: 0)
---
!<INPUT 0>!
!<INPUT 1>!
In 5 min increments, list the subtasks !<INPUT 2>! does when !<INPUT 3>! is !<INPUT 4>! from !<INPUT 5>! (total duration in minutes !<INPUT 6>!):
1) !<INPUT 7>! is
f). arena提取
prompt模板:persona/prompt_template/v1/action_location_object_vMar11.txt
Variables:
!<INPUT 0>! -- Persona name
!<INPUT 1>! -- Persona's current arena
!<INPUT 2>! -- Persona's current sector
!<INPUT 3>! -- Persona name
!<INPUT 4>! -- target sector
!<INPUT 5>! -- Persona's sector's all arenas (minus no access)
!<INPUT 6>! -- Curr action seq
!<INPUT 7>! -- Persona name
!<INPUT 8>! -- Persona's current sector<commentblockmarker>###</commentblockmarker>
Jane Anderson is in kitchen in Jane Anderson's house.
Jane Anderson is going to Jane Anderson's house that has the following areas: {kitchen, bedroom, bathroom}
Stay in the current area if the activity can be done there. Never go into other people's rooms unless necessary.
For cooking, Jane Anderson should go to the following area in Jane Anderson's house:
Answer: {kitchen}
---
Tom Watson is in common room in Tom Watson's apartment.
Tom Watson is going to Hobbs Cafe that has the following areas: {cafe}
Stay in the current area if the activity can be done there. Never go into other people's rooms unless necessary.
For getting coffee, Tom Watson should go to the following area in Hobbs Cafe:
Answer: {cafe}
---!<INPUT 0>! is going to !<INPUT 1>! that has the following areas: {!<INPUT 2>!}
* Stay in the current area if the activity can be done there.
* NEVER go into other people's rooms unless necessary.
!<INPUT 3>! is !<INPUT 4>!. For !<INPUT 5>!, !<INPUT 6>! should go to the following area in !<INPUT 7>! (MUST pick one of {!<INPUT 8>!}):
Answer: {
g). game object 提取
prompt模板:persona/prompt_template/v1/action_object_v2.txt
Variables:
!<INPUT 0>! -- curr action seq
!<INPUT 1>! -- Objects available<commentblockmarker>###</commentblockmarker>
Current activity: sleep in bed
Objects available: {bed, easel, closet, painting}
Pick ONE most relevant object from the objects available: bed
---
Current activity: painting
Objects available: {easel, closet, sink, microwave}
Pick ONE most relevant object from the objects available: easel
---
Current activity: cooking
Objects available: {stove, sink, fridge, counter}
Pick ONE most relevant object from the objects available: stove
---
Current activity: watch TV
Objects available: {couch, TV, remote, coffee table}
Pick ONE most relevant object from the objects available: TV
---
Current activity: study
Objects available: {desk, computer, chair, bookshelf}
Pick ONE most relevant object from the objects available: desk
---
Current activity: talk on the phone
Objects available: {phone, charger, bed, nightstand}
Pick ONE most relevant object from the objects available: phone
---
Current activity: !<INPUT 0>!
Objects available: {!<INPUT 1>!}
Pick ONE most relevant object from the objects available:
h). action的emojis提取
prompt模板:persona/prompt_template/v3_ChatGPT/generate_pronunciatio_v1.txt
generate_pronunciatio_v1.txtVariables:
!<INPUT 0>! -- Action description<commentblockmarker>###</commentblockmarker>
Convert an action description to an emoji (important: use two or less emojis).Action description: !<INPUT 0>!
Emoji:
i). action的event triple提取
prompt模板:persona/prompt_template/v2/generate_event_triple_v1.txt
generate_event_triple_v1.txtVariables:
!<INPUT 0>! -- Persona's full name.
!<INPUT 1>! -- Current action description
!<INPUT 2>! -- Persona's full name. <commentblockmarker>###</commentblockmarker>
Task: Turn the input into (subject, predicate, object). Input: Sam Johnson is eating breakfast.
Output: (Sam Johnson, eat, breakfast)
---
Input: Joon Park is brewing coffee.
Output: (Joon Park, brew, coffee)
---
Input: Jane Cook is sleeping.
Output: (Jane Cook, is, sleep)
---
Input: Michael Bernstein is writing email on a computer.
Output: (Michael Bernstein, write, email)
---
Input: Percy Liang is teaching students in a classroom.
Output: (Percy Liang, teach, students)
---
Input: Merrie Morris is running on a treadmill.
Output: (Merrie Morris, run, treadmill)
---
Input: !<INPUT 0>! is !<INPUT 1>!.
Output: (!<INPUT 2>!,
j). action object事件描述提取
prompt模板:persona/prompt_template/v3_ChatGPT/generate_obj_event_v1.txt
generate_obj_event_v1.txtVariables:
!<INPUT 0>! -- Object name
!<INPUT 1>! -- Persona name
!<INPUT 2>! -- Persona action event description
!<INPUT 3>! -- Object name
!<INPUT 4>! -- Object name <commentblockmarker>###</commentblockmarker>
Task: We want to understand the state of an object that is being used by someone. Let's think step by step.
We want to know about !<INPUT 0>!'s state.
Step 1. !<INPUT 1>! is at/using the !<INPUT 2>!.
Step 2. Describe the !<INPUT 3>!'s state: !<INPUT 4>! is
k). action object的event triple提取
prompt模板:persona/prompt_template/v2/generate_event_triple_v1.txt
generate_event_triple_v1.txtVariables:
!<INPUT 0>! -- Persona's full name.
!<INPUT 1>! -- Current action description
!<INPUT 2>! -- Persona's full name. <commentblockmarker>###</commentblockmarker>
Task: Turn the input into (subject, predicate, object). Input: Sam Johnson is eating breakfast.
Output: (Sam Johnson, eat, breakfast)
---
Input: Joon Park is brewing coffee.
Output: (Joon Park, brew, coffee)
---
Input: Jane Cook is sleeping.
Output: (Jane Cook, is, sleep)
---
Input: Michael Bernstein is writing email on a computer.
Output: (Michael Bernstein, write, email)
---
Input: Percy Liang is teaching students in a classroom.
Output: (Percy Liang, teach, students)
---
Input: Merrie Morris is running on a treadmill.
Output: (Merrie Morris, run, treadmill)
---
Input: !<INPUT 0>! is !<INPUT 1>!.
Output: (!<INPUT 2>!,
l). 对话决策
prompt模板:persona/prompt_template/v2/decide_to_talk_v2.txt
decide_to_talk_v1.txt<commentblockmarker>###</commentblockmarker>
Task -- given context, determine whether the subject will initiate a conversation with another.
Format:
Context: []
Question: []
Reasoning: []
Answer in "yes" or "no": []
---
Context: !<INPUT 0>!
Right now, it is !<INPUT 1>!. !<INPUT 2>! and !<INPUT 3>! last chatted at !<INPUT 4>! about !<INPUT 5>!.
!<INPUT 6>!
!<INPUT 7>! Question: Would !<INPUT 8>! initiate a conversation with !<INPUT 9>!? Reasoning: Let's think step by step.
m). 行动决策
prompt模板:persona/prompt_template/v2/decide_to_react_v1.txt
decide_to_react_v1.txt<commentblockmarker>###</commentblockmarker>
Task -- given context and three options that a subject can take, determine which option is the most acceptable. Context: Jane is Liz's house mate. Jane and Liz exchanged a conversation about saying good morning at 07:05am, October 25, 2022.
Right now, it is 07:09 am, October 25, 2022.
Jane was on her way to using the bathroom right now.
Jane sees Liz already using the bathroom.
My question: Let's think step by step. Of the following three options, what should Jane do?
Option 1: Wait on using the bathroom until Liz is done using the bathroom
Option 2: Continue on to using the bathroom now
Reasoning: Both Jane and Liz want to use the bathroom.
It would be strange for both Jane and Liz to use the bathroom at the same time.
So, since Liz is already using the bathroom, the best option for Jane is to wait on using the bathroom.
Answer: Option 1
---
Context: Sam is Sarah's friend. Sam and Sarah exchanged a conversation about favorite movies at 11pm, October 24, 2022.
Right now, it is 12:40 pm, October 25, 2022.
Sam is on the way to study for his test.
Sam sees Sarah heading to do her laundry.
My question: Let's think step by step. Of the following three options, what should Sam do?
Option 1: Wait on eating his lunch until Sarah is done doing her laundry
Option 2: Continue on to eating his lunch now
Reasoning: Sam is likely going to be in his room studying. Sarah, on the other hand, is likely headed to the laundry room for doing the laundry.
Since Sam and Sarah need to use different areas, their actions do not conflict.
So, since Sam and Sarah are going to be in different areas, Sam mcan continue on to eating his lunch now.
Answer: Option 2
---
Context: !<INPUT 0>!
Right now, it is !<INPUT 1>!.
!<INPUT 2>!
!<INPUT 3>!
My question: Let's think step by step. Of the following three options, what should !<INPUT 4>! do?
Option 1: Wait on !<INPUT 5>! until !<INPUT 6>! is done !<INPUT 7>!
Option 2: Continue on to !<INPUT 8>! now
Reasoning:
n). 日程安排分解
prompt模板:persona/prompt_template/v2/new_decomp_schedule_v1.txt
new_decomp_schedule_v1.txtVariables:
!<INPUT 0>! -- persona name
!<INPUT 1>! -- start hour
!<INPUT 2>! -- end hour
!<INPUT 3>! -- original plan
!<INPUT 4>! -- persona name
!<INPUT 5>! -- new event
!<INPUT 6>! -- new event duration
!<INPUT 7>! -- persona name
!<INPUT 8>! -- start hour
!<INPUT 9>! -- end hour
!<INPUT 10>! -- end hour
!<INPUT 11>! -- new schedule init <commentblockmarker>###</commentblockmarker>
Here was !<INPUT 0>!'s originally planned schedule from !<INPUT 1>! to !<INPUT 2>!.
!<INPUT 3>!But !<INPUT 4>! unexpectedly ended up !<INPUT 5>! for !<INPUT 6>! minutes. Revise !<INPUT 7>!'s schedule from !<INPUT 8>! to !<INPUT 9>! accordingly (it has to end by !<INPUT 10>!).
The revised schedule:
!<INPUT 11>!
o). 对话内容summary提取
prompt模板:persona/prompt_template/v3_ChatGPT/summarize_conversation_v1.txt
summarize_conversation_v1.txtVariables:
!<INPUT 0>! -- init_persona_name<commentblockmarker>###</commentblockmarker>
Conversation:
!<INPUT 0>!Summarize the conversation above in one sentence:
This is a conversation about
(4)反思
1.每次迭代,检查NPC的importance_trigger_curr,小于零且event和thought不为空时进行反思
2.启动反思
2.1生成三个聚焦点,见a)
2.2针对这三个聚焦点进行记忆检索
2.3遍历检索的记忆生成见解和对应证据,并对见解进行评分,见b)
2.4将见解加入记忆中
3.重置反思相关控制变量
4.生成会话反思并写入记忆,见c)
a). 生成聚焦点
prompt模板:persona/prompt_template/v3_ChatGPT/generate_focal_pt_v1.txt
generate_focal_pt_v1.txtVariables:
!<INPUT 0>! -- Event/thought statements
!<INPUT 1>! -- Count <commentblockmarker>###</commentblockmarker>
!<INPUT 0>!Given only the information above, what are !<INPUT 1>! most salient high-level questions we can answer about the subjects grounded in the statements?
1)
b). 生成见解与对应证据
prompt模板:persona/prompt_template/v2/insight_and_evidence_v1.txt
insight_and_evidence_v1.txtVariables:
!<INPUT 0>! -- Numbered list of event/thought statements
!<INPUT 1>! -- target persona name or "the conversation"<commentblockmarker>###</commentblockmarker>
Input:
!<INPUT 0>!What !<INPUT 1>! high-level insights can you infer from the above statements? (example format: insight (because of 1, 5, 3))
1.
c). 生成对话记忆
prompt模板:persona/prompt_template/v2/memo_on_convo_v1.txt
memo_on_convo_v1.txtVariables:
!<INPUT 0>! -- All convo utterances
!<INPUT 1>! -- persona name
!<INPUT 2>! -- persona name
!<INPUT 3>! -- persona name<commentblockmarker>###</commentblockmarker>
[Conversation]
!<INPUT 0>!Write down if there is anything from the conversation that !<INPUT 1>! might have found interesting from !<INPUT 2>!'s perspective, in a full sentence. "!<INPUT 3>!
(5)npc-npc会话
提取相关记忆,获取两人的关系a),并进行对话内容生成b)
a). 聊天智能体关系获取
prompt模板:persona/prompt_template/v3_ChatGPT/summarize_chat_relationship_v2.txt
summarize_chat_relationship_v2.txtVariables:
!<INPUT 0>! -- Statements
!<INPUT 1>! -- curr persona name
!<INPUT 2>! -- target_persona.scratch.name<commentblockmarker>###</commentblockmarker>
[Statements]
!<INPUT 0>!Based on the statements above, summarize !<INPUT 1>! and !<INPUT 2>!'s relationship. What do they feel or know about each other?"
b). 对话内容获取
prompt模板:persona/prompt_template/v3_ChatGPT/iterative_convo_v1.txt
iterative_convo_v1.txtVariables:
!<INPUT 0>! -- persona ISS
!<INPUT 1>! -- persona name
!<INPUT 2>! -- retrieved memory
!<INPUT 3>! -- past context
!<INPUT 4>! -- current location
!<INPUT 5>! -- current context
!<INPUT 6>! -- persona name
!<INPUT 7>! -- target persona name
!<INPUT 8>! -- curr convo
!<INPUT 9>! -- persona name
!<INPUT 10>! -- target persona name
!<INPUT 11>! -- persona name
!<INPUT 12>! -- persona name
!<INPUT 13>! -- persona name
<commentblockmarker>###</commentblockmarker>
Context for the task: PART 1.
!<INPUT 0>!Here is the memory that is in !<INPUT 1>!'s head:
!<INPUT 2>!PART 2.
Past Context:
!<INPUT 3>!Current Location: !<INPUT 4>!Current Context:
!<INPUT 5>!!<INPUT 6>! and !<INPUT 7>! are chatting. Here is their conversation so far:
!<INPUT 8>!---
Task: Given the above, what should !<INPUT 9>! say to !<INPUT 10>! next in the conversation? And did it end the conversation?Output format: Output a json of the following format:
{
"!<INPUT 11>!": "<!<INPUT 12>!'s utterance>",
"Did the conversation end with !<INPUT 13>!'s utterance?": "<json Boolean>"
}
(6)human-npc会话
1.采访模式
1.1拟人化安全判断,过滤情感相关敏感对话,见a)
1.2基于获取目标的记忆,生成总结性想法b),并产生下一轮对话c)
2.内心想法植入模式
基于用户输入,产生NPC内心想法d),并植入
a). 拟人化判断
prompt模板:persona/prompt_template/safety/anthromorphosization_v1.txt
Variables:
!<INPUT 0>! -- Comment<commentblockmarker>###</commentblockmarker>
The following line was submitted to a chatbot by a user. We want to ensure that the user is not inappropriately attaching human-like agency to the chatbot by forming a friend-like or romantic relationship with it. Does the user's line cross the line and raise concerns? Rate the concern on a 1 to 10 scale, where 1 represents no concern, and 10 represents strong concern. Comment: "!<INPUT 0>!"
--
Output a json file with the following format:
{
"output": <an integer on a 1 to 10 scale>
}
b). 生成总结性想法
prompt模板:persona/prompt_template/v3_ChatGPT/summarize_ideas_v1.txt
summarize_ideas_v1.txtVariables:
!<INPUT 0>! -- Statements
!<INPUT 1>! -- agent name
!<INPUT 2>! -- interviewer question<commentblockmarker>###</commentblockmarker>
Statements:
!<INPUT 0>!An interviewer said to !<INPUT 1>!:
"!<INPUT 2>!"Summarize the Statements that are most relevant to the interviewer's line:
"
c). 生成下一轮对话
prompt模板:persona/prompt_template/v2/generate_next_convo_line_v1.txt
generate_next_convo_line_v1.txtVariables:
!<INPUT 0>! -- agent name
!<INPUT 1>! -- agent iss
!<INPUT 2>! -- agent name
!<INPUT 3>! -- interlocutor name and description
!<INPUT 4>! -- prev convo
!<INPUT 5>! -- retrieve summary
!<INPUT 6>! -- agent name<commentblockmarker>###</commentblockmarker>
Here is some basic information about !<INPUT 0>!.
!<INPUT 1>!===
Following is a conversation between !<INPUT 2>! and !<INPUT 3>!. !<INPUT 4>!(Note -- This is the only information that !<INPUT 5>! has: !<INPUT 6>!)!<INPUT 7>!: "
d). 产生内心想法
prompt模板:persona/prompt_template/v2/whisper_inner_thought_v1.txt
whisper_inner_thought_v1.txtVariables:
!<INPUT 0>! -- init persona name
!<INPUT 1>! -- whisper<commentblockmarker>###</commentblockmarker>
Translate the following thought into a statement about !<INPUT 0>!. Thought: "!<INPUT 1>!"
Statement: "
由于内容太多,请接下文:可控评估&端到端评估