pub struct EmbeddingInput {
pub contents: Vec<Content>,
}Expand description
One value to embed.
Upstream is generic over the input type (EmbeddingInputT): text-only
clients take str, while Foundry takes Content | str and Gemini takes
str or a multimodal Content. This port uses one input type for every
client so the trait stays object-safe. An input is a list of
Content items embedded together as one vector: usually a single
text, or a single image as Content::Data or Content::Uri, and
several items where a provider can combine them (Gemini embeds text and
media parts together; Foundry pairs an image with a caption).
Strings convert directly, so text callers write
vec!["hello".into()]:
let text: EmbeddingInput = "a cat on a mat".into();
assert_eq!(text.as_text(), Some("a cat on a mat"));
let png = [0x89, 0x50, 0x4e, 0x47];
let image = EmbeddingInput::from(Content::Data(DataContent::from_bytes(&png, "image/png")));
assert_eq!(image.as_text(), None);A client that cannot embed some input returns an error naming its index rather than skipping it, so results always line up with inputs.
Fields§
§contents: Vec<Content>The items embedded together into one vector.
Implementations§
Source§impl EmbeddingInput
impl EmbeddingInput
Sourcepub fn new(contents: Vec<Content>) -> EmbeddingInput
pub fn new(contents: Vec<Content>) -> EmbeddingInput
An input from content items embedded together.
Sourcepub fn text(text: impl Into<String>) -> EmbeddingInput
pub fn text(text: impl Into<String>) -> EmbeddingInput
A text input.
Sourcepub fn into_texts(
values: Vec<EmbeddingInput>,
provider: &str,
) -> Result<Vec<String>, Error>
pub fn into_texts( values: Vec<EmbeddingInput>, provider: &str, ) -> Result<Vec<String>, Error>
Converts a batch to plain strings for a client that embeds text only.
Fails on the first input that is not exactly one text item, naming
provider and the input’s index.
Trait Implementations§
Source§impl Clone for EmbeddingInput
impl Clone for EmbeddingInput
Source§fn clone(&self) -> EmbeddingInput
fn clone(&self) -> EmbeddingInput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more