assistant2: Suggest current thread in inline assistant (#22586)

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.com>
This commit is contained in:
Agus Zubiaga 2025-01-02 17:36:57 -03:00 committed by GitHub
parent 0e75ca8603
commit 374c298bd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 161 additions and 114 deletions

View file

@ -164,6 +164,27 @@ impl Thread {
id
}
/// Returns the representation of this [`Thread`] in a textual form.
///
/// This is the representation we use when attaching a thread as context to another thread.
pub fn text(&self) -> String {
let mut text = String::new();
for message in &self.messages {
text.push_str(match message.role {
language_model::Role::User => "User:",
language_model::Role::Assistant => "Assistant:",
language_model::Role::System => "System:",
});
text.push('\n');
text.push_str(&message.text);
text.push('\n');
}
text
}
pub fn to_completion_request(
&self,
_request_kind: RequestKind,