fix: expose ollama error (#2378)

This commit is contained in:
Yingjie He
2025-04-28 16:46:39 -07:00
committed by GitHub
parent 711554cbcf
commit 8d6c5ef6af

View File

@@ -93,11 +93,11 @@ where
struct CodeVisitor;
impl Visitor<'_> for CodeVisitor {
impl<'de> Visitor<'de> for CodeVisitor {
type Value = Option<String>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a string or a number for the code field")
formatter.write_str("a string, a number, null, or none for the code field")
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
@@ -120,9 +120,23 @@ where
{
Ok(None)
}
fn visit_unit<E>(self) -> Result<Self::Value, E>
where
E: de::Error,
{
Ok(None)
}
fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(CodeVisitor)
}
}
deserializer.deserialize_any(CodeVisitor)
deserializer.deserialize_option(CodeVisitor)
}
impl OpenAIError {