assistant2: Add Thread::send_to_model method (#25703)

This PR adds a new `send_to_model` method to the `Thread` to encapsulate
more of the thread-specific capabilities.

We then call this in `MessageEditor::send_to_model`.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-02-26 19:16:44 -05:00 committed by GitHub
parent f0dec2f576
commit 9822d9673c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 20 deletions

View file

@ -7,7 +7,7 @@ use gpui::{
pulsating_between, Animation, AnimationExt, App, DismissEvent, Entity, Focusable, Subscription,
TextStyle, WeakEntity,
};
use language_model::{LanguageModelRegistry, LanguageModelRequestTool};
use language_model::LanguageModelRegistry;
use language_model_selector::LanguageModelSelector;
use rope::Point;
use settings::Settings;
@ -205,22 +205,7 @@ impl MessageEditor {
.update(&mut cx, |thread, cx| {
let context = context_store.read(cx).snapshot(cx).collect::<Vec<_>>();
thread.insert_user_message(user_message, context, cx);
let mut request = thread.to_completion_request(request_kind, cx);
if use_tools {
request.tools = thread
.tools()
.tools(cx)
.into_iter()
.map(|tool| LanguageModelRequestTool {
name: tool.name(),
description: tool.description(),
input_schema: tool.input_schema(),
})
.collect();
}
thread.stream_completion(request, model, cx)
thread.send_to_model(model, request_kind, use_tools, cx);
})
.ok();
})