1
+ import logging
2
+ from groq import Groq
3
+
1
4
class BaseMetric :
2
5
"""
3
6
The Base Metric class.
4
7
"""
5
- def __init__ (self , groq_client ):
8
+ def __init__ (self , groq_client : Groq , verbose : bool = None ):
6
9
self .groq_client = groq_client
10
+ self .logger = logging .getLogger (__name__ )
11
+ if verbose :
12
+ self .logger .setLevel (logging .INFO )
13
+
7
14
8
15
def groq_chat_completion (self , messages , model , temperature = 0.5 , response_format = None ):
9
16
"""
@@ -15,27 +22,27 @@ def groq_chat_completion(self, messages, model, temperature=0.5, response_format
15
22
temperature = temperature ,
16
23
response_format = response_format
17
24
)
18
- print (chat_completion .choices [0 ].message .content )
19
25
return chat_completion
20
26
21
27
def check_data_types (self , ** kwargs ):
22
28
"""
23
29
Checks for empty strings in the arguments
24
30
"""
25
31
for key , value in kwargs .items ():
26
- if key != "context" :
27
- if value == "" :
28
- raise ValueError (f"'{ key } ' cannot be an empty string." )
29
- if not isinstance (value , str ):
30
- raise TypeError (f"'{ key } ' must be a string" )
31
- else :
32
- if len (value ) == 0 :
33
- raise ValueError (f"'{ key } ' cannot be an empty list." )
34
- if not isinstance (value , list ):
35
- raise TypeError (f"'{ key } ' must be a list of strings" )
32
+ if key != "verbose" :
33
+ if key != "context" :
34
+ if value == "" :
35
+ raise ValueError (f"'{ key } ' cannot be an empty string." )
36
+ if not isinstance (value , str ):
37
+ raise TypeError (f"'{ key } ' must be a string" )
36
38
else :
37
- if not all (isinstance (item , str ) for item in value ):
38
- raise TypeError (f"All items in '{ key } ' must be strings" )
39
+ if len (value ) == 0 :
40
+ raise ValueError (f"'{ key } ' cannot be an empty list." )
41
+ if not isinstance (value , list ):
42
+ raise TypeError (f"'{ key } ' must be a list of strings" )
43
+ else :
44
+ if not all (isinstance (item , str ) for item in value ):
45
+ raise TypeError (f"All items in '{ key } ' must be strings" )
39
46
40
47
41
48
0 commit comments