(self, os: &mut Os, session: &mut ChatSession)
| 56 | |
| 57 | impl CompactArgs { |
| 58 | pub async fn execute(self, os: &mut Os, session: &mut ChatSession) -> Result<ChatState, ChatError> { |
| 59 | let default = CompactStrategy::default(); |
| 60 | let prompt = if self.prompt.is_empty() { |
| 61 | None |
| 62 | } else { |
| 63 | Some(self.prompt.join(" ")) |
| 64 | }; |
| 65 | |
| 66 | // Compact interrupts the current conversation so this will always result in a new user |
| 67 | // turn. |
| 68 | session.reset_user_turn(); |
| 69 | |
| 70 | session |
| 71 | .compact_history(os, prompt, self.show_summary, CompactStrategy { |
| 72 | messages_to_exclude: self.messages_to_exclude.unwrap_or(default.messages_to_exclude), |
| 73 | truncate_large_messages: self.truncate_large_messages.unwrap_or(default.truncate_large_messages), |
| 74 | max_message_length: self.max_message_length.map_or(default.max_message_length, |v| { |
| 75 | v.clamp(UserMessageContent::TRUNCATED_SUFFIX.len(), MAX_USER_MESSAGE_SIZE) |
| 76 | }), |
| 77 | }) |
| 78 | .await |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /// Parameters for performing the history compaction request. |
nothing calls this directly
no test coverage detected