mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-08 08:11:07 -10:00
* fix(examples): resolve syntax errors and align with consolidated-params API * fix: correct TypeError in 3 example files by using proper parameter names - Fix MemoryConfig(memory=...) → user_id=... in agent_centric_api.py - Fix Session(memory=...) → user_id=... in session-example.py - Fix build_context_for_task(memory=...) → user_id=... in memory-quality-example.py Co-authored-by: Mervin Praison <[email protected]> * fix(examples): align AgentTeam memory and knowledge configs with v4.6.52 API * fix(examples): phase-3 API alignment for consolidated params on v4.6.52 * fix(examples): phase-4 API alignment for 40 validation failures on v4.6.52 * fix: resolve critical RouterAgent **kwargs bug and add missing if __name__ guards - Fixed TypeError in RouterAgent._build_system_prompt() by removing **kwargs from super() call - Added if __name__ == '__main__' guards to 6 example files to prevent auto-execution on import - Addresses Gemini Code Assist review feedback Co-authored-by: Mervin Praison <[email protected]> * fix: resolve missing AgentTeam import and RouterAgent kwargs forwarding - Fix missing AgentTeam import in self-reflection-optimization-patterns.py - Forward kwargs properly in RouterAgent._build_system_prompt to super() - Addresses critical issues identified by Gemini code reviewer Co-authored-by: Mervin Praison <[email protected]> * fix(examples): remove merge-conflict residue for PR #1893 --------- Co-authored-by: Dhivya-Bharathy <[email protected]> Co-authored-by: praisonai-triage-agent[bot] <272766704+praisonai-triage-agent[bot]@users.noreply.github.com> Co-authored-by: Mervin Praison <[email protected]> Co-authored-by: Mervin Praison <[email protected]>
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
"""
|
|
Advanced Memory Search and Optimization Example
|
|
|
|
This example demonstrates memory search optimization using PraisonAI's
|
|
built-in memory capabilities with semantic search and quality filtering.
|
|
"""
|
|
|
|
from praisonaiagents import Agent, Task, AgentTeam
|
|
from praisonaiagents.tools import internet_search
|
|
|
|
print("=== Advanced Memory Search and Optimization Example ===\n")
|
|
|
|
# Configure optimized memory settings
|
|
memory_config = {
|
|
"config": {
|
|
"provider": "mem0",
|
|
"vector_store": {
|
|
"provider": "chroma",
|
|
"config": {
|
|
"path": ".praison/optimized_memory"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
# Create research agent with optimized memory
|
|
research_agent = Agent(
|
|
name="Memory Research Agent",
|
|
role="Information Researcher with Memory Optimization",
|
|
goal="Research and demonstrate optimized memory search patterns",
|
|
backstory="Expert at storing and retrieving information efficiently with memory optimization",
|
|
tools=[internet_search],
|
|
memory=True)
|
|
|
|
# Task to build searchable memory
|
|
build_memory_task = Task(
|
|
description="""Research and store information about these topics for later search:
|
|
1. Artificial intelligence market trends and growth data
|
|
2. Machine learning technologies and applications
|
|
3. Tech industry partnerships and investments
|
|
4. Cloud computing adoption statistics
|
|
|
|
Store detailed information that can be searched later.""",
|
|
expected_output="Comprehensive research stored in optimized memory",
|
|
agent=research_agent
|
|
)
|
|
|
|
# Task to demonstrate memory search optimization
|
|
search_task = Task(
|
|
description="""Using the stored memory, perform optimized searches for:
|
|
1. "AI market growth trends" - find relevant stored information
|
|
2. "technology partnerships" - retrieve partnership data
|
|
3. "cloud adoption statistics" - search for cloud computing info
|
|
|
|
Demonstrate efficient memory retrieval and search optimization.""",
|
|
expected_output="Results from optimized memory searches",
|
|
agent=research_agent
|
|
)
|
|
|
|
# Run with memory optimization
|
|
agents_system = AgentTeam(
|
|
agents=[research_agent],
|
|
tasks=[build_memory_task, search_task],
|
|
memory=memory_config,
|
|
output="verbose",
|
|
)
|
|
|
|
print("Starting memory search optimization demonstration...")
|
|
result = agents_system.start()
|
|
|
|
print(f"\nMemory Search Result: {result[:200]}...")
|
|
print("\n✅ Memory search optimization complete!")
|
|
print("Agent demonstrated efficient memory storage and optimized search retrieval.") |