Skip to content

Commit 0d42787

Browse files
perf: eliminate redundant getattr calls in token metrics collection
- Remove duplicate llm variable definitions in aexecute_task and execute_task - Reuse existing llm variable instead of redefining with getattr calls - Reduces function call overhead without changing functionality - Addresses code duplication identified in PR review Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
1 parent 10e58e0 commit 0d42787

File tree

1 file changed

+0
-2
lines changed
  • src/praisonai-agents/praisonaiagents/agents

1 file changed

+0
-2
lines changed

src/praisonai-agents/praisonaiagents/agents/agents.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ def _get_multimodal_message(text_prompt, images):
414414
)
415415

416416
# Add token metrics if available
417-
llm = getattr(executor_agent, 'llm', None) or getattr(executor_agent, 'llm_instance', None)
418417
if llm and hasattr(llm, 'last_token_metrics'):
419418
token_metrics = llm.last_token_metrics
420419
if token_metrics:
@@ -774,7 +773,6 @@ def _get_multimodal_message(text_prompt, images):
774773
)
775774

776775
# Add token metrics if available
777-
llm = getattr(executor_agent, 'llm', None) or getattr(executor_agent, 'llm_instance', None)
778776
if llm and hasattr(llm, 'last_token_metrics'):
779777
token_metrics = llm.last_token_metrics
780778
if token_metrics:

0 commit comments

Comments
 (0)