agent: Remove unneeded tracking of request usage (#29894)
This PR removes some unneeded tracking of the model request usage in the `ActiveThread` and `ThreadEvent::UsageUpdated` events. Release Notes: - N/A
This commit is contained in:
parent
fe177f5d69
commit
3db4744e18
4 changed files with 4 additions and 18 deletions
|
@ -29,8 +29,7 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use language::{Buffer, Language, LanguageRegistry};
|
use language::{Buffer, Language, LanguageRegistry};
|
||||||
use language_model::{
|
use language_model::{
|
||||||
LanguageModelRequestMessage, LanguageModelToolUseId, MessageContent, RequestUsage, Role,
|
LanguageModelRequestMessage, LanguageModelToolUseId, MessageContent, Role, StopReason,
|
||||||
StopReason,
|
|
||||||
};
|
};
|
||||||
use markdown::parser::{CodeBlockKind, CodeBlockMetadata};
|
use markdown::parser::{CodeBlockKind, CodeBlockMetadata};
|
||||||
use markdown::{HeadingLevelStyles, Markdown, MarkdownElement, MarkdownStyle, ParsedMarkdown};
|
use markdown::{HeadingLevelStyles, Markdown, MarkdownElement, MarkdownStyle, ParsedMarkdown};
|
||||||
|
@ -72,7 +71,6 @@ pub struct ActiveThread {
|
||||||
expanded_thinking_segments: HashMap<(MessageId, usize), bool>,
|
expanded_thinking_segments: HashMap<(MessageId, usize), bool>,
|
||||||
expanded_code_blocks: HashMap<(MessageId, usize), bool>,
|
expanded_code_blocks: HashMap<(MessageId, usize), bool>,
|
||||||
last_error: Option<ThreadError>,
|
last_error: Option<ThreadError>,
|
||||||
last_usage: Option<RequestUsage>,
|
|
||||||
notifications: Vec<WindowHandle<AgentNotification>>,
|
notifications: Vec<WindowHandle<AgentNotification>>,
|
||||||
copied_code_block_ids: HashSet<(MessageId, usize)>,
|
copied_code_block_ids: HashSet<(MessageId, usize)>,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
|
@ -783,7 +781,6 @@ impl ActiveThread {
|
||||||
hide_scrollbar_task: None,
|
hide_scrollbar_task: None,
|
||||||
editing_message: None,
|
editing_message: None,
|
||||||
last_error: None,
|
last_error: None,
|
||||||
last_usage: None,
|
|
||||||
copied_code_block_ids: HashSet::default(),
|
copied_code_block_ids: HashSet::default(),
|
||||||
notifications: Vec::new(),
|
notifications: Vec::new(),
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
|
@ -840,10 +837,6 @@ impl ActiveThread {
|
||||||
self.last_error.take();
|
self.last_error.take();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn last_usage(&self) -> Option<RequestUsage> {
|
|
||||||
self.last_usage
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the editing message id and the estimated token count in the content
|
/// Returns the editing message id and the estimated token count in the content
|
||||||
pub fn editing_message_id(&self) -> Option<(MessageId, usize)> {
|
pub fn editing_message_id(&self) -> Option<(MessageId, usize)> {
|
||||||
self.editing_message
|
self.editing_message
|
||||||
|
@ -949,9 +942,6 @@ impl ActiveThread {
|
||||||
ThreadEvent::ShowError(error) => {
|
ThreadEvent::ShowError(error) => {
|
||||||
self.last_error = Some(error.clone());
|
self.last_error = Some(error.clone());
|
||||||
}
|
}
|
||||||
ThreadEvent::UsageUpdated(usage) => {
|
|
||||||
self.last_usage = Some(*usage);
|
|
||||||
}
|
|
||||||
ThreadEvent::NewRequest | ThreadEvent::CompletionCanceled => {
|
ThreadEvent::NewRequest | ThreadEvent::CompletionCanceled => {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1366,7 +1366,6 @@ impl AgentDiff {
|
||||||
}
|
}
|
||||||
// intentionally being exhaustive in case we add a variant we should handle
|
// intentionally being exhaustive in case we add a variant we should handle
|
||||||
ThreadEvent::Stopped(Ok(StopReason::ToolUse))
|
ThreadEvent::Stopped(Ok(StopReason::ToolUse))
|
||||||
| ThreadEvent::UsageUpdated(_)
|
|
||||||
| ThreadEvent::StreamedCompletion
|
| ThreadEvent::StreamedCompletion
|
||||||
| ThreadEvent::ReceivedTextChunk
|
| ThreadEvent::ReceivedTextChunk
|
||||||
| ThreadEvent::StreamedAssistantText(_, _)
|
| ThreadEvent::StreamedAssistantText(_, _)
|
||||||
|
|
|
@ -1545,7 +1545,6 @@ impl Thread {
|
||||||
let usage = RequestUsage { limit, amount: amount as i32 };
|
let usage = RequestUsage { limit, amount: amount as i32 };
|
||||||
|
|
||||||
thread.last_usage = Some(usage);
|
thread.last_usage = Some(usage);
|
||||||
cx.emit(ThreadEvent::UsageUpdated(usage));
|
|
||||||
}
|
}
|
||||||
CompletionRequestStatus::ToolUseLimitReached => {
|
CompletionRequestStatus::ToolUseLimitReached => {
|
||||||
thread.tool_use_limit_reached = true;
|
thread.tool_use_limit_reached = true;
|
||||||
|
@ -1714,11 +1713,11 @@ impl Thread {
|
||||||
LanguageModelCompletionEvent::StatusUpdate(
|
LanguageModelCompletionEvent::StatusUpdate(
|
||||||
CompletionRequestStatus::UsageUpdated { amount, limit },
|
CompletionRequestStatus::UsageUpdated { amount, limit },
|
||||||
) => {
|
) => {
|
||||||
this.update(cx, |_, cx| {
|
this.update(cx, |thread, _cx| {
|
||||||
cx.emit(ThreadEvent::UsageUpdated(RequestUsage {
|
thread.last_usage = Some(RequestUsage {
|
||||||
limit,
|
limit,
|
||||||
amount: amount as i32,
|
amount: amount as i32,
|
||||||
}));
|
});
|
||||||
})?;
|
})?;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2565,7 +2564,6 @@ pub enum ThreadError {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ThreadEvent {
|
pub enum ThreadEvent {
|
||||||
ShowError(ThreadError),
|
ShowError(ThreadError),
|
||||||
UsageUpdated(RequestUsage),
|
|
||||||
StreamedCompletion,
|
StreamedCompletion,
|
||||||
ReceivedTextChunk,
|
ReceivedTextChunk,
|
||||||
NewRequest,
|
NewRequest,
|
||||||
|
|
|
@ -283,7 +283,6 @@ impl ExampleContext {
|
||||||
| ThreadEvent::ReceivedTextChunk
|
| ThreadEvent::ReceivedTextChunk
|
||||||
| ThreadEvent::StreamedToolUse { .. }
|
| ThreadEvent::StreamedToolUse { .. }
|
||||||
| ThreadEvent::CheckpointChanged
|
| ThreadEvent::CheckpointChanged
|
||||||
| ThreadEvent::UsageUpdated(_)
|
|
||||||
| ThreadEvent::CancelEditing => {
|
| ThreadEvent::CancelEditing => {
|
||||||
tx.try_send(Ok(())).ok();
|
tx.try_send(Ok(())).ok();
|
||||||
if std::env::var("ZED_EVAL_DEBUG").is_ok() {
|
if std::env::var("ZED_EVAL_DEBUG").is_ok() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue