voyage_embedding {tidyllm} | R Documentation |
Generate Embeddings Using Voyage AI API
Description
This function creates embedding vectors from text or multimodal inputs (text and images) using the Voyage AI API. It supports three types of input:
Usage
voyage_embedding(
.input,
.model = "voyage-3",
.timeout = 120,
.dry_run = FALSE,
.max_tries = 3,
.verbose = FALSE
)
Arguments
.input |
Input to embed. Can be:
|
.model |
The embedding model identifier. For text-only: "voyage-3" (default). For multimodal inputs: "voyage-multimodal-3" is used automatically. |
.timeout |
Timeout for the API request in seconds (default: 120). |
.dry_run |
If TRUE, perform a dry run and return the request object without sending. |
.max_tries |
Maximum retry attempts for requests (default: 3). |
.verbose |
Should information about current rate limits be printed? (default: FALSE). |
Details
Character vector: Embeds each text string separately
LLMMessage object: Extracts and embeds text content from messages
List of mixed content: Processes a combination of text strings and image objects created with
img()
For multimodal inputs, the function automatically switches to Voyage's multimodal API
and formats the response with appropriate labels (e.g., "[IMG] image.png"
) for images.
Value
A tibble with two columns: input
and embeddings
.
The
input
column contains the input texts or image labelsThe
embeddings
column is a list column where each row contains an embedding vector
Examples
## Not run:
# Text embeddings
voyage_embedding("How does photosynthesis work?")
# Multimodal embeddings
list("A banana", img("banana.jpg"), "Yellow fruit") |>
voyage_embedding()
## End(Not run)