Skip to content

Commit 10befa2

Browse files
committed
Add a global on_ai_call to ai_statisitcs.py
1 parent 4133f23 commit 10befa2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

aikido_zen/storage/ai_statistics.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import copy
22

3+
from aikido_zen.thread.thread_cache import get_cache
4+
35

46
class AIStatistics:
57
def __init__(self):
@@ -44,3 +46,9 @@ def empty(self):
4446

4547
def get_provider_key(provider, model):
4648
return f"{provider}:{model}"
49+
50+
51+
def on_ai_call(provider, model, input_tokens, output_tokens):
52+
cache = get_cache()
53+
if cache:
54+
cache.ai_stats.on_ai_call(provider, model, input_tokens, output_tokens)

0 commit comments

Comments
 (0)