loopd: a turn's speaker in the log, its number in SessionUpdated
Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
@@ -113,19 +113,23 @@ fn map_event(event: &ChatEvent, on_event: &mut dyn FnMut(&TurnEvent)) {
|
||||
}
|
||||
}
|
||||
|
||||
/// One turn of `session`: `content` is the user's message, and `speaker` who spoke it, when one
|
||||
/// person did. The speaker is logged on the `User` record, for `memoryd`, and never sent to the
|
||||
/// model: the request is the same with a speaker and without one (M5c spec, section 11).
|
||||
pub fn run_turn(
|
||||
session: &mut Session,
|
||||
rt: &Runtime<'_>,
|
||||
content: &str,
|
||||
speaker: Option<&str>,
|
||||
on_event: &mut dyn FnMut(&TurnEvent),
|
||||
) -> Result<TurnOutcome, TurnError> {
|
||||
session
|
||||
.append(LogRecord::User {
|
||||
time: Timestamp::now(),
|
||||
content: neutralise(content).into_owned(),
|
||||
// Set in M5c-1 task 02, from the turn. `None` is not written: the record's bytes
|
||||
// are as before.
|
||||
speaker: None,
|
||||
// As it came: not checked and not neutralised, since it never reaches the model.
|
||||
// `None` is not written, so the record's bytes are as before M5c.
|
||||
speaker: speaker.map(str::to_string),
|
||||
})
|
||||
.map_err(TurnError::Session)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user