Accept wrapped text content from LLM providers (#31048)

Some providers sometimes send `{ "type": "text", "text": ... }` instead
of just the text as a string. Now we accept those instead of erroring.

Release Notes:

- N/A
This commit is contained in:
Richard Feldman 2025-05-20 16:50:02 -04:00 committed by GitHub
parent 89700c3682
commit 4bb04cef9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 72 additions and 26 deletions

View file

@ -9,7 +9,7 @@ use handlebars::Handlebars;
use language::{Buffer, DiagnosticSeverity, OffsetRangeExt as _};
use language_model::{
LanguageModel, LanguageModelCompletionEvent, LanguageModelRequest, LanguageModelRequestMessage,
LanguageModelToolResultContent, MessageContent, Role, TokenUsage,
LanguageModelToolResultContent, MessageContent, Role, TokenUsage, WrappedTextContent,
};
use project::lsp_store::OpenLspBufferHandle;
use project::{DiagnosticSummary, Project, ProjectPath};
@ -973,8 +973,12 @@ impl RequestMarkdown {
}
match &tool_result.content {
LanguageModelToolResultContent::Text(str) => {
writeln!(messages, "{}\n", str).ok();
LanguageModelToolResultContent::Text(text)
| LanguageModelToolResultContent::WrappedText(WrappedTextContent {
text,
..
}) => {
writeln!(messages, "{text}\n").ok();
}
LanguageModelToolResultContent::Image(image) => {
writeln!(messages, "![Image](data:base64,{})\n", image.source).ok();