mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 22:54:24 +01:00
fix: cap the repeat time when display usage (#2864)
This commit is contained in:
@@ -621,12 +621,19 @@ pub fn display_greeting() {
|
|||||||
pub fn display_context_usage(total_tokens: usize, context_limit: usize) {
|
pub fn display_context_usage(total_tokens: usize, context_limit: usize) {
|
||||||
use console::style;
|
use console::style;
|
||||||
|
|
||||||
// Calculate percentage used
|
if context_limit == 0 {
|
||||||
let percentage = (total_tokens as f64 / context_limit as f64 * 100.0).round() as usize;
|
println!("Context: Error - context limit is zero");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Create dot visualization
|
// Calculate percentage used with bounds checking
|
||||||
|
let percentage =
|
||||||
|
(((total_tokens as f64 / context_limit as f64) * 100.0).round() as usize).min(100);
|
||||||
|
|
||||||
|
// Create dot visualization with safety bounds
|
||||||
let dot_count = 10;
|
let dot_count = 10;
|
||||||
let filled_dots = ((percentage as f64 / 100.0) * dot_count as f64).round() as usize;
|
let filled_dots =
|
||||||
|
(((percentage as f64 / 100.0) * dot_count as f64).round() as usize).min(dot_count);
|
||||||
let empty_dots = dot_count - filled_dots;
|
let empty_dots = dot_count - filled_dots;
|
||||||
|
|
||||||
let filled = "●".repeat(filled_dots);
|
let filled = "●".repeat(filled_dots);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"license": {
|
"license": {
|
||||||
"name": "Apache-2.0"
|
"name": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"version": "1.0.26"
|
"version": "1.0.27"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"/agent/tools": {
|
"/agent/tools": {
|
||||||
|
|||||||
Reference in New Issue
Block a user