assistant2: Add support for referencing other threads as context (#22092)

This PR adds the ability to reference other threads as context:

<img width="1159" alt="Screenshot 2024-12-16 at 11 29 54 AM"
src="https://github.com/user-attachments/assets/bb8a24ff-56d3-4406-ab8c-6657e65d8c70"
/>

<img width="1159" alt="Screenshot 2024-12-16 at 11 29 35 AM"
src="https://github.com/user-attachments/assets/7a02ebda-a2f5-40e9-9dd4-1bb029cb1c43"
/>


Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-12-16 11:50:57 -05:00 committed by GitHub
parent 188c55c8a6
commit 88f7942f11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 278 additions and 11 deletions

View file

@ -194,6 +194,7 @@ impl Thread {
if let Some(context) = self.context_for_message(message.id) {
let mut file_context = String::new();
let mut fetch_context = String::new();
let mut thread_context = String::new();
for context in context.iter() {
match context.kind {
@ -207,6 +208,12 @@ impl Thread {
fetch_context.push_str(&context.text);
fetch_context.push('\n');
}
ContextKind::Thread => {
thread_context.push_str(&context.name);
thread_context.push('\n');
thread_context.push_str(&context.text);
thread_context.push('\n');
}
}
}
@ -221,6 +228,12 @@ impl Thread {
context_text.push_str(&fetch_context);
}
if !thread_context.is_empty() {
context_text
.push_str("The following previous conversation threads are available\n");
context_text.push_str(&thread_context);
}
request_message
.content
.push(MessageContent::Text(context_text))