Phidata uses OpenAIEmbedder as the default embeder for the vector database. The OpenAIEmbedder class is used to embed text data into vectors using the OpenAI API.

Usage

from phi.agent import Agent, AgentKnowledge
from phi.vectordb.pgvector import PgVector
from phi.embedder.openai import OpenAIEmbedder

# Create knowledge base
knowledge_base=AgentKnowledge(
    vector_db=PgVector(
        db_url=db_url,
        table_name=embeddings_table,
        embedder=OpenAIEmbedder(),
    ),
    # 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"text-embedding-ada-002"The name of the model used for generating embeddings.
dimensionsint1536The dimensionality of the embeddings generated by the model.
encoding_formatLiteral['float', 'base64']"float"The format in which the embeddings are encoded. Options are “float” or “base64”.
userstr-The user associated with the API request.
api_keystr-The API key used for authenticating requests.
organizationstr-The organization associated with the API request.
base_urlstr-The base URL for the API endpoint.
request_paramsOptional[Dict[str, Any]]-Additional parameters to include in the API request.
client_paramsOptional[Dict[str, Any]]-Additional parameters for configuring the API client.
openai_clientOptional[OpenAIClient]-An instance of the OpenAIClient to use for making API requests.