memoryd: a reported turn decided after loopd has its answer, from brokerd and the log
Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
//! Session logs of turns with speakers, for the tests of deciding turns. Do not edit.
|
||||
|
||||
#![allow(dead_code)] // each test file uses a different part of this module
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use bxcore::{DataClass, LogRecord, SessionId, SessionStateReply};
|
||||
|
||||
use crate::logs::{assistant, at, result};
|
||||
|
||||
pub fn sid(s: &str) -> SessionId {
|
||||
SessionId::new(s).unwrap()
|
||||
}
|
||||
|
||||
pub fn clean() -> SessionStateReply {
|
||||
SessionStateReply {
|
||||
class: DataClass::Private,
|
||||
untrusted: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spoken(content: &str, speaker: Option<&str>) -> LogRecord {
|
||||
LogRecord::User {
|
||||
time: at(1),
|
||||
content: content.to_string(),
|
||||
speaker: speaker.map(str::to_string),
|
||||
}
|
||||
}
|
||||
|
||||
/// A finished turn: the speaker's message and the reply.
|
||||
pub fn finished(speaker: Option<&str>) -> Vec<LogRecord> {
|
||||
vec![spoken("hello", speaker), assistant(2, Some("hi"), &[])]
|
||||
}
|
||||
|
||||
/// A finished turn that read an untrusted page.
|
||||
pub fn fetched(speaker: Option<&str>) -> Vec<LogRecord> {
|
||||
vec![
|
||||
spoken("read this page", speaker),
|
||||
assistant(2, None, &[("fetch", "{}")]),
|
||||
result(3, "the page", DataClass::Public, true),
|
||||
assistant(4, Some("it says hello"), &[]),
|
||||
]
|
||||
}
|
||||
|
||||
/// A turn still running, or one that failed: no reply.
|
||||
pub fn running(speaker: Option<&str>) -> Vec<LogRecord> {
|
||||
vec![
|
||||
spoken("look it up", speaker),
|
||||
assistant(2, None, &[("fetch", "{}")]),
|
||||
]
|
||||
}
|
||||
|
||||
/// `sessions/<session>/0.jsonl` under `home`, the turns one after another.
|
||||
pub fn write_turns(home: &Path, session: &str, turns: &[Vec<LogRecord>]) {
|
||||
let records: Vec<LogRecord> = turns.iter().flatten().cloned().collect();
|
||||
crate::logs::write_log(home, session, &records);
|
||||
}
|
||||
Reference in New Issue
Block a user