Checkpoint: Defining MessageContent

This commit is contained in:
Agus Zubiaga 2025-08-11 13:22:35 -03:00
parent 62270b33c2
commit 3085c6fad4

View file

@ -10,8 +10,9 @@ use futures::{
stream::FuturesUnordered,
};
use gpui::{App, Context, Entity, SharedString, Task};
use language::Rope;
use language_model::{
LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent,
LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelImage,
LanguageModelRequest, LanguageModelRequestMessage, LanguageModelRequestTool,
LanguageModelToolResult, LanguageModelToolResultContent, LanguageModelToolSchemaFormat,
LanguageModelToolUse, LanguageModelToolUseId, MessageContent, Role, StopReason,
@ -31,6 +32,56 @@ pub struct AgentMessage {
pub content: Vec<MessageContent>,
}
enum MessageContent {
Text(String),
Thinking {
text: String,
signature: Option<String>,
},
File {
path: PathBuf,
content: Rope,
},
Symbol {
name: String,
path: PathBuf,
content: Rope,
},
Thread {
name: String,
content: String,
},
Rule {
name: String,
content: String,
},
RedactedThinking(String),
Image(LanguageModelImage),
ToolUse(LanguageModelToolUse),
ToolResult(LanguageModelToolResult),
}
impl Into<language_model::MessageContent> for MessageContent {
fn into(self) -> language_model::MessageContent {
match self {
MessageContent::Text(text) => language_model::MessageContent::Text(text),
MessageContent::Thinking { data, signature } => todo!(),
MessageContent::File { path, content } => todo!(),
MessageContent::Symbol { name } => todo!(),
MessageContent::Thread { name, content } => todo!(),
MessageContent::Rule { name, content } => todo!(),
MessageContent::RedactedThinking(text) => {
language_model::MessageContent::RedactedThinking(text)
}
MessageContent::Image(image) => language_model::MessageContent::Image(image),
MessageContent::ToolUse(tool_use) => language_model::MessageContent::ToolUse(tool_use),
MessageContent::ToolResult(tool_result) => {
language_model::MessageContent::ToolResult(tool_result)
}
}
}
}
impl AgentMessage {
pub fn to_markdown(&self) -> String {
let mut markdown = format!("## {}\n", self.role);