API Reference๏
Complete API documentation for the Praval framework, auto-generated from source code docstrings.
Overview๏
The Praval API is organized into logical modules:
Core API๏
The fundamental building blocks of the Praval framework.
Core Agent class for the Praval framework. |
|
Reef Communication System for Praval Framework. |
|
Agent and Tool Registry for Praval Framework. |
|
Custom exceptions for the Praval framework. |
Decorators๏
High-level decorator API for creating agents and tools.
Decorator-based Agent API for Praval Framework. |
|
Composition utilities for decorator-based agents. |
Memory System๏
Multi-layered memory capabilities for persistent agents.
MemoryManager - Unified interface for all Praval agent memory systems |
|
Short-term working memory for Praval agents |
|
Long-term vector memory using Qdrant for Praval agents |
|
Episodic memory for Praval agents - conversation history and experiences |
|
Semantic memory for Praval agents - knowledge, facts, and concepts |
|
Memory types and data structures for Praval agents |
Storage System๏
Unified data storage and retrieval across multiple providers.
Data Manager - Unified interface for storage operations |
|
Base Storage Provider Framework |
|
Storage Registry System |
|
Storage decorators for Praval agents |
|
Built-in storage providers for Praval framework |
Tool System๏
Tool integration and management for agent capabilities.
Tool decorator and utilities for Praval Framework. |
|
Tool Registry for Praval Framework. |
LLM Providers๏
Integration with multiple Large Language Model providers.
Factory for creating LLM provider instances. |
|
OpenAI provider implementation for Praval framework. |
|
Anthropic provider implementation for Praval framework. |
|
Cohere provider implementation for Praval framework. |
Detailed Documentation๏
Core Module๏
Core Agent class for the Praval framework.
The Agent class provides a simple, composable interface for LLM-based conversations with support for multiple providers, tools, and state persistence.
- class praval.core.agent.AgentConfig(provider=None, temperature=0.7, max_tokens=1000, system_message=None)[source]๏
Bases:
objectConfiguration for Agent behavior and LLM parameters.
- class praval.core.agent.Agent(name, provider=None, persist_state=False, system_message=None, config=None, memory_enabled=False, memory_config=None, knowledge_base=None)[source]๏
Bases:
objectA simple, composable LLM agent.
The Agent class provides the core functionality for LLM-based conversations with support for multiple providers, conversation history, tools, and state persistence.
Examples
Basic usage: >>> agent = Agent(โassistantโ) >>> response = agent.chat(โHello!โ)
With persistence: >>> agent = Agent(โmy_agentโ, persist_state=True) >>> agent.chat(โRemember this conversationโ)
With tools: >>> agent = Agent(โcalculatorโ) >>> @agent.tool >>> def add(x: int, y: int) -> int: โฆ return x + y
- Parameters:
- __init__(name, provider=None, persist_state=False, system_message=None, config=None, memory_enabled=False, memory_config=None, knowledge_base=None)[source]๏
Initialize a new Agent.
- Parameters:
name (
str) โ Unique identifier for this agentprovider (
Optional[str]) โ LLM provider to use (openai, anthropic, cohere)persist_state (
bool) โ Whether to persist conversation statesystem_message (
Optional[str]) โ System message to set agent behaviorconfig (
Optional[Dict[str,Any]]) โ Additional configuration parametersmemory_enabled (
bool) โ Whether to enable vector memory capabilitiesmemory_config (
Optional[Dict[str,Any]]) โ Configuration for memory systemknowledge_base (
Optional[str]) โ Path to knowledge base files to auto-index
- Raises:
ValueError โ If name is empty or configuration is invalid
ProviderError โ If provider setup fails
- chat(message)[source]๏
Send a message to the agent and get a response.
- Parameters:
message (
Optional[str]) โ User message to send to the agent- Return type:
- Returns:
Agentโs response as a string
- Raises:
ValueError โ If message is empty or None
PravalError โ If response generation fails
- tool(func)[source]๏
Decorator to register a function as a tool for the agent.
- Parameters:
func (
Callable) โ Function to register as a tool- Return type:
- Returns:
The original function (unchanged)
- Raises:
ValueError โ If function lacks proper type hints
- send_knowledge(to_agent, knowledge, channel='main')[source]๏
Send knowledge to another agent through the reef.
- broadcast_knowledge(knowledge, channel='main')[source]๏
Broadcast knowledge to all agents in the reef.
- request_knowledge(from_agent, request, timeout=30)[source]๏
Request knowledge from another agent with timeout.
- on_spore_received(spore)[source]๏
Handle received spores from the reef.
This is a default implementation that can be overridden by subclasses for custom spore handling.
- Parameters:
spore โ The received Spore object
- Return type:
- create_knowledge_reference(content, importance=0.8)[source]๏
Create knowledge references for lightweight spores
Reef Communication System for Praval Framework.
Like coral reefs facilitate communication between polyps through chemical and biological signals, this system enables knowledge-first communication between agents through structured JSON message queues.
Components: - Spores: JSON messages containing knowledge, data, or requests - ReefChannel: Named message channels within the reef - Reef: The message queue network connecting all agents
- class praval.core.reef.SporeType(*values)[source]๏
Bases:
EnumTypes of spores that can flow through the reef.
- KNOWLEDGE = 'knowledge'๏
- REQUEST = 'request'๏
- RESPONSE = 'response'๏
- BROADCAST = 'broadcast'๏
- NOTIFICATION = 'notification'๏
- class praval.core.reef.Spore(id, spore_type, from_agent, to_agent, knowledge, created_at, expires_at=None, priority=5, reply_to=None, metadata=None, knowledge_references=None, data_references=None)[source]๏
Bases:
objectA spore is a knowledge-carrying message that flows through the reef.
Like biological spores, each carries: - Genetic material (knowledge/data) - Identification markers (metadata) - Survival instructions (processing hints)
Spores can carry either direct knowledge or lightweight references to knowledge stored in vector memory, following the principle that โlight spores travel far.โ
- Parameters:
- add_knowledge_reference(reference_id)[source]๏
Add a reference to stored knowledge
- Parameters:
reference_id (str)
- add_data_reference(reference_uri)[source]๏
Add a reference to storage system data
- Parameters:
reference_uri (str)
- __init__(id, spore_type, from_agent, to_agent, knowledge, created_at, expires_at=None, priority=5, reply_to=None, metadata=None, knowledge_references=None, data_references=None)๏
- Parameters:
- Return type:
None
- class praval.core.reef.ReefChannel(name, max_capacity=1000, max_workers=4)[source]๏
Bases:
objectA message channel within the reef.
Like channels in a coral reef, they: - Have directional flow patterns - Can carry multiple spores simultaneously - Have capacity limits (to prevent overwhelming) - Can experience turbulence (message loss/delays)
- class praval.core.reef.Reef(default_max_workers=4)[source]๏
Bases:
objectThe Reef manages all communication channels and facilitates agent communication.
Like a coral reef ecosystem, it: - Maintains multiple communication channels - Enables knowledge flow between polyps (agents) - Supports both direct and broadcast communication - Provides network health monitoring
- Parameters:
default_max_workers (int)
- create_channel(name, max_capacity=1000, max_workers=None)[source]๏
Create a new reef channel.
- Return type:
- Parameters:
- send(from_agent, to_agent, knowledge, spore_type=SporeType.KNOWLEDGE, channel=None, priority=5, expires_in_seconds=None, reply_to=None, knowledge_references=None, auto_reference_large_knowledge=True)[source]๏
Send a spore through the reef.
- broadcast(from_agent, knowledge, channel=None)[source]๏
Broadcast knowledge to all agents in the reef.
- system_broadcast(knowledge, channel=None)[source]๏
Broadcast system-level messages to all agents in a channel.
- request(from_agent, to_agent, request, channel=None, expires_in_seconds=300)[source]๏
Send a knowledge request to another agent.
- reply(from_agent, to_agent, response, reply_to_spore_id, channel=None)[source]๏
Reply to a knowledge request.
- subscribe(agent_name, handler, channel=None)[source]๏
Subscribe an agent to receive spores from a channel.
- create_knowledge_reference_spore(from_agent, to_agent, knowledge_summary, knowledge_references, spore_type=SporeType.KNOWLEDGE, channel=None)[source]๏
Create a lightweight spore with knowledge references
This follows the reef principle: โlight spores travel farโ
Agent and Tool Registry for Praval Framework.
Provides a global registry for tracking agents and tools across the system, enabling better coordination and discovery in multi-agent applications.
- class praval.core.registry.PravalRegistry[source]๏
Bases:
objectGlobal registry for agents and tools in Praval applications.
Custom exceptions for the Praval framework.
These exceptions provide clear error handling and debugging information for common issues in LLM agent operations.
- exception praval.core.exceptions.PravalError[source]๏
Bases:
ExceptionBase exception for all Praval-related errors.
- exception praval.core.exceptions.ProviderError[source]๏
Bases:
PravalErrorRaised when there are issues with LLM provider operations.
- exception praval.core.exceptions.ConfigurationError[source]๏
Bases:
PravalErrorRaised when there are configuration validation issues.
- exception praval.core.exceptions.ToolError[source]๏
Bases:
PravalErrorRaised when there are issues with tool registration or execution.
- exception praval.core.exceptions.StateError[source]๏
Bases:
PravalErrorRaised when there are issues with state persistence operations.
Decorators Module๏
Decorator-based Agent API for Praval Framework.
This module provides a Pythonic decorator interface for creating agents that automatically handle reef communication and coordination.
Example
@agent(โexplorerโ, channel=โknowledgeโ) def explore_concepts(spore):
concepts = chat(โFind concepts related to: โ + spore.knowledge.get(โconceptโ, โโ)) return {โdiscoveredโ: concepts.split(โ,โ)}
- praval.decorators.agent(name=None, channel=None, system_message=None, auto_broadcast=True, responds_to=None, memory=False, knowledge_base=None)[source]๏
Decorator that turns a function into an autonomous agent.
- Parameters:
name (
Optional[str]) โ Agent name (defaults to function name)channel (
Optional[str]) โ Channel to subscribe to (defaults to name + โ_channelโ)system_message (
Optional[str]) โ System message (defaults to function docstring)auto_broadcast (
bool) โ Whether to auto-broadcast return valuesresponds_to (
Optional[List[str]]) โ List of message types this agent responds to (None = all messages)memory (
Union[bool,Dict[str,Any]]) โ Memory configuration - True for defaults, dict for custom config, False to disableknowledge_base (
Optional[str]) โ Path to knowledge base files for auto-indexing
Examples
Basic agent: @agent(โexplorerโ, channel=โknowledgeโ, responds_to=[โconcept_requestโ]) def explore_concepts(spore):
โโโFind related concepts and broadcast discoveries.โโโ concepts = chat(โRelated to: โ + spore.knowledge.get(โconceptโ, โโ)) return {โtypeโ: โdiscoveryโ, โdiscoveredโ: concepts.split(โ,โ)}
Agent with memory: @agent(โresearcherโ, memory=True) def research_agent(spore):
โโโResearch agent with memory capabilities.โโโ query = spore.knowledge.get(โqueryโ) # Remember the research research_agent.remember(fโResearched: {query}โ) # Recall similar past research past_research = research_agent.recall(query) return {โresearchโ: โcompletedโ, โpast_similarโ: len(past_research)}
Agent with knowledge base: @agent(โexpertโ, memory=True, knowledge_base=โ./knowledge/โ) def expert_agent(spore):
โโโExpert with pre-loaded knowledge base.โโโ question = spore.knowledge.get(โquestionโ) relevant = expert_agent.recall(question, limit=3) return {โanswerโ: [r.content for r in relevant]}
- praval.decorators.chat(message, timeout=10.0)[source]๏
Quick chat function that uses the current agentโs LLM with timeout support. Can only be used within @agent decorated functions.
- Parameters:
- Return type:
- Returns:
LLM response as string
- Raises:
RuntimeError โ If called outside of an @agent function
TimeoutError โ If LLM call exceeds timeout
- async praval.decorators.achat(message, timeout=10.0)[source]๏
Async version of chat function for use within async agent handlers.
- Parameters:
- Return type:
- Returns:
LLM response as string
- Raises:
RuntimeError โ If called outside of an @agent function
TimeoutError โ If LLM call exceeds timeout
- praval.decorators.broadcast(data, channel=None, message_type=None)[source]๏
Quick broadcast function that uses the current agentโs communication. Can only be used within @agent decorated functions.
- Parameters:
- Return type:
- Returns:
Spore ID of the broadcast message
- Raises:
RuntimeError โ If called outside of an @agent function
- praval.decorators.get_agent_info(agent_func)[source]๏
Get information about an @agent decorated function.
Composition utilities for decorator-based agents.
This module provides utilities for composing and orchestrating agents decorated with the @agent decorator.
- praval.composition.agent_pipeline(*agents, channel='pipeline')[source]๏
Compose agents into a pipeline that processes data sequentially.
- Parameters:
- Return type:
- Returns:
Function that triggers the pipeline with initial data
Example
pipeline = agent_pipeline(explorer, analyzer, reporter) pipeline({โtaskโ: โanalyze sentimentโ})
- praval.composition.conditional_agent(condition_func)[source]๏
Decorator for conditional agent execution.
Example
@conditional_agent(lambda spore: spore.knowledge.get(โpriorityโ) == โhighโ) @agent(โurgent_processorโ) def process_urgent(spore):
return {โprocessedโ: True}
- praval.composition.throttled_agent(delay_seconds)[source]๏
Decorator to throttle agent execution.
- Parameters:
delay_seconds (
float) โ Minimum seconds between executions
Example
@throttled_agent(2.0) # Max once every 2 seconds @agent(โslow_processorโ) def process_slowly(spore):
return {โprocessedโ: True}
- class praval.composition.AgentSession(session_name)[source]๏
Bases:
objectContext manager for coordinated agent sessions.
Example
- with AgentSession(โknowledge_miningโ) as session:
session.add_agents(explorer, analyzer, curator) session.broadcast({โtaskโ: โmine concepts about AIโ})
- Parameters:
session_name (str)
- add_agent(agent_func)[source]๏
Add an agent to this session.
- Return type:
- Parameters:
agent_func (Callable)
- add_agents(*agent_funcs)[source]๏
Add multiple agents to this session.
- Return type:
- Parameters:
agent_funcs (Callable)
- praval.composition.start_agents(*agent_funcs, initial_data=None, channel='startup')[source]๏
Convenience function to start multiple agents with initial data.
- Parameters:
- Return type:
- Returns:
Spore ID of startup broadcast
Example
- start_agents(explorer, analyzer, curator,
initial_data={โtaskโ: โanalyze market trendsโ})
Memory Module๏
MemoryManager - Unified interface for all Praval agent memory systems
This coordinates: - Short-term working memory - Long-term vector memory - Episodic conversation memory - Semantic knowledge memory
- class praval.memory.memory_manager.MemoryManager(agent_id, backend='auto', qdrant_url='http://localhost:6333', storage_path=None, collection_name='praval_memories', short_term_max_entries=1000, short_term_retention_hours=24, knowledge_base_path=None)[source]๏
Bases:
objectUnified memory management system for Praval agents
Provides a single interface to: - Store and retrieve memories across all systems - Coordinate between short-term and long-term storage - Manage different types of memory (episodic, semantic, etc.) - Optimize memory access patterns
- Parameters:
- __init__(agent_id, backend='auto', qdrant_url='http://localhost:6333', storage_path=None, collection_name='praval_memories', short_term_max_entries=1000, short_term_retention_hours=24, knowledge_base_path=None)[source]๏
Initialize the unified memory manager
- Parameters:
agent_id (
str) โ ID of the agent using this memorybackend (
str) โ Memory backend (โautoโ, โchromadbโ, โqdrantโ, โmemoryโ)qdrant_url (
str) โ URL for Qdrant vector databasestorage_path (
Optional[str]) โ Path for persistent storagecollection_name (
str) โ Collection name for vector storageshort_term_max_entries (
int) โ Max entries in short-term memoryshort_term_retention_hours (
int) โ Short-term memory retention timeknowledge_base_path (
Optional[str]) โ Path to knowledge base files to auto-index
- store_memory(agent_id, content, memory_type=MemoryType.SHORT_TERM, metadata=None, importance=0.5, store_long_term=None)[source]๏
Store a memory entry
- Parameters:
agent_id (
str) โ The agent storing the memorycontent (
str) โ The memory contentmemory_type (
MemoryType) โ Type of memoryimportance (
float) โ Importance score (0.0 to 1.0)store_long_term (
bool) โ Whether to store in long-term memory (auto-decided if None)
- Return type:
- Returns:
Memory ID
- retrieve_memory(memory_id)[source]๏
Retrieve a specific memory by ID
- Parameters:
memory_id (
str) โ The memory ID- Return type:
- Returns:
The memory entry if found
- search_memories(query)[source]๏
Search memories across all systems
- Parameters:
query (
MemoryQuery) โ The search query- Return type:
- Returns:
Combined search results
- get_conversation_context(agent_id, turns=10)[source]๏
Get recent conversation context for an agent
- Parameters:
- Return type:
- Returns:
List of conversation memories
- store_conversation_turn(agent_id, user_message, agent_response, context=None)[source]๏
Store a conversation turn
- store_knowledge(agent_id, knowledge, domain='general', confidence=1.0, knowledge_type='fact')[source]๏
Store knowledge or facts
- get_domain_knowledge(agent_id, domain, limit=20)[source]๏
Get knowledge in a specific domain
- Parameters:
- Return type:
- Returns:
List of knowledge entries
- clear_agent_memories(agent_id, memory_types=None)[source]๏
Clear memories for a specific agent
- Parameters:
agent_id (
str) โ The agent IDmemory_types (
Optional[List[MemoryType]]) โ Types of memory to clear (all if None)
- recall_by_id(memory_id)[source]๏
Recall a specific memory by ID (for spore references)
- Return type:
- Parameters:
memory_id (str)
Short-term working memory for Praval agents
This provides fast, in-memory storage for: - Current conversation context - Recent agent interactions - Active tasks and goals - Temporary state information
- class praval.memory.short_term_memory.ShortTermMemory(max_entries=1000, retention_hours=24, cleanup_interval=3600)[source]๏
Bases:
objectFast, in-memory storage for short-term agent memory
Features: - Thread-safe operations - Automatic cleanup of old memories - Context-aware retrieval - Working memory capacity limits
- __init__(max_entries=1000, retention_hours=24, cleanup_interval=3600)[source]๏
Initialize short-term memory
- store(memory)[source]๏
Store a memory entry
- Parameters:
memory (
MemoryEntry) โ The memory entry to store- Return type:
- Returns:
The ID of the stored memory
- retrieve(memory_id)[source]๏
Retrieve a specific memory by ID
- Parameters:
memory_id (
str) โ The ID of the memory to retrieve- Return type:
- Returns:
The memory entry if found, None otherwise
- search(query)[source]๏
Search memories using text similarity
- Parameters:
query (
MemoryQuery) โ The search query- Return type:
- Returns:
Search results with matching memories
- get_recent(agent_id=None, limit=10)[source]๏
Get recent memories
- Parameters:
- Return type:
- Returns:
List of recent memory entries
- get_context(agent_id, context_size=5)[source]๏
Get contextual memories for an agent
- Parameters:
- Return type:
- Returns:
List of contextual memory entries
Long-term vector memory using Qdrant for Praval agents
This provides persistent, vector-based storage for: - Semantic knowledge and concepts - Long-term conversation history - Learned patterns and insights - Cross-session memory persistence
- class praval.memory.long_term_memory.LongTermMemory(qdrant_url='http://localhost:6333', collection_name='praval_memories', vector_size=1536, distance_metric='cosine')[source]๏
Bases:
objectQdrant-based long-term memory for persistent vector storage
Features: - Vector similarity search - Persistent storage across sessions - Scalable to millions of memories - Semantic search capabilities - Memory importance scoring
- __init__(qdrant_url='http://localhost:6333', collection_name='praval_memories', vector_size=1536, distance_metric='cosine')[source]๏
Initialize long-term memory
- store(memory)[source]๏
Store a memory entry with vector embedding
- Parameters:
memory (
MemoryEntry) โ The memory entry to store- Return type:
- Returns:
The ID of the stored memory
- retrieve(memory_id)[source]๏
Retrieve a specific memory by ID
- Parameters:
memory_id (
str) โ The ID of the memory to retrieve- Return type:
- Returns:
The memory entry if found, None otherwise
- search(query)[source]๏
Search memories using vector similarity
- Parameters:
query (
MemoryQuery) โ The search query- Return type:
- Returns:
Search results with matching memories
Episodic memory for Praval agents - conversation history and experiences
This manages: - Conversation turns and dialogue history - Agent interaction sequences - Temporal event chains - Experience-based learning patterns
- class praval.memory.episodic_memory.EpisodicMemory(long_term_memory, short_term_memory, conversation_window=50, episode_lifetime_days=30)[source]๏
Bases:
objectManages episodic memories - experiences and conversations over time
Features: - Conversation turn tracking - Experience sequencing - Temporal relationship modeling - Context window management
- Parameters:
long_term_memory (LongTermMemory)
short_term_memory (ShortTermMemory)
conversation_window (int)
episode_lifetime_days (int)
- __init__(long_term_memory, short_term_memory, conversation_window=50, episode_lifetime_days=30)[source]๏
Initialize episodic memory
- Parameters:
long_term_memory (
LongTermMemory) โ Long-term memory backendshort_term_memory (
ShortTermMemory) โ Short-term memory backendconversation_window (
int) โ Number of conversation turns to keep in contextepisode_lifetime_days (
int) โ How long to keep episodes before archiving
- store_conversation_turn(agent_id, user_message, agent_response, context=None)[source]๏
Store a conversation turn as an episodic memory
- store_experience(agent_id, experience_type, experience_data, outcome, success=True)[source]๏
Store an experience or learning episode
- Parameters:
agent_id (
str) โ The agent that had the experienceexperience_type (
str) โ Type of experience (e.g., โtask_completionโ, โproblem_solvingโ)experience_data (
Dict[str,Any]) โ Data about the experienceoutcome (
str) โ The result or outcomesuccess (
bool) โ Whether the experience was successful
- Return type:
- Returns:
The memory ID
- get_conversation_context(agent_id, turns=None)[source]๏
Get recent conversation context for an agent
- Parameters:
- Return type:
- Returns:
List of recent conversation memories
- get_similar_experiences(agent_id, experience_description, limit=5)[source]๏
Find similar past experiences for an agent
- Parameters:
- Return type:
- Returns:
Search results with similar experiences
- get_episode_timeline(agent_id, start_time, end_time)[source]๏
Get episodic memories within a time range
- Parameters:
- Return type:
- Returns:
List of episodic memories in chronological order
Semantic memory for Praval agents - knowledge, facts, and concepts
This manages: - Factual knowledge storage - Concept relationships - Domain expertise - Learned information persistence
- class praval.memory.semantic_memory.SemanticMemory(long_term_memory)[source]๏
Bases:
objectManages semantic memories - facts, concepts, and knowledge
Features: - Factual knowledge storage - Concept relationship tracking - Knowledge validation and updating - Domain expertise building
- Parameters:
long_term_memory (LongTermMemory)
- __init__(long_term_memory)[source]๏
Initialize semantic memory
- Parameters:
long_term_memory (
LongTermMemory) โ Long-term memory backend for persistence
- store_fact(agent_id, fact, domain, confidence=1.0, source=None, related_concepts=None)[source]๏
Store a factual piece of knowledge
- Parameters:
- Return type:
- Returns:
The memory ID
- store_concept(agent_id, concept, definition, domain, properties=None, relationships=None)[source]๏
Store a concept with its definition and relationships
- Parameters:
agent_id (
str) โ The agent learning this conceptconcept (
str) โ The concept namedefinition (
str) โ Definition of the conceptdomain (
str) โ Domain or field of the conceptproperties (
Optional[Dict[str,Any]]) โ Properties or attributes of the conceptrelationships (
Optional[Dict[str,List[str]]]) โ Relationships to other concepts (e.g., {โis_aโ: [โcategoryโ], โrelates_toโ: [โother_conceptsโ]})
- Return type:
- Returns:
The memory ID
- store_rule(agent_id, rule_name, rule_description, conditions, actions, domain, confidence=1.0)[source]๏
Store a procedural rule or pattern
- Parameters:
- Return type:
- Returns:
The memory ID
- get_knowledge_in_domain(agent_id, domain, limit=50)[source]๏
Get all knowledge in a specific domain
- Parameters:
- Return type:
- Returns:
List of semantic memories in the domain
Find concepts related to a given concept
- Parameters:
- Return type:
- Returns:
Search results with related concepts
- validate_knowledge(agent_id, statement, threshold=0.8)[source]๏
Check if a statement is consistent with stored knowledge
- update_knowledge(agent_id, old_knowledge, new_knowledge, reason='Updated information')[source]๏
Update existing knowledge with new information
Memory types and data structures for Praval agents
- class praval.memory.memory_types.MemoryType(*values)[source]๏
Bases:
EnumTypes of memory entries
- SHORT_TERM = 'short_term'๏
- EPISODIC = 'episodic'๏
- SEMANTIC = 'semantic'๏
- PROCEDURAL = 'procedural'๏
- EMOTIONAL = 'emotional'๏
- class praval.memory.memory_types.MemoryEntry(id, agent_id, memory_type, content, metadata, embedding=None, created_at=None, accessed_at=None, access_count=0, importance=0.5)[source]๏
Bases:
objectA single memory entry
- Parameters:
-
memory_type:
MemoryType๏
- __init__(id, agent_id, memory_type, content, metadata, embedding=None, created_at=None, accessed_at=None, access_count=0, importance=0.5)๏
- class praval.memory.memory_types.MemoryQuery(query_text, memory_types=None, agent_id=None, limit=10, similarity_threshold=0.7, include_metadata=True, temporal_filter=None)[source]๏
Bases:
objectA memory search query
- Parameters:
-
memory_types:
List[MemoryType] = None๏
- __init__(query_text, memory_types=None, agent_id=None, limit=10, similarity_threshold=0.7, include_metadata=True, temporal_filter=None)๏
- class praval.memory.memory_types.MemorySearchResult(entries, scores, query, total_found)[source]๏
Bases:
objectResult of a memory search
- Parameters:
entries (List[MemoryEntry])
query (MemoryQuery)
total_found (int)
-
entries:
List[MemoryEntry]๏
-
query:
MemoryQuery๏
- get_above_threshold(threshold=0.8)[source]๏
Get entries above similarity threshold
- Return type:
- Parameters:
threshold (float)
- __init__(entries, scores, query, total_found)๏
- Parameters:
entries (List[MemoryEntry])
query (MemoryQuery)
total_found (int)
- Return type:
None
Storage Module๏
Data Manager - Unified interface for storage operations
Provides a high-level interface for agents to interact with multiple storage providers through a single, consistent API.
- class praval.storage.data_manager.DataManager(registry=None)[source]๏
Bases:
objectUnified data management interface for agents.
Provides high-level methods for storing, retrieving, and querying data across multiple storage backends through a single interface.
Features: - Automatic provider selection based on data type - Cross-provider queries and operations - Data reference management for spore communication - Storage optimization and caching - Transaction-like operations across providers
- Parameters:
registry (StorageRegistry | None)
- __init__(registry=None)[source]๏
Initialize data manager.
- Parameters:
registry (
Optional[StorageRegistry]) โ Storage registry to use (defaults to global registry)
- set_agent_context(agent_name)[source]๏
Set the current agent context for permission checking.
- Parameters:
agent_name (str)
- async store(provider, resource, data, **kwargs)[source]๏
Store data in a specific provider.
- Parameters:
- Return type:
- Returns:
StorageResult with operation outcome
- async get(provider, resource, **kwargs)[source]๏
Retrieve data from a specific provider.
- Parameters:
- Return type:
- Returns:
StorageResult with retrieved data
- async query(provider, resource, query, **kwargs)[source]๏
Execute a query on a specific provider.
- Parameters:
- Return type:
- Returns:
StorageResult with query results
- async delete(provider, resource, **kwargs)[source]๏
Delete data from a specific provider.
- Parameters:
- Return type:
- Returns:
StorageResult with operation outcome
- async smart_store(data, resource=None, preferred_provider=None, **kwargs)[source]๏
Intelligently store data by selecting the best provider.
- async smart_search(query, providers=None, **kwargs)[source]๏
Search across multiple providers intelligently.
- create_data_reference(provider, resource, **metadata)[source]๏
Create a data reference for spore communication.
- Parameters:
- Return type:
- Returns:
DataReference object
- async resolve_data_reference(data_ref, **kwargs)[source]๏
Resolve a data reference to actual data.
- Parameters:
data_ref (
Union[DataReference,str]) โ DataReference object or URI string**kwargs โ Retrieval parameters
- Return type:
- Returns:
StorageResult with resolved data
- praval.storage.data_manager.get_data_manager()[source]๏
Get the global data manager instance.
- Return type:
- async praval.storage.data_manager.store_data(provider, resource, data, **kwargs)[source]๏
Store data using the global data manager.
- Return type:
- Parameters:
- async praval.storage.data_manager.get_data(provider, resource, **kwargs)[source]๏
Retrieve data using the global data manager.
- Return type:
- Parameters:
- async praval.storage.data_manager.query_data(provider, resource, query, **kwargs)[source]๏
Query data using the global data manager.
- Return type:
- Parameters:
- async praval.storage.data_manager.delete_data(provider, resource, **kwargs)[source]๏
Delete data using the global data manager.
- Return type:
- Parameters:
Base Storage Provider Framework
Defines the core interfaces and base classes for all Praval storage providers. This provides a standardized way to create, register, and use storage backends that agents can access uniformly.
- class praval.storage.base_provider.StorageType(*values)[source]๏
Bases:
EnumTypes of storage backends
- RELATIONAL = 'relational'๏
- DOCUMENT = 'document'๏
- KEY_VALUE = 'key_value'๏
- OBJECT = 'object'๏
- VECTOR = 'vector'๏
- SEARCH = 'search'๏
- GRAPH = 'graph'๏
- FILE_SYSTEM = 'file_system'๏
- CACHE = 'cache'๏
- QUEUE = 'queue'๏
- class praval.storage.base_provider.DataReference(provider, storage_type, resource_id, metadata=<factory>, created_at=<factory>, expires_at=None)[source]๏
Bases:
objectReference to data stored in a backend
- Parameters:
-
storage_type:
StorageType๏
- class praval.storage.base_provider.StorageQuery(operation, resource, parameters=<factory>, filters=<factory>, limit=None, offset=None, timeout=None)[source]๏
Bases:
objectQuery parameters for storage operations
- Parameters:
- class praval.storage.base_provider.StorageResult(success, data=None, error=None, execution_time=0.0, metadata=<factory>, data_reference=None, timestamp=<factory>)[source]๏
Bases:
objectResult from storage operation
- Parameters:
-
data_reference:
Optional[DataReference] = None๏
- __init__(success, data=None, error=None, execution_time=0.0, metadata=<factory>, data_reference=None, timestamp=<factory>)๏
- class praval.storage.base_provider.StorageMetadata(name, description, storage_type, version='1.0.0', supports_async=True, supports_transactions=False, supports_schemas=False, supports_indexing=False, supports_search=False, supports_streaming=False, max_connection_pool=10, default_timeout=30.0, required_config=<factory>, optional_config=<factory>, connection_string_template=None)[source]๏
Bases:
objectMetadata describing a storage providerโs capabilities
- Parameters:
name (str)
description (str)
storage_type (StorageType)
version (str)
supports_async (bool)
supports_transactions (bool)
supports_schemas (bool)
supports_indexing (bool)
supports_search (bool)
supports_streaming (bool)
max_connection_pool (int)
default_timeout (float)
connection_string_template (str | None)
-
storage_type:
StorageType๏
- __init__(name, description, storage_type, version='1.0.0', supports_async=True, supports_transactions=False, supports_schemas=False, supports_indexing=False, supports_search=False, supports_streaming=False, max_connection_pool=10, default_timeout=30.0, required_config=<factory>, optional_config=<factory>, connection_string_template=None)๏
- Parameters:
name (str)
description (str)
storage_type (StorageType)
version (str)
supports_async (bool)
supports_transactions (bool)
supports_schemas (bool)
supports_indexing (bool)
supports_search (bool)
supports_streaming (bool)
max_connection_pool (int)
default_timeout (float)
connection_string_template (str | None)
- Return type:
None
- class praval.storage.base_provider.BaseStorageProvider(name, config)[source]๏
Bases:
ABCAbstract base class for all storage providers.
All storage backends must inherit from this class and implement the required methods. This ensures a consistent interface across all storage types while allowing for provider-specific optimizations.
- abstractmethod async connect()[source]๏
Establish connection to the storage backend.
- Return type:
- Returns:
True if connection successful, False otherwise
- abstractmethod async store(resource, data, **kwargs)[source]๏
Store data in the backend.
- Parameters:
- Return type:
- Returns:
StorageResult with operation outcome
- abstractmethod async retrieve(resource, **kwargs)[source]๏
Retrieve data from the backend.
- Parameters:
resource (
str) โ Resource identifier**kwargs โ Provider-specific parameters
- Return type:
- Returns:
StorageResult with retrieved data
- abstractmethod async query(resource, query, **kwargs)[source]๏
Execute a query against the backend.
- Parameters:
- Return type:
- Returns:
StorageResult with query results
- abstractmethod async delete(resource, **kwargs)[source]๏
Delete data from the backend.
- Parameters:
resource (
str) โ Resource to delete**kwargs โ Provider-specific parameters
- Return type:
- Returns:
StorageResult with operation outcome
- async list_resources(prefix='', **kwargs)[source]๏
List available resources.
- Parameters:
prefix (
str) โ Resource prefix to filter by**kwargs โ Provider-specific parameters
- Return type:
- Returns:
StorageResult with list of resources
- praval.storage.base_provider.create_storage_provider(provider_class, name, config)[source]๏
Create a storage provider instance.
- Parameters:
- Return type:
- Returns:
Configured provider instance
Storage Registry System
Provides centralized registration, discovery, and management of storage providers available to Praval agents. This follows the same pattern as the tool registry for consistent framework design.
- class praval.storage.storage_registry.StorageRegistry[source]๏
Bases:
objectCentral registry for managing storage providers available to agents.
Features: - Provider registration and discovery - Type-based organization (relational, object, vector, etc.) - Access control and permissions - Connection pooling and lifecycle management - Usage statistics and health monitoring - Multi-provider query routing
- async register_provider(provider, replace_existing=False, permissions=None, auto_connect=None)[source]๏
Register a storage provider in the registry.
- Parameters:
- Return type:
- Returns:
True if registration successful, False otherwise
- get_provider(provider_name, agent_name=None)[source]๏
Get a provider by name with permission checking.
- Parameters:
- Return type:
- Returns:
BaseStorageProvider instance
- Raises:
StorageNotFoundError โ If provider not found
StoragePermissionError โ If agent lacks permission
- list_providers(storage_type=None, agent_name=None, connected_only=False)[source]๏
List available providers with optional filtering.
- get_providers_by_type(storage_type)[source]๏
Get all providers of a specific storage type.
- Return type:
- Parameters:
storage_type (StorageType)
- async execute_query(provider_name, query, agent_name=None)[source]๏
Execute a query on a specific provider.
- Parameters:
provider_name (
str) โ Name of provider to queryquery (
StorageQuery) โ Query to execute
- Return type:
- Returns:
StorageResult with query outcome
- remove_permission(provider_name, agent_name)[source]๏
Remove permission for an agent to use a provider.
- block_provider(provider_name)[source]๏
Block a provider from being used.
- Parameters:
provider_name (str)
- praval.storage.storage_registry.get_storage_registry()[source]๏
Get the global storage registry instance.
- Return type:
- async praval.storage.storage_registry.register_storage_provider(provider, **kwargs)[source]๏
Register a storage provider in the global registry.
- Return type:
- Parameters:
provider (BaseStorageProvider)
- praval.storage.storage_registry.get_storage_provider(provider_name, agent_name=None)[source]๏
Get a storage provider from the global registry.
- Return type:
- Parameters:
- praval.storage.storage_registry.list_storage_providers(**kwargs)[source]๏
List available storage providers from the global registry.
Storage decorators for Praval agents
Provides decorator-based integration between agents and storage providers, following the same patterns as the agent and tool decorators.
- praval.storage.decorators.storage_enabled(providers=None, auto_register=True, permissions=None, **default_configs)[source]๏
Decorator to enable storage access for agent functions.
- Parameters:
providers (
Union[str,List[str],Dict[str,Dict[str,Any]],None]) โ Storage providers to enable. Can be: - String: Single provider name - List: Multiple provider names - Dict: Provider name -> configuration mappingauto_register (
bool) โ Whether to auto-register providers from environmentpermissions (
Optional[List[str]]) โ Default permissions for storage access**default_configs โ Default configurations for providers
Examples
@storage_enabled(โpostgresโ) @agent(โdata_analystโ) def analyze_data(spore):
data = storage.query(โpostgresโ, โSELECT * FROM customersโ)
@storage_enabled([โpostgresโ, โs3โ, โredisโ]) @agent(โbusiness_intelligenceโ) def generate_report(spore):
# Access multiple storage backends pass
- @storage_enabled({
โpostgresโ: {โhostโ: โlocalhostโ, โdatabaseโ: โbusinessโ}, โs3โ: {โbucket_nameโ: โreportsโ}
}) @agent(โreport_generatorโ) def create_analysis(spore):
pass
- praval.storage.decorators.requires_storage(*provider_names, permissions=None)[source]๏
Decorator to require specific storage providers for a function.
- Parameters:
Example
@requires_storage(โpostgresโ, โs3โ) @agent(โdata_processorโ) def process_customer_data(spore):
# Function requires both postgres and s3 to be available pass
Storage Providers๏
File system storage provider for Praval framework
Provides local file system storage capabilities with path management, directory operations, and file metadata support.
- class praval.storage.providers.filesystem.FileSystemProvider(name, config)[source]๏
Bases:
BaseStorageProviderLocal file system storage provider.
Features: - File and directory operations - Path management and validation - File metadata and permissions - Recursive operations - Pattern-based file listing - Atomic file operations
- async store(resource, data, **kwargs)[source]๏
Store data to file system.
- Parameters:
- Return type:
- Returns:
StorageResult with operation outcome
- async retrieve(resource, **kwargs)[source]๏
Retrieve data from file system.
- Parameters:
resource (
str) โ File path relative to base_path**kwargs โ Read parameters (encoding, decode_json, etc.)
- Return type:
- Returns:
StorageResult with retrieved data
- async query(resource, query, **kwargs)[source]๏
Execute file system operations.
- Parameters:
- Return type:
- Returns:
StorageResult with query results
- async delete(resource, **kwargs)[source]๏
Delete file or directory from file system.
- Parameters:
resource (
str) โ Path to delete**kwargs โ Delete parameters (recursive, etc.)
- Return type:
- Returns:
StorageResult with operation outcome
PostgreSQL storage provider for Praval framework
Provides relational database capabilities with SQL query support, transactions, and schema management.
- class praval.storage.providers.postgresql.PostgreSQLProvider(name, config)[source]๏
Bases:
BaseStorageProviderPostgreSQL storage provider with async connection pooling.
Features: - Async connection pooling - SQL query execution - Transaction support - Schema management - JSON column support - Full-text search capabilities
- async store(resource, data, **kwargs)[source]๏
Store data in PostgreSQL table.
- Parameters:
- Return type:
- Returns:
StorageResult with operation outcome
- async retrieve(resource, **kwargs)[source]๏
Retrieve data from PostgreSQL table.
- Parameters:
resource (
str) โ Table name**kwargs โ Query parameters (where, limit, offset, order_by, etc.)
- Return type:
- Returns:
StorageResult with retrieved data
- async query(resource, query, **kwargs)[source]๏
Execute SQL query against PostgreSQL.
- Parameters:
- Return type:
- Returns:
StorageResult with query results
- async delete(resource, **kwargs)[source]๏
Delete data from PostgreSQL table.
- Parameters:
resource (
str) โ Table name**kwargs โ Delete parameters (where clause required)
- Return type:
- Returns:
StorageResult with operation outcome
Redis storage provider for Praval framework
Provides key-value storage, caching, and pub/sub capabilities with Redis backend.
- class praval.storage.providers.redis_provider.RedisProvider(name, config)[source]๏
Bases:
BaseStorageProviderRedis key-value storage provider with async support.
Features: - Key-value operations (GET, SET, DEL) - Hash operations (HGET, HSET, HGETALL) - List operations (LPUSH, RPUSH, LRANGE) - Set operations (SADD, SMEMBERS) - Expiration and TTL management - Pub/Sub messaging - Lua script execution
- async store(resource, data, **kwargs)[source]๏
Store data in Redis.
- Parameters:
- Return type:
- Returns:
StorageResult with operation outcome
- async retrieve(resource, **kwargs)[source]๏
Retrieve data from Redis.
- Parameters:
resource (
str) โ Redis key**kwargs โ Additional parameters (decode_json, etc.)
- Return type:
- Returns:
StorageResult with retrieved data
- async query(resource, query, **kwargs)[source]๏
Execute Redis operations or search queries.
- Parameters:
- Return type:
- Returns:
StorageResult with query results
- async delete(resource, **kwargs)[source]๏
Delete keys from Redis.
- Parameters:
resource (
str) โ Key or pattern to delete**kwargs โ Delete parameters
- Return type:
- Returns:
StorageResult with operation outcome
S3 object storage provider for Praval framework
Provides object storage capabilities with S3-compatible backends including AWS S3, MinIO, and other S3-compatible services.
- class praval.storage.providers.s3_provider.S3Provider(name, config)[source]๏
Bases:
BaseStorageProviderS3-compatible object storage provider.
Features: - Object upload, download, and deletion - Bucket management - Presigned URLs for secure access - Metadata and tagging support - Multipart uploads for large files - Lifecycle management - Cross-region replication support
- async store(resource, data, **kwargs)[source]๏
Store object in S3.
- Parameters:
- Return type:
- Returns:
StorageResult with operation outcome
- async retrieve(resource, **kwargs)[source]๏
Retrieve object from S3.
- Parameters:
resource (
str) โ S3 object key**kwargs โ Retrieval parameters (range, decode_json, etc.)
- Return type:
- Returns:
StorageResult with retrieved data
- async query(resource, query, **kwargs)[source]๏
Execute S3 operations or list objects.
- Parameters:
- Return type:
- Returns:
StorageResult with query results
- async delete(resource, **kwargs)[source]๏
Delete object(s) from S3.
- Parameters:
resource (
str) โ Object key or prefix**kwargs โ Delete parameters (recursive, etc.)
- Return type:
- Returns:
StorageResult with operation outcome
Qdrant vector storage provider for Praval framework
Integrates with existing Praval memory system to provide vector storage capabilities through the storage framework.
- class praval.storage.providers.qdrant_provider.QdrantProvider(name, config)[source]๏
Bases:
BaseStorageProviderQdrant vector database storage provider.
Features: - Vector similarity search - Collection management - Point insertion and retrieval - Filtering and metadata search - Batch operations - Integration with Praval memory system
- async store(resource, data, **kwargs)[source]๏
Store vector data in Qdrant.
- Parameters:
resource (
str) โ Collection name (optional, uses default if not specified)data (
Any) โ Data to store - can be: - Single point: {โidโ: โโฆโ, โvectorโ: [โฆ], โpayloadโ: {โฆ}} - Multiple points: [{โidโ: โโฆโ, โvectorโ: [โฆ], โpayloadโ: {โฆ}}, โฆ] - Just vector: [0.1, 0.2, โฆ] (will generate ID)**kwargs โ Additional parameters
- Return type:
- Returns:
StorageResult with operation outcome
- async retrieve(resource, **kwargs)[source]๏
Retrieve vectors from Qdrant.
- Parameters:
resource (
str) โ Collection name or โcollection:point_idโ**kwargs โ Retrieval parameters (point_ids, with_vectors, with_payload)
- Return type:
- Returns:
StorageResult with retrieved data
- async query(resource, query, **kwargs)[source]๏
Execute vector search or other operations.
- Parameters:
- Return type:
- Returns:
StorageResult with query results
- async delete(resource, **kwargs)[source]๏
Delete points from Qdrant.
- Parameters:
resource (
str) โ Collection name or โcollection:point_idโ**kwargs โ Delete parameters (point_ids, filter)
- Return type:
- Returns:
StorageResult with operation outcome
Tool Module๏
Tool decorator and utilities for Praval Framework.
This module provides the @tool decorator for creating tools that can be registered and used by agents. Tools are automatically registered in the global tool registry and can be associated with specific agents.
- praval.tools.tool(tool_name=None, owned_by=None, description=None, category='general', shared=False, version='1.0.0', author='', tags=None)[source]๏
Decorator to register a function as a tool in the Praval framework.
The @tool decorator automatically registers functions as tools that can be used by agents. Tools can be owned by specific agents, shared across all agents, or organized by category.
- Parameters:
tool_name (
Optional[str]) โ Name of the tool (defaults to function name)description (
Optional[str]) โ Description of what the tool does (defaults to docstring)category (
str) โ Category for organizing toolsshared (
bool) โ Whether this tool is available to all agentsversion (
str) โ Version of the toolauthor (
str) โ Author of the tool
- Return type:
- Returns:
Decorated function with tool metadata attached
- Raises:
ToolError โ If tool registration fails or validation errors occur
Examples
Basic tool owned by specific agent: ```python @tool(โadd_numbersโ, owned_by=โcalculatorโ) def add(x: float, y: float) -> float:
โโโAdd two numbers together.โโโ return x + y
Shared tool available to all agents: ```python @tool(โloggerโ, shared=True, category=โutilityโ) def log_message(level: str, message: str) -> str:
โโโLog a message at the specified level.โโโ import logging logger = logging.getLogger(โpraval.toolsโ) getattr(logger, level.lower())(message) return fโLogged: {message}โ
Tool with metadata: ```python @tool(
โvalidate_emailโ, owned_by=โdata_processorโ, category=โvalidationโ, tags=[โemailโ, โvalidationโ, โdataโ], version=โ2.0.0โ, author=โPraval Teamโ
) def validate_email(email: str) -> bool:
โโโValidate email address format.โโโ import re pattern = rโ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$โ return bool(re.match(pattern, email))
- praval.tools.get_tool_info(tool_func)[source]๏
Get information about a @tool decorated function.
- Parameters:
tool_func (
Callable) โ Function decorated with @tool- Return type:
- Returns:
Dictionary with tool metadata
- Raises:
ValueError โ If function is not decorated with @tool
- praval.tools.discover_tools(module=None, pattern=None, category=None)[source]๏
Discover tools based on various criteria.
- praval.tools.list_tools(agent_name=None, category=None, shared_only=False)[source]๏
List tools with optional filtering.
- praval.tools.register_tool_with_agent(tool_name, agent_name)[source]๏
Register an existing tool with an agent at runtime.
- praval.tools.unregister_tool_from_agent(tool_name, agent_name)[source]๏
Unregister a tool from an agent at runtime.
- class praval.tools.ToolCollection(name, description='')[source]๏
Bases:
objectA collection of related tools that can be managed as a group.
Useful for organizing tools by functionality or creating tool suites that can be easily assigned to agents.
Tool Registry for Praval Framework.
This module provides a centralized registry for managing tools and their relationships to agents. Tools can be registered, discovered, and assigned to agents dynamically.
- class praval.core.tool_registry.ToolMetadata(tool_name, owned_by=None, description='', category='general', shared=False, version='1.0.0', author='', tags=<factory>, parameters=<factory>, return_type='Any')[source]๏
Bases:
objectMetadata for a registered tool.
- Parameters:
- __init__(tool_name, owned_by=None, description='', category='general', shared=False, version='1.0.0', author='', tags=<factory>, parameters=<factory>, return_type='Any')๏
- class praval.core.tool_registry.Tool(func, metadata)[source]๏
Bases:
objectWrapper class for a registered tool function.
Provides metadata, validation, and execution capabilities for functions registered as tools in the Praval framework.
- Parameters:
func (Callable)
metadata (ToolMetadata)
- __init__(func, metadata)[source]๏
Initialize a Tool instance.
- Parameters:
func (
Callable) โ The function to wrap as a toolmetadata (
ToolMetadata) โ Metadata describing the tool
- Raises:
ToolError โ If function validation fails
- class praval.core.tool_registry.ToolRegistry[source]๏
Bases:
objectCentralized registry for managing tools and their relationships to agents.
The registry provides functionality to: - Register and retrieve tools - Associate tools with agents - Manage shared tools - Query tools by category - Handle tool lifecycle
- get_tools_for_agent(agent_name)[source]๏
Get all tools available to a specific agent.
This includes: - Tools owned by the agent - Shared tools - Tools explicitly assigned to the agent
- search_tools(name_pattern=None, category=None, owned_by=None, shared_only=False, tags=None)[source]๏
Search for tools based on multiple criteria.
Providers Module๏
Factory for creating LLM provider instances.
Provides a unified interface for instantiating different LLM providers with consistent configuration handling.
- class praval.providers.factory.ProviderFactory[source]๏
Bases:
objectFactory class for creating LLM provider instances.
- static create_provider(provider_name, config)[source]๏
Create an LLM provider instance.
- Parameters:
- Returns:
Provider instance
- Raises:
ProviderError โ If provider is not supported or creation fails
OpenAI provider implementation for Praval framework.
Provides integration with OpenAIโs Chat Completions API with support for conversation history, tool calling, and streaming responses.
- class praval.providers.openai.OpenAIProvider(config)[source]๏
Bases:
objectOpenAI provider for LLM interactions.
Handles communication with OpenAIโs GPT models through the Chat Completions API with support for tools and conversation history.
- __init__(config)[source]๏
Initialize OpenAI provider.
- Parameters:
config โ AgentConfig object with provider settings
- Raises:
ProviderError โ If OpenAI client initialization fails
Anthropic provider implementation for Praval framework.
Provides integration with Anthropicโs Claude models through the Messages API with support for conversation history and system messages.
- class praval.providers.anthropic.AnthropicProvider(config)[source]๏
Bases:
objectAnthropic provider for LLM interactions.
Handles communication with Anthropicโs Claude models through the Messages API with proper system message handling.
- __init__(config)[source]๏
Initialize Anthropic provider.
- Parameters:
config โ AgentConfig object with provider settings
- Raises:
ProviderError โ If Anthropic client initialization fails
- generate(messages, tools=None)[source]๏
Generate a response using Anthropicโs Messages API.
- Parameters:
- Return type:
- Returns:
Generated response as a string
- Raises:
ProviderError โ If API call fails
Cohere provider implementation for Praval framework.
Provides integration with Cohereโs chat models through their Chat API with support for conversation history.
- class praval.providers.cohere.CohereProvider(config)[source]๏
Bases:
objectCohere provider for LLM interactions.
Handles communication with Cohereโs chat models through the Chat API with conversation history support.
- __init__(config)[source]๏
Initialize Cohere provider.
- Parameters:
config โ AgentConfig object with provider settings
- Raises:
ProviderError โ If Cohere client initialization fails
- generate(messages, tools=None)[source]๏
Generate a response using Cohereโs Chat API.
- Parameters:
- Return type:
- Returns:
Generated response as a string
- Raises:
ProviderError โ If API call fails