@@ -15,15 +15,6 @@ class Audit(StreamMixin):
1515
1616 Attributes:
1717 None
18-
19- Example usage:
20- audit = Audit()
21- audit.push_usage_data(
22- token_counter,
23- workflow_id,
24- execution_id,
25- external_service,
26- event_type)
2718 """
2819
2920 def __init__ (self , log_level : LogLevel = LogLevel .INFO ) -> None :
@@ -33,23 +24,28 @@ def push_usage_data(
3324 self ,
3425 platform_api_key : str ,
3526 token_counter : TokenCountingHandler = None ,
36- workflow_id : str = "" ,
37- execution_id : str = "" ,
38- external_service : str = "" ,
27+ model_name : str = "" ,
3928 event_type : CBEventType = None ,
29+ ** kwargs ,
4030 ) -> None :
4131 """Pushes the usage data to the platform service.
4232
4333 Args:
34+ platform_api_key (str): The platform API key.
4435 token_counter (TokenCountingHandler, optional): The token counter
45- object. Defaults to None.
46- workflow_id (str, optional): The ID of the workflow. Defaults to "".
47- execution_id (str, optional): The ID of the execution. Defaults
48- to "".
49- external_service (str, optional): The name of the external service.
50- Defaults to "".
36+ object. Defaults to None.
37+ model_name (str, optional): The name of the model.
38+ Defaults to "".
5139 event_type (CBEventType, optional): The type of the event. Defaults
52- to None.
40+ to None.
41+ **kwargs: Optional keyword arguments.
42+ workflow_id (str, optional): The ID of the workflow.
43+ Defaults to "".
44+ execution_id (str, optional): The ID of the execution. Defaults
45+ to "".
46+ adapter_instance_id (str, optional): The adapter instance ID.
47+ Defaults to "".
48+ run_id (str, optional): The run ID. Defaults to "".
5349
5450 Returns:
5551 None
@@ -66,11 +62,18 @@ def push_usage_data(
6662 )
6763 bearer_token = platform_api_key
6864
65+ workflow_id = kwargs .get ("workflow_id" , "" )
66+ execution_id = kwargs .get ("execution_id" , "" )
67+ adapter_instance_id = kwargs .get ("adapter_instance_id" , "" )
68+ run_id = kwargs .get ("run_id" , "" )
69+
6970 data = {
70- "usage_type" : event_type ,
71- "external_service" : external_service ,
7271 "workflow_id" : workflow_id ,
7372 "execution_id" : execution_id ,
73+ "adapter_instance_id" : adapter_instance_id ,
74+ "run_id" : run_id ,
75+ "usage_type" : event_type ,
76+ "model_name" : model_name ,
7477 "embedding_tokens" : token_counter .total_embedding_token_count ,
7578 "prompt_tokens" : token_counter .prompt_llm_token_count ,
7679 "completion_tokens" : token_counter .completion_llm_token_count ,
@@ -100,3 +103,6 @@ def push_usage_data(
100103 log = f"Error while pushing usage details: { e } " ,
101104 level = LogLevel .ERROR ,
102105 )
106+
107+ finally :
108+ token_counter .reset_counts ()
0 commit comments