The VoyageAIEmbedder class is used to embed text data into vectors using the Voyage AI API.

Usage

from phi.agent import Agent, AgentKnowledge
from phi.vectordb.pgvector import PgVector
from phi.embedder.voyageai import VoyageAIEmbedder

# Create knowledge base
knowledge_base=AgentKnowledge(
    vector_db=PgVector(
        db_url=db_url,
        table_name=embeddings_table,
        embedder=VoyageAIEmbedder(),
    ),
    # 2 references are added to the prompt
    num_documents=2,
),

# Add information to the knowledge base
knowledge_base.load_text("The sky is blue")

# Add the knowledge base to the Agent
agent = Agent(knowledge_base=knowledge_base)

Params

ParameterTypeDefaultDescription
modelstr"voyage-2"The name of the model used for generating embeddings.
dimensionsint1024The dimensionality of the embeddings generated by the model.
request_paramsOptional[Dict[str, Any]]-Additional parameters to include in the API request. Optional.
api_keystr-The API key used for authenticating requests.
base_urlstr"https://api.voyageai.com/v1/embeddings"The base URL for the API endpoint.
max_retriesOptional[int]-The maximum number of retries for API requests. Optional.
timeoutOptional[float]-The timeout duration for API requests. Optional.
client_paramsOptional[Dict[str, Any]]-Additional parameters for configuring the API client. Optional.
voyage_clientOptional[Client]-An instance of the Client to use for making API requests. Optional.