Public
Edited
Apr 23
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
common_leading_prompt = (speaker, listener, chat_history, additional_part) => {
return `Your name is ${speaker.name}. You have the following personality and background. Use them to guide your behavior and speech:
###
${speaker.character}
###

Now, you are having a conversation with ${listener.name}.

# Chat History
###
${chat_history}${additional_part}
###

## Chat History Format
- Older messages are listed first, and newer messages follow below.
- The notation \`{{X interrupted}}\` indicates that person X cut in while the speaker was still talking.
`;
}
Insert cell
additional_context_template = (speaker, listener) => {
return `
# Notice
As you can see from the chat history, your last speech was interrupted by ${
listener.name
}'s cut in.
You had planned to continue speaking with the following text:
###
${interruption_state[speaker.id].unspoken_part}
###
`
}
Insert cell
speech_prompt_template = (speaker, listener, chat_history) => {
const final_prompt =
common_leading_prompt(speaker, listener, chat_history, "") +
(interruption_state[listener.id].type != 0
? additional_context_template(speaker, listener) +
`
# Task
1. Privately assess (do not output) whether ${listener.name}'s interruption is logically or contextually relevant to your current unspoken statement.
- If relevant or justified, your next response should reflect positivity or acceptance toward the interruption.
- If irrelevant or unjustified, your next response may indicate disagreement or attempt to clarify your original intention.
2. **Generate your next speech**:
- From a first-person perspective
- In your own natural language
- Stay consistent with your background and personality
- Reflect your private assessment in your speech (without explicitly revealing it)
`
: `
# Task
**Generate your next speech**:
- From a first-person perspective
- In your own natural language
- Stay consistent with your background and personality
`) +
`
# Important
**Do not include any speaker labels.**
`;

return final_prompt;
}
Insert cell
segment_text_prompt_template = `You are an assistant that splits the given text into smaller segments. Return these segments as a plain JSON array (without any code fences or additional formatting). Each segment must be a string in its own array element.`
Insert cell
interrupt_decision_prompt_template = (
listener,
speaker,
last_speech,
chat_history
) => {
const final_prompt =
common_leading_prompt(
listener,
speaker,
chat_history,
`\n${speaker.name}: ${last_speech}`
) +
(interruption_state[speaker.id].type != 0
? additional_context_template(listener, speaker)
: "") +
`
# Task
` +
(interruption_state[speaker.id].type != 0
? `1. Privately assess (do not output) whether ${speaker.name}'s interruption is logically or contextually relevant to your current unspoken statement.
- If relevant or justified, your next response should reflect positivity or acceptance toward the interruption.
- If irrelevant or unjustified, your next response may indicate disagreement or attempt to clarify your original intention.
2. Decide if you want to interrupt this speech **immediately** based on this assessment.
- The interruption from ${speaker.name} may not have finished. If it remains unclear, it is better to keep listening until you understand the ${speaker.name}'s intent.
3. `
: `1. Decide if you want to interrupt this speech **immediately**.
- ${speaker.name}'s latest speech may not have finished. If it remains unclear, it is better to keep listening until you understand the ${speaker.name}'s intent.
2. `) +
`Return your decision in **valid JSON** with the following structure:

{
"type": 0|1,
"text": "..."
}

Where:
- "type" must be one of:
- 0 = Do NOT interrupt (continue listening)
- 1 = Interrupt because of strong empathy, strong disagreement, or a sudden impulse
- "text" must be the actual interruption statement matching your private assessment, written:
- From a first-person perspective
- In your own natural language
- Consistent with your background and disposition

# Important
**Your entire response MUST consist of the single JSON object only. Do not add any extra text, punctuation, or commentary outside of it.**
`;

return final_prompt;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more