Make language model deserialization more resilient (#31311)
This expands our deserialization of JSON from models to be more tolerant of different variations that the model may send, including capitalization, wrapping things in objects vs. being plain strings, etc. Also when deserialization fails, it reports the entire error in the JSON so we can see what failed to deserialize. (Previously these errors were very unhelpful at diagnosing the problem.) Finally, also removes the `WrappedText` variant since the custom deserializer just turns that style of JSON into a normal `Text` variant. Release Notes: - N/A
This commit is contained in:
parent
7443fde4e9
commit
00fd045844
9 changed files with 301 additions and 69 deletions
|
@ -9,7 +9,7 @@ use handlebars::Handlebars;
|
|||
use language::{Buffer, DiagnosticSeverity, OffsetRangeExt as _};
|
||||
use language_model::{
|
||||
LanguageModel, LanguageModelCompletionEvent, LanguageModelRequest, LanguageModelRequestMessage,
|
||||
LanguageModelToolResultContent, MessageContent, Role, TokenUsage, WrappedTextContent,
|
||||
LanguageModelToolResultContent, MessageContent, Role, TokenUsage,
|
||||
};
|
||||
use project::lsp_store::OpenLspBufferHandle;
|
||||
use project::{DiagnosticSummary, Project, ProjectPath};
|
||||
|
@ -967,11 +967,7 @@ impl RequestMarkdown {
|
|||
}
|
||||
|
||||
match &tool_result.content {
|
||||
LanguageModelToolResultContent::Text(text)
|
||||
| LanguageModelToolResultContent::WrappedText(WrappedTextContent {
|
||||
text,
|
||||
..
|
||||
}) => {
|
||||
LanguageModelToolResultContent::Text(text) => {
|
||||
writeln!(messages, "{text}\n").ok();
|
||||
}
|
||||
LanguageModelToolResultContent::Image(image) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue