pub struct VisionAnswer {
pub regions: Vec<AnswerRegion>,
pub text: Option<String>,
pub fields: BTreeMap<String, String>,
}Expand description
What an agent perceived in one turn, read from its vision tool responses.
§Example
use adk_eval::vision::VisionAnswer;
use serde_json::json;
let answer = VisionAnswer::from_tool_response(
"vision_describe",
&json!({"text": "An invoice.", "value": {"total": 58.2, "currency": "USD"}}),
)
.unwrap();
assert_eq!(answer.fields["total"], "58.2");
assert_eq!(answer.text.as_deref(), Some("An invoice."));Fields§
§regions: Vec<AnswerRegion>Regions found, in source pixels.
text: Option<String>Text read or answered.
fields: BTreeMap<String, String>Field values, from a describer’s structured value or a reader’s fields.
Implementations§
Source§impl VisionAnswer
impl VisionAnswer
Sourcepub fn from_tool_response(tool: &str, response: &Value) -> Option<Self>
pub fn from_tool_response(tool: &str, response: &Value) -> Option<Self>
Reads the response of one of the VISION_TOOLS; None for any other tool or a
response that holds no regions, text or fields.
| Key | Becomes |
|---|---|
regions | regions (box arrays, optional mask, or region-set shapes) |
blocks | text: the blocks’ text in the order given, one line each |
text | text (preferred over blocks) |
value, fields | fields: each top-level scalar, as a string |
Sourcepub fn from_json(value: &Value) -> Option<Self>
pub fn from_json(value: &Value) -> Option<Self>
Reads an answer from any JSON object with the keys
from_tool_response lists.
Trait Implementations§
Source§impl Clone for VisionAnswer
impl Clone for VisionAnswer
Source§impl Debug for VisionAnswer
impl Debug for VisionAnswer
Source§impl Default for VisionAnswer
impl Default for VisionAnswer
Source§impl<'de> Deserialize<'de> for VisionAnswer
impl<'de> Deserialize<'de> for VisionAnswer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for VisionAnswer
impl PartialEq for VisionAnswer
Source§impl Serialize for VisionAnswer
impl Serialize for VisionAnswer
impl StructuralPartialEq for VisionAnswer
Auto Trait Implementations§
impl Forget for VisionAnswer
impl Freeze for VisionAnswerwhere
*const u8 is !null: Freeze,
PhantomData<AnswerRegion>: Freeze,
PhantomData<u8>: Freeze,
*const LeafNode<String, String> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, String)>>: Freeze,
impl Move for VisionAnswer
impl RefUnwindSafe for VisionAnswer
impl Send for VisionAnswer
impl Sync for VisionAnswer
impl Unpin for VisionAnswer
impl UnsafeUnpin for VisionAnswerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<AnswerRegion>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const LeafNode<String, String> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, String)>>: UnsafeUnpin,
impl UnwindSafe for VisionAnswer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more