mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 12:47:55 -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]>
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
"""
|
|
Production Telemetry Example
|
|
|
|
Demonstrates compatible telemetry setup with `enable_telemetry()` and
|
|
`TelemetryCollector` patterns.
|
|
"""
|
|
|
|
from contextlib import nullcontext
|
|
from praisonaiagents import Agent, Task, AgentTeam
|
|
from praisonaiagents.tools import duckduckgo
|
|
from praisonaiagents.telemetry import enable_telemetry, TelemetryCollector
|
|
|
|
|
|
def main() -> None:
|
|
print("=" * 80)
|
|
print("PRODUCTION TELEMETRY SETUP")
|
|
print("=" * 80)
|
|
|
|
# New API: no args
|
|
enable_telemetry()
|
|
collector = TelemetryCollector()
|
|
|
|
customer_service_agent = Agent(
|
|
name="CustomerServiceAgent",
|
|
role="Customer Service Representative",
|
|
goal="Provide excellent customer service with fast response times",
|
|
backstory="Customer service expert focused on quick issue resolution.",
|
|
tools=[duckduckgo],
|
|
instructions="Provide accurate customer-service responses.",
|
|
)
|
|
|
|
requests = [
|
|
"Customer asking about monthly bill charges",
|
|
"Customer experiencing connectivity issues",
|
|
]
|
|
|
|
for idx, description in enumerate(requests, start=1):
|
|
trace_ctx = getattr(collector, "trace", None)
|
|
trace_cm = trace_ctx(f"customer_request_{idx}") if callable(trace_ctx) else nullcontext()
|
|
with trace_cm:
|
|
task = Task(
|
|
name=f"customer_request_{idx}",
|
|
description=description,
|
|
expected_output="Professional customer service response with solution",
|
|
agent=customer_service_agent,
|
|
)
|
|
agents = AgentTeam(agents=[customer_service_agent], tasks=[task], output="minimal")
|
|
result = agents.start()
|
|
print(f"✅ Request {idx} completed, response length={len(str(result))}")
|
|
|
|
print("\nTelemetry demonstration completed.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |