Skip to content

Commit 645a23b

Browse files
committed
feat: propagate None in ExtractByLlm
1 parent d3bc087 commit 645a23b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ops/functions/extract_by_llm.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl SimpleFunctionExecutor for Executor {
9696
.transpose()?;
9797

9898
if text.is_none() && image_bytes.is_none() {
99-
api_bail!("At least one of `text` or `image` must be provided");
99+
return Ok(Value::Null);
100100
}
101101

102102
let user_prompt = text.map_or("", |v| v);
@@ -147,7 +147,13 @@ impl SimpleFunctionFactoryBase for Factory {
147147
api_bail!("At least one of 'text' or 'image' must be provided");
148148
}
149149

150-
Ok((args, spec.output_type.clone()))
150+
let mut output_type = spec.output_type.clone();
151+
if args.text.as_ref().map_or(true, |arg| arg.typ.nullable)
152+
&& args.image.as_ref().map_or(true, |arg| arg.typ.nullable)
153+
{
154+
output_type.nullable = true;
155+
}
156+
Ok((args, output_type))
151157
}
152158

153159
async fn build_executor(

0 commit comments

Comments
 (0)