assistant2: Suggest current thread in inline assistant (#22586)
Release Notes: - N/A --------- Co-authored-by: Marshall <marshall@zed.com>
This commit is contained in:
parent
0e75ca8603
commit
374c298bd5
8 changed files with 161 additions and 114 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue