Skip to main content

EmbeddingAgent

Defined in the embedding_agent module.
A specialized agent for generating text embeddings. Provides:
  • Single text embedding
  • Batch text embedding
  • Similarity calculation between texts
Supported Providers:
  • OpenAI: text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002
  • Azure: azure/text-embedding-3-small
  • Cohere: cohere/embed-english-v3.0, cohere/embed-multilingual-v3.0
  • Voyage: voyage/voyage-3, voyage/voyage-3-lite
  • Mistral: mistral/mistral-embed

Constructor

name
Optional
No description available.
instructions
Optional
No description available.
llm
Optional
No description available.
model
Optional
No description available.
base_url
Optional
No description available.
api_key
Optional
No description available.
embedding
Optional
No description available.
verbose
Union
default:"True"
No description available.

Methods

Usage

from praisonaiagents import EmbeddingAgent
    
    # Simple usage
    agent = EmbeddingAgent()
    embedding = agent.embed("Hello world")
    print(f"Embedding dimension: {len(embedding)}")
    
    # Batch embedding
    embeddings = agent.embed_batch([
        "First text",
        "Second text",
        "Third text"
    ])
    
    # Calculate similarity
    score = agent.similarity("Hello", "Hi there")
    print(f"Similarity: {score:.2f}")