Skip to content

Commit 7ee6156

Browse files
requested fixes
1 parent a4d0d8a commit 7ee6156

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

toolium/utils/ai_utils/text_analysis.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ def get_text_criteria_analysis(text_input, text_criteria, model_name=None, azure
7878
7979
:param text_input: text to analyze
8080
:param text_criteria: list of target characteristics to evaluate
81-
:param extra_tasks: additional system messages for extra analysis sections (optional)
82-
:param model_name: name of the Azure OpenAI model to use
81+
:param model_name: name of the OpenAI model to use
8382
:param azure: whether to use Azure OpenAI or standard OpenAI
84-
:param kwargs: additional parameters to be used by Azure OpenAI client
85-
:returns: response from Azure OpenAI
83+
:param kwargs: additional parameters to be used by OpenAI client
84+
:returns: response from OpenAI
8685
"""
8786
# Build prompt using base prompt and target features
8887
system_message = build_system_message(text_criteria)
@@ -96,15 +95,20 @@ def assert_text_criteria(text_input, text_criteria, threshold, model_name=None,
9695
:param text_input: text to analyze
9796
:param text_criteria: list of target characteristics to evaluate
9897
:param threshold: minimum overall match score to consider the text acceptable
99-
:param model_name: name of the Azure OpenAI model to use
98+
:param model_name: name of the OpenAI model to use
10099
:param azure: whether to use Azure OpenAI or standard OpenAI
101-
:param kwargs: additional parameters to be used by Azure OpenAI client
100+
:param kwargs: additional parameters to be used by OpenAI client
102101
:raises AssertionError: if overall match score is below threshold
103102
"""
104103
analysis = json.loads(get_text_criteria_analysis(text_input, text_criteria, model_name, azure, **kwargs))
105104
overall_match = analysis.get("overall_match", 0.0)
106105
if overall_match < threshold:
106+
logger.error(f"Text criteria analysis failed: overall match {overall_match} "
107+
f"is below threshold {threshold}\n"
108+
f"Failed features: {analysis.get('features', [])}")
107109
raise AssertionError(f"Text criteria analysis failed: overall match {overall_match} "
108-
f"is below threshold {threshold}")
110+
f"is below threshold {threshold}\n"
111+
f"Failed features: {analysis.get('features', [])}")
109112
logger.info(f"Text criteria analysis passed: overall match {overall_match} "
110-
f"is above threshold {threshold}")
113+
f"is above threshold {threshold}."
114+
f"Low scored features: {analysis.get('features', [])}")

0 commit comments

Comments
 (0)