Skip to content

Commit 610b92e

Browse files
committed
adding suffix to decorator
1 parent 38b2c0b commit 610b92e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/agentlab/llm/tracking.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from functools import cache
21
import os
32
import threading
43
from contextlib import contextmanager
4+
from functools import cache
55

66
import requests
77
from langchain_community.callbacks.openai_info import MODEL_COST_PER_1K_TOKENS
@@ -52,11 +52,12 @@ def set_tracker():
5252
TRACKER.instance = previous_tracker
5353

5454

55-
def cost_tracker_decorator(get_action):
55+
def cost_tracker_decorator(get_action, suffix=""):
5656
def wrapper(self, obs):
5757
with set_tracker() as tracker:
5858
action, agent_info = get_action(self, obs)
59-
agent_info.get("stats").update(tracker.stats)
59+
stats = {k + "_" + suffix: v for k, v in tracker.stats.items()}
60+
agent_info.get("stats").update(stats)
6061
return action, agent_info
6162

6263
return wrapper

0 commit comments

Comments
 (0)