Skip to content

Commit

Permalink
refactor: renamed InvalidResponse event to just ChatResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Feb 6, 2025
1 parent b3e21ea commit 88f7213
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/agent/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum EventType {
EmptyResponse,
Thinking(String),
Sleeping(usize),
InvalidResponse(String),
ChatResponse(String),
InvalidAction {
invocation: Invocation,
error: Option<String>,
Expand Down
6 changes: 3 additions & 3 deletions src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ impl Agent {
self.on_event(Event::new(EventType::EmptyResponse)).unwrap();
}

async fn on_invalid_response(&self, response: &str) {
async fn on_chat_response(&self, response: &str) {
let mut mut_state = self.state.lock().await;
mut_state.metrics.errors.unparsed_responses += 1;
mut_state.add_unparsed_response_to_history(
response,
"I could not parse any valid actions from your response, please correct it according to the instructions.".to_string(),
);
self.on_event(Event::new(EventType::InvalidResponse(response.to_string())))
self.on_event(Event::new(EventType::ChatResponse(response.to_string())))
.unwrap();
}

Expand Down Expand Up @@ -509,7 +509,7 @@ impl Agent {
if response.content.is_empty() {
self.on_empty_response().await;
} else {
self.on_invalid_response(&response.content).await;
self.on_chat_response(&response.content).await;
}
} else {
self.on_valid_response().await;
Expand Down
8 changes: 4 additions & 4 deletions src/cli/ui/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ pub async fn consume_events(mut events_rx: Receiver, args: Args, is_workflow: bo
}
EventType::StateUpdate(_state) => {}
EventType::Thinking(thinking) => {
log::info!("🧠 thinking: {}", thinking.dimmed());
log::info!("🧠 thinking: {}", thinking.italic());
}
EventType::EmptyResponse => {
log::warn!("🧠 empty response");
log::warn!("🧠 {}", "...".dimmed());
}
EventType::InvalidResponse(response) => {
log::info!("🧠 {}", response.trim().dimmed());
EventType::ChatResponse(response) => {
log::info!("🧠 {}", response.trim().italic());
}
EventType::InvalidAction { invocation, error } => {
log::warn!("invalid action {} : {:?}", &invocation.action, error);
Expand Down

0 comments on commit 88f7213

Please sign in to comment.