Allow attaching text threads as context (#29947)
Release Notes: - N/A --------- Co-authored-by: Michael Sloan <mgsloan@gmail.com>
This commit is contained in:
parent
7f868a2eff
commit
dd79c29af9
24 changed files with 784 additions and 245 deletions
|
@ -32,7 +32,7 @@ use serde::{Deserialize, Serialize};
|
|||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
cmp::{Ordering, max},
|
||||
fmt::Debug,
|
||||
fmt::{Debug, Write as _},
|
||||
iter, mem,
|
||||
ops::Range,
|
||||
path::Path,
|
||||
|
@ -2539,6 +2539,26 @@ impl AssistantContext {
|
|||
Some(user_message)
|
||||
}
|
||||
|
||||
pub fn to_xml(&self, cx: &App) -> String {
|
||||
let mut output = String::new();
|
||||
let buffer = self.buffer.read(cx);
|
||||
for message in self.messages(cx) {
|
||||
if message.status != MessageStatus::Done {
|
||||
continue;
|
||||
}
|
||||
|
||||
writeln!(&mut output, "<{}>", message.role).unwrap();
|
||||
for chunk in buffer.text_for_range(message.offset_range) {
|
||||
output.push_str(chunk);
|
||||
}
|
||||
if !output.ends_with('\n') {
|
||||
output.push('\n');
|
||||
}
|
||||
writeln!(&mut output, "</{}>", message.role).unwrap();
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
pub fn to_completion_request(
|
||||
&self,
|
||||
request_type: RequestType,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue