File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1- from functools import cache
21import os
32import threading
43from contextlib import contextmanager
4+ from functools import cache
55
66import requests
77from 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
You can’t perform that action at this time.
0 commit comments