mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 04:35:58 -10:00
* chore(benchmarks): date README perf claim, archive superseded results, fix benchmark scripts, re-measure (fixes #5824) - Re-measured on a quiet runner: Agent instantiation median 20.3us (1.6.60) -> 47.1us (main) on identical hardware; gradual creep, recorded in INSTANTIATION_RCA.md - performance_benchmark.py: lazy framework imports, rank-based 'fastest' label, ratios vs the fastest, min/median/std + versions + machine info, no README rewrite; BENCHMARK_RESULTS.md regenerated in one run - simple_benchmark.py: --save writes SIMPLE_BENCHMARK_RESULTS.md; README updater removed - Archive superseded result files with a 'Superseded' header - benchmark.yml: PR gate via simple_benchmark --json --fail-over-threshold; parse failures now fail instead of passing as 0; threshold 450 -> 150us - Delete dead nested src/praisonai-agents/.github workflow - README: dated 46us figure linking BENCHMARK_RESULTS.md Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(benchmarks): link follow-up issue #5835 in RCA Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): absolute README link, validate --iterations/--warmup, accurate reproduce command Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: MervinPraison <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
73 lines
2.3 KiB
Python
73 lines
2.3 KiB
Python
"""
|
|
Fast Context - Basic Example
|
|
|
|
FastContext provides rapid code search capabilities.
|
|
Use it directly from the context module for code search.
|
|
|
|
FastContext provides:
|
|
- Parallel execution (8 concurrent searches)
|
|
- Automatic caching for repeated queries
|
|
|
|
Note: FastContext is now accessed via the context module directly,
|
|
not as Agent parameters. For context management with agents,
|
|
use Agent(context=True) or Agent(context=ManagerConfig(...)).
|
|
"""
|
|
|
|
from praisonaiagents import Agent
|
|
from praisonaiagents.context import ManagerConfig
|
|
|
|
def main():
|
|
print("=" * 60)
|
|
print("Agent with Context Management - Basic Example")
|
|
print("=" * 60)
|
|
|
|
# Create an agent with context management enabled
|
|
# This is the recommended way to use context features
|
|
agent = Agent(
|
|
name="CodeAssistant",
|
|
instructions="You are a helpful code assistant.",
|
|
context=True, # Enable context management with defaults
|
|
)
|
|
|
|
print("\n✓ Agent created with context management enabled")
|
|
print(f" - context_manager: {agent.context_manager is not None}")
|
|
if agent.context_manager:
|
|
print(f" - auto_compact: {agent.context_manager.config.auto_compact}")
|
|
print(f" - strategy: {agent.context_manager.config.strategy}")
|
|
|
|
# For FastContext code search, use the module directly
|
|
print("\n" + "-" * 60)
|
|
print("Using FastContext for code search...")
|
|
print("-" * 60)
|
|
|
|
try:
|
|
from praisonaiagents.context.fast import FastContext
|
|
|
|
fc = FastContext(
|
|
workspace_path=".",
|
|
model="gpt-4o-mini",
|
|
max_turns=4,
|
|
max_parallel=8,
|
|
)
|
|
|
|
result = fc.search("class Agent")
|
|
print(f"\n✓ Search for 'class Agent':")
|
|
print(f" Files found: {result.total_files}")
|
|
print(f" Search time: {result.search_time_ms}ms")
|
|
|
|
if result.total_files > 0:
|
|
context = fc.get_context_for_agent("class Agent")
|
|
print(f" Context length: {len(context)} characters")
|
|
except ImportError:
|
|
print("\n⚠ FastContext not available (optional feature)")
|
|
except Exception as e:
|
|
print(f"\n⚠ FastContext search failed: {e}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("Context management is now unified via context= param!")
|
|
print("=" * 60)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|