Persona T7: the note retry's helpers are free functions, so the public surface does not change
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9d02af2240
commit
900e8fea6c
1 changed files with 15 additions and 17 deletions
|
|
@ -370,21 +370,19 @@ pub(crate) enum MemoryRefusal {
|
|||
MemoryUnlisted,
|
||||
}
|
||||
|
||||
impl MemoryRefusal {
|
||||
/// Whether the Interpreter can mend it by saying the note again (`decide_in`): its wording, not its count.
|
||||
fn retryable(self) -> bool {
|
||||
matches!(self, Self::MemoryLong | Self::Echo)
|
||||
}
|
||||
/// Whether the Interpreter can mend a refused note by saying it again (`decide_in`): its wording, not its count.
|
||||
fn retryable(refusal: MemoryRefusal) -> bool {
|
||||
matches!(refusal, MemoryRefusal::MemoryLong | MemoryRefusal::Echo)
|
||||
}
|
||||
|
||||
/// The reason in plain words, as the Interpreter is told it when a note goes back to it once.
|
||||
fn why(self) -> String {
|
||||
match self {
|
||||
Self::MemoryEmpty => "it said nothing".to_owned(),
|
||||
Self::MemoryLong => format!("it is over {MEMORY_BYTES} bytes; keep it shorter"),
|
||||
Self::Echo => format!("it repeats someone's words from what reached the person or what they read, {ECHO_MIN_WORDS} words or more in a row; no one's line is kept as a memory, so say it in words of its own"),
|
||||
Self::OverMemories => "one answer keeps at most four notes".to_owned(),
|
||||
Self::MemoryUnlisted => "it names no memory listed".to_owned(),
|
||||
}
|
||||
/// The refusal in plain words, as the Interpreter is told it when a note goes back to it once.
|
||||
fn memory_why(refusal: MemoryRefusal) -> String {
|
||||
match refusal {
|
||||
MemoryRefusal::MemoryEmpty => "it said nothing".to_owned(),
|
||||
MemoryRefusal::MemoryLong => format!("it is over {MEMORY_BYTES} bytes; keep it shorter"),
|
||||
MemoryRefusal::Echo => format!("it repeats someone's words from what reached the person or what they read, {ECHO_MIN_WORDS} words or more in a row; no one's line is kept as a memory, so say it in words of its own"),
|
||||
MemoryRefusal::OverMemories => "one answer keeps at most four notes".to_owned(),
|
||||
MemoryRefusal::MemoryUnlisted => "it names no memory listed".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -757,7 +755,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
// applies (`commit::apply`), each held to code's structural checks. A memory carries no one's line: one that echoes
|
||||
// what she was shown or read, or quotes a run of it, is refused, so no heard words reach the Projector by way of her
|
||||
// state (I16.7). Her own drafts are hers: words of them that a heard line or a read quotes back are not what it
|
||||
// measures a note against (`without_drafts`). A note refused for its wording (`MemoryRefusal::retryable`) goes back to
|
||||
// measures a note against (`without_drafts`). A note refused for its wording (`retryable`) goes back to
|
||||
// the Interpreter once, with code's plain reason, and the second answer is held to the same checks and stands.
|
||||
let mut proposals: Vec<Value> = Vec::new();
|
||||
let mut memory_refused: Vec<Value> = Vec::new();
|
||||
|
|
@ -787,7 +785,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
None
|
||||
};
|
||||
if let Some(reason) = reason {
|
||||
if reason.retryable() && !retried {
|
||||
if retryable(reason) && !retried {
|
||||
again.push((text.to_owned(), reason));
|
||||
} else {
|
||||
settled_texts.push(text.to_owned());
|
||||
|
|
@ -804,7 +802,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
if again.is_empty() {
|
||||
break;
|
||||
}
|
||||
let refused_notes: String = again.iter().map(|(text, reason)| format!("- \"{text}\": {}\n", reason.why())).collect();
|
||||
let refused_notes: String = again.iter().map(|(text, reason)| format!("- \"{text}\": {}\n", memory_why(*reason))).collect();
|
||||
let asking = format!("{prompt}\n\nSome notes in an earlier answer to this were refused:\n{refused_notes}Answer the speech contract again. Only `remember` is read this time: say each refused note you still want kept in words of its own, or leave it out. Everything else in your earlier answer is settled.");
|
||||
let request_id = format!("{segment_id}:{attempt}");
|
||||
let (usage, second) = match model.ask(&request_id, &tuning.interpreter.model, &asking, Some(SPEECH_SCHEMA)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue