Skip to content

Commit 012800a

Browse files
committed
Fixed Logs not Visible with Verbose == True
1 parent 3f740b6 commit 012800a

7 files changed

+21
-12
lines changed

groqeval/metrics/answer_relevance.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def output_decomposition(self):
7373
temperature=0,
7474
response_format={"type": "json_object"}
7575
)
76-
self.logger.info("Decomposition of the Output into Statements: %s", response.choices[0].message.content)
76+
self.logger.info("Decomposition of the Output into Statements: \n%s", response.choices[0].message.content)
7777
return Output.model_validate_json(response.choices[0].message.content)
7878

7979
@cached(cache=TTLCache(maxsize=100, ttl=300))
@@ -95,7 +95,7 @@ def score_relevance(self):
9595
temperature=0,
9696
response_format={"type": "json_object"}
9797
)
98-
self.logger.info("Breakdown of the Answer Relevance Score: %s", response.choices[0].message.content)
98+
self.logger.info("Breakdown of the Answer Relevance Score: \n%s", response.choices[0].message.content)
9999
return ScoredOutput.model_validate_json(response.choices[0].message.content), json.loads(response.choices[0].message.content)
100100

101101
@property

groqeval/metrics/base_metric.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ def __init__(self, groq_client: Groq, verbose: bool = None):
1111
self.groq_client = groq_client
1212
self.aggregation = statistics.mean
1313
self.logger = logging.getLogger(__name__)
14+
handler = logging.StreamHandler() # Stream handler to output to the console
15+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
16+
handler.setFormatter(formatter)
17+
self.logger.addHandler(handler)
18+
self.logger.propagate = False
19+
1420
if verbose:
15-
self.logger.setLevel(logging.INFO)
21+
self.logger.setLevel(logging.INFO) # Set to DEBUG to see all levels of logs
22+
self.logger.info("Verbose Mode is on.")
23+
else:
24+
self.logger.setLevel(logging.WARNING)
1625

1726
def groq_chat_completion(self, messages, model, temperature=0.5, response_format=None):
1827
"""

groqeval/metrics/bias.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def output_decomposition(self):
7979
temperature=0,
8080
response_format={"type": "json_object"}
8181
)
82-
self.logger.info("Decomposition of the Output into Opinions: %s", response.choices[0].message.content)
82+
self.logger.info("Decomposition of the Output into Opinions: \n%s", response.choices[0].message.content)
8383
return Output.model_validate_json(response.choices[0].message.content)
8484

8585
@cached(cache=TTLCache(maxsize=100, ttl=300))
@@ -101,7 +101,7 @@ def score_bias(self):
101101
temperature=0,
102102
response_format={"type": "json_object"}
103103
)
104-
self.logger.info("Breakdown of the Bias Score: %s", response.choices[0].message.content)
104+
self.logger.info("Breakdown of the Bias Score: \n%s", response.choices[0].message.content)
105105
return ScoredOutput.model_validate_json(response.choices[0].message.content), json.loads(response.choices[0].message.content)
106106

107107
@property

groqeval/metrics/context_relevance.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def context_decomposition(self):
8686
temperature=0,
8787
response_format={"type": "json_object"}
8888
)
89-
self.logger.info("Decomposition of the Context into Statements: %s", response.choices[0].message.content)
89+
self.logger.info("Decomposition of the Context into Statements: \n%s", response.choices[0].message.content)
9090
return Context.model_validate_json(response.choices[0].message.content)
9191

9292
@cached(cache=TTLCache(maxsize=100, ttl=300))
@@ -112,7 +112,7 @@ def score_relevance(self):
112112
temperature=0,
113113
response_format={"type": "json_object"}
114114
)
115-
self.logger.info("Breakdown of the Context Relevance Score: %s", response.choices[0].message.content)
115+
self.logger.info("Breakdown of the Context Relevance Score: \n%s", response.choices[0].message.content)
116116
return ScoredContext.model_validate_json(response.choices[0].message.content), json.loads(response.choices[0].message.content)
117117

118118
@property

groqeval/metrics/faithfulness.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def output_decomposition(self):
8787
temperature=0,
8888
response_format={"type": "json_object"}
8989
)
90-
self.logger.info("Decomposition of the Output into Claims: %s", response.choices[0].message.content)
90+
self.logger.info("Decomposition of the Output into Claims: \n%s", response.choices[0].message.content)
9191
return Output.model_validate_json(response.choices[0].message.content)
9292

9393
@cached(cache=TTLCache(maxsize=100, ttl=300))
@@ -114,7 +114,7 @@ def score_faithfulness(self):
114114
temperature=0,
115115
response_format={"type": "json_object"}
116116
)
117-
self.logger.info("Breakdown of the Faithfulness Score: %s", response.choices[0].message.content)
117+
self.logger.info("Breakdown of the Faithfulness Score: \n%s", response.choices[0].message.content)
118118
return ScoredOutput.model_validate_json(response.choices[0].message.content), json.loads(response.choices[0].message.content)
119119

120120
@property

groqeval/metrics/hallucination.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def context_decomposition(self):
9696
temperature=0,
9797
response_format={"type": "json_object"}
9898
)
99-
self.logger.info("Decomposition of the Context into Statements: %s", response.choices[0].message.content)
99+
self.logger.info("Decomposition of the Context into Statements: \n%s", response.choices[0].message.content)
100100
return Context.model_validate_json(response.choices[0].message.content)
101101

102102
@cached(cache=TTLCache(maxsize=100, ttl=300))
@@ -118,7 +118,7 @@ def score_hallucination(self):
118118
temperature=0,
119119
response_format={"type": "json_object"}
120120
)
121-
self.logger.info("Breakdown of the Hallucination Score: %s", response.choices[0].message.content)
121+
self.logger.info("Breakdown of the Hallucination Score: \n%s", response.choices[0].message.content)
122122
return ScoredContext.model_validate_json(response.choices[0].message.content), json.loads(response.choices[0].message.content)
123123

124124
@property

groqeval/metrics/toxicity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def output_decomposition(self):
7878
temperature=0,
7979
response_format={"type": "json_object"}
8080
)
81-
self.logger.info("Breakdown of the Toxicity Score: %s", response.choices[0].message.content)
81+
self.logger.info("Breakdown of the Toxicity Score: \n%s", response.choices[0].message.content)
8282
return Output.model_validate_json(response.choices[0].message.content)
8383

8484
@cached(cache=TTLCache(maxsize=100, ttl=300))

0 commit comments

Comments
 (0)