Embedding Agent • AI Agent SDK
EmbeddingAgent: A specialized agent for generating text embeddings.
EmbeddingAgent
Defined in the Embedding Agent module.
AI Agent
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
Optional[str]No description available.
Optional[str]No description available.
Optional[str]No description available.
Optional[str]No description available.
Optional[str]No description available.
Optional[str]No description available.
OptionalNo description available.
Union[bool, int]No description available.
Methods
Lazily initialize Rich Console.
litellm()Lazy load litellm module when needed.
embed()Generate embedding for a single text.
embed_batch()Generate embeddings for multiple texts.
similarity()Calculate cosine similarity between two texts.
find_most_similar()Find the most similar texts to a query.
aembed()Async version of embed().
aembed_batch()Async version of embed_batch().
asimilarity()Async version of similarity().
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}")Source
View on GitHubpraisonaiagents/agent/embedding_agent.py at line 47