Skip to content

Commit

Permalink
chore: small refactoring around ui::text::consume_events and arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Feb 4, 2025
1 parent 2daec59 commit ceecd27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
27 changes: 16 additions & 11 deletions src/cli/ui/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ use std::time::Duration;

use colored::Colorize;

use crate::agent::{
events::{EventType, Receiver},
Invocation,
use crate::{
agent::{
events::{EventType, Receiver},
Invocation,
},
cli::Args,
};

fn on_action_executed(
Expand Down Expand Up @@ -60,12 +63,7 @@ fn on_action_executed(
}
}

pub async fn consume_events(
mut events_rx: Receiver,
save_to: Option<String>,
is_judge: bool,
is_workflow: bool,
) {
pub async fn consume_events(mut events_rx: Receiver, args: Args, is_workflow: bool) {
while let Some(event) = events_rx.recv().await {
match event.event {
EventType::MetricsUpdate(metrics) => {
Expand All @@ -74,7 +72,7 @@ pub async fn consume_events(
}
}
EventType::StateUpdate(state) => {
if let Some(prompt_path) = &save_to {
if let Some(prompt_path) = &args.save_to {
let data = format!(
"[SYSTEM PROMPT]\n\n{}\n\n[PROMPT]\n\n{}\n\n[CHAT]\n\n{}",
&state.chat.system_prompt.unwrap_or_default(),
Expand Down Expand Up @@ -122,7 +120,14 @@ pub async fn consume_events(
elapsed,
complete_task,
} => {
on_action_executed(is_judge, error, invocation, result, elapsed, complete_task);
on_action_executed(
args.judge_mode,
error,
invocation,
result,
elapsed,
complete_task,
);
}
EventType::TaskComplete { impossible, reason } => {
if !is_workflow {
Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ async fn run_task(args: Args, for_workflow: bool) -> Result<HashMap<String, Stri
// spawn the events consumer
tokio::spawn(ui::text::consume_events(
events_rx,
args.save_to,
args.judge_mode,
false,
args.clone(),
for_workflow,
));

// keep going until the task is complete or a fatal error is reached
Expand Down

0 comments on commit ceecd27

Please sign in to comment.