Rename agent/ to user/ and poc-agent binary to consciousness
Mechanical rename: src/agent/ -> src/user/, all crate::agent:: -> crate::user:: references updated. Binary poc-agent renamed to consciousness with CLI name and user-facing strings updated. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
beb49ec477
commit
14dd8d22af
31 changed files with 1857 additions and 1468 deletions
|
|
@ -8,9 +8,9 @@
|
|||
// Column sums = response memory-dependence (training candidates)
|
||||
|
||||
use std::time::Instant;
|
||||
use crate::agent::api::ApiClient;
|
||||
use crate::agent::types::*;
|
||||
use crate::agent::ui_channel::{UiMessage, UiSender};
|
||||
use crate::user::api::ApiClient;
|
||||
use crate::user::types::*;
|
||||
use crate::user::ui_channel::{UiMessage, UiSender};
|
||||
|
||||
/// Timeout for individual /v1/score API calls.
|
||||
const SCORE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(120);
|
||||
|
|
@ -53,6 +53,10 @@ pub async fn score_memories(
|
|||
client: &ApiClient,
|
||||
ui_tx: &UiSender,
|
||||
) -> anyhow::Result<MemoryScore> {
|
||||
let _ = ui_tx.send(UiMessage::Debug(format!(
|
||||
"[training] in score_memories"
|
||||
)));
|
||||
|
||||
let memories: Vec<(usize, String)> = context.entries.iter().enumerate()
|
||||
.filter_map(|(i, e)| match e {
|
||||
ConversationEntry::Memory { key, .. } => Some((i, key.clone())),
|
||||
|
|
@ -97,6 +101,7 @@ pub async fn score_memories(
|
|||
)));
|
||||
|
||||
// Baseline: score with all memories present
|
||||
let _ = ui_tx.send(UiMessage::Debug("[training] serializing payload...".into()));
|
||||
let payload_size = serde_json::to_string(&all_messages)
|
||||
.map(|s| s.len()).unwrap_or(0);
|
||||
let _ = ui_tx.send(UiMessage::Debug(format!(
|
||||
|
|
@ -128,12 +133,13 @@ pub async fn score_memories(
|
|||
match without {
|
||||
Ok(without) => {
|
||||
let elapsed = start.elapsed().as_secs_f64();
|
||||
// Match scores by message index and compute divergence
|
||||
// Match scores by position (nth scored response),
|
||||
// not message_index — indices shift when a memory
|
||||
// is removed from the conversation.
|
||||
let mut row = Vec::new();
|
||||
for base_score in &baseline {
|
||||
for (i, base_score) in baseline.iter().enumerate() {
|
||||
let base_lp = base_score.total_logprob;
|
||||
let without_lp = without.iter()
|
||||
.find(|s| s.message_index == base_score.message_index)
|
||||
let without_lp = without.get(i)
|
||||
.map(|s| s.total_logprob)
|
||||
.unwrap_or(base_lp);
|
||||
let divergence = (base_lp - without_lp).max(0.0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue