Traceback (most recent call last):
File "D:\python-agents-examples-main\windows_env\Lib\site-packages\opentelemetry\util\_decorator.py", line 71, in async_wrapper
return await func(*args, **kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python-agents-examples-main\windows_env\Lib\site-packages\livekit\agents\ipc\job_proc_lazy_main.py", line 240, in _traceable_entrypoint
await self._job_entrypoint_fnc(job_ctx)
File "D:\python-agents-examples-main\my_local_examples\agent.py", line 410, in entrypoint
agent = Assistant(),
^^^^^^^^^^^
File "D:\python-agents-examples-main\my_local_examples\agent.py", line 237, in init
self.llm.on("metrics_collected", sync_wrapper)
^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'on'
Getting this error for:
def sync_wrapper(metrics: LLMMetrics):
asyncio.create_task(self.on_metrics_collected(metrics))
self.llm.on("metrics_collected", sync_wrapper)
async def on_metrics_collected(self, metrics: LLMMetrics) -> None:
table = Table(
title="[bold blue]LLM Metrics Report[/bold blue]",
box=box.ROUNDED,
highlight=True,
show_header=True,
header_style="bold cyan"
)
table.add_column("Metric", style="bold green")
table.add_column("Value", style="yellow")
timestamp = datetime.fromtimestamp(metrics.timestamp).strftime('%Y-%m-%d %H:%M:%S')
table.add_row("Type", str(metrics.type))
table.add_row("Label", str(metrics.label))
table.add_row("Request ID", str(metrics.request_id))
table.add_row("Timestamp", timestamp)
table.add_row("Duration", f"[white]{metrics.duration:.4f}[/white]s")
table.add_row("Time to First Token", f"[white]{metrics.ttft:.4f}[/white]s")
table.add_row("Cancelled", "✓" if metrics.cancelled else "✗")
table.add_row("Completion Tokens", str(metrics.completion_tokens))
table.add_row("Prompt Tokens", str(metrics.prompt_tokens))
table.add_row("Total Tokens", str(metrics.total_tokens))
table.add_row("Tokens/Second", f"{metrics.tokens_per_second:.2f}")
console.print("\n")
console.print(table)
console.print("\n")