Skip to content

Commit d19eace

Browse files
committed
Refactor context utilisation logic to accurately calculate and display the number of tokens exceeding the warning threshold
1 parent 6b890af commit d19eace

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/ui/src/components/editor/panel/ContextUtilisation/ContextUtilisation.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const format_tokens = (tokens: number): string => {
1515
}
1616

1717
export const ContextUtilisation: React.FC<Props> = (props) => {
18+
console.log('xxx',props)
1819
const is_above_threshold =
1920
props.current_context_size > props.context_size_warning_threshold
2021
const progress = Math.min(
@@ -42,7 +43,10 @@ export const ContextUtilisation: React.FC<Props> = (props) => {
4243
const formatted_remaining_tokens = format_tokens(remaining_tokens)
4344
title_text = `${formatted_remaining_tokens} tokens remaining until threshold warning (change in settings)`
4445
} else {
45-
title_text = `Context of size ${formatted_current_size} tokens exceeds threshold by ${formatted_threshold} tokens`
46+
const exceeded_by =
47+
props.current_context_size - props.context_size_warning_threshold
48+
const formatted_exceeded_by = format_tokens(exceeded_by)
49+
title_text = `Threshold of ${formatted_threshold} tokens is exceeded by ${formatted_exceeded_by} tokens`
4650
}
4751

4852
return (

0 commit comments

Comments
 (0)