11import base64
22import json
3- import logging
43import time
54from dataclasses import dataclass
65from enum import Enum
76from typing import Any , Callable , Dict , Iterable , List , Optional
87
98from ldclient import Context , LDClient
109
11- logger = logging . getLogger ( __name__ )
10+ from ldai import log
1211
1312
1413class FeedbackKind (Enum ):
@@ -201,7 +200,7 @@ def track_duration(self, duration: int) -> None:
201200 :param duration: Duration in milliseconds.
202201 """
203202 if self ._summary .duration is not None :
204- logger .warning ("Duration has already been tracked for this execution. %s" , self .__get_track_data ())
203+ log .warning ("Duration has already been tracked for this execution. %s" , self .__get_track_data ())
205204 return
206205 self ._summary ._duration = duration
207206 self ._ld_client .track (
@@ -215,7 +214,7 @@ def track_time_to_first_token(self, time_to_first_token: int) -> None:
215214 :param time_to_first_token: Time to first token in milliseconds.
216215 """
217216 if self ._summary .time_to_first_token is not None :
218- logger .warning (
217+ log .warning (
219218 "Time to first token has already been tracked for this execution. %s" ,
220219 self .__get_track_data (),
221220 )
@@ -346,7 +345,7 @@ def track_feedback(self, feedback: Dict[str, FeedbackKind]) -> None:
346345 :param feedback: Dictionary containing feedback kind.
347346 """
348347 if self ._summary .feedback is not None :
349- logger .warning ("Feedback has already been tracked for this execution. %s" , self .__get_track_data ())
348+ log .warning ("Feedback has already been tracked for this execution. %s" , self .__get_track_data ())
350349 return
351350 self ._summary ._feedback = feedback
352351 if feedback ["kind" ] == FeedbackKind .Positive :
@@ -369,7 +368,7 @@ def track_success(self) -> None:
369368 Track a successful AI generation.
370369 """
371370 if self ._summary .success is not None :
372- logger .warning ("Success has already been tracked for this execution. %s" , self .__get_track_data ())
371+ log .warning ("Success has already been tracked for this execution. %s" , self .__get_track_data ())
373372 return
374373 self ._summary ._success = True
375374 self ._ld_client .track (
@@ -381,7 +380,7 @@ def track_error(self) -> None:
381380 Track an unsuccessful AI generation attempt.
382381 """
383382 if self ._summary .success is not None :
384- logger .warning ("Success has already been tracked for this execution. %s" , self .__get_track_data ())
383+ log .warning ("Success has already been tracked for this execution. %s" , self .__get_track_data ())
385384 return
386385 self ._summary ._success = False
387386 self ._ld_client .track (
@@ -450,7 +449,7 @@ def track_tokens(self, tokens: TokenUsage) -> None:
450449 :param tokens: Token usage data from either custom, OpenAI, or Bedrock sources.
451450 """
452451 if self ._summary .usage is not None :
453- logger .warning ("Tokens have already been tracked for this execution. %s" , self .__get_track_data ())
452+ log .warning ("Tokens have already been tracked for this execution. %s" , self .__get_track_data ())
454453 return
455454 self ._summary ._usage = tokens
456455 td = self .__get_track_data ()
0 commit comments