2626 Field = None
2727
2828from toolium .driver_wrappers_pool import DriverWrappersPool
29+ from toolium .test .utils .ai_utils .common import (
30+ configure_default_openai_model , # noqa: F401, fixture needed to set the OpenAI model for all tests in this module
31+ )
2932from toolium .utils .ai_utils .evaluate_answer import assert_answer_evaluation , get_answer_evaluation_with_azure_openai
3033
3134test_data_get = [
6871 test_data_get ,
6972)
7073def test_get_answer_evaluation_no_format_with_azure_openai (llm_answer , reference_answer , question ):
71- model = 'gpt4o'
7274 similarity , response = get_answer_evaluation_with_azure_openai (
73- llm_answer = llm_answer , reference_answer = reference_answer , question = question , model_name = model
75+ llm_answer = llm_answer , reference_answer = reference_answer , question = question
7476 )
7577 assert isinstance (similarity , float ), 'Similarity should be a float'
7678 assert isinstance (response ['explanation' ], str ), 'Explanation should be a string'
@@ -90,12 +92,10 @@ class SimilarityEvaluation(BaseModel):
9092 similarity : float = Field (description = 'Similarity score between 0.0 and 1.0' , ge = 0.0 , le = 1.0 )
9193 explanation : str = Field (description = 'Brief justification for the similarity score' )
9294
93- model = 'gpt4o'
9495 similarity , response = get_answer_evaluation_with_azure_openai (
9596 llm_answer = llm_answer ,
9697 reference_answer = reference_answer ,
9798 question = question ,
98- model_name = model ,
9999 response_format = SimilarityEvaluation ,
100100 )
101101 assert isinstance (similarity , float ), 'Similarity should be a float'
@@ -133,12 +133,10 @@ class AnswerEval(BaseModel):
133133 'Only answer 5 if the answer is completely relevant to the question and gives no additional information.'
134134 )
135135
136- model = 'gpt4o'
137136 similarity , response = get_answer_evaluation_with_azure_openai (
138137 llm_answer = llm_answer ,
139138 reference_answer = reference_answer ,
140139 question = question ,
141- model_name = model ,
142140 response_format = AnswerEval ,
143141 )
144142 assert isinstance (similarity , float ), 'Similarity should be a float'
@@ -178,12 +176,10 @@ class AnswerEval(BaseModel):
178176 'Only answer 5 if the answer is completely relevant to the question and gives no additional information.'
179177 )
180178
181- model = 'gpt4o'
182179 similarity , response = get_answer_evaluation_with_azure_openai (
183180 llm_answer = llm_answer ,
184181 reference_answer = reference_answer ,
185182 question = question ,
186- model_name = model ,
187183 response_format = AnswerEval ,
188184 )
189185 assert isinstance (similarity , float ), 'Similarity should be a float'
@@ -197,13 +193,11 @@ class AnswerEval(BaseModel):
197193 test_data_assert ,
198194)
199195def test_assert_answer_with_azure_openai (llm_answer , reference_answer , question , expected_low ):
200- model = 'gpt4o'
201- provider = 'azure_openai'
196+ provider = 'azure'
202197 assert_answer_evaluation (
203198 llm_answer = llm_answer ,
204199 reference_answers = reference_answer ,
205200 question = question ,
206- model_name = model ,
207201 threshold = expected_low ,
208202 provider = provider ,
209203 )
@@ -221,11 +215,9 @@ def test_assert_answer_from_config(llm_answer, reference_answer, question, expec
221215 except Exception :
222216 pass
223217 config .set ('AI' , 'provider' , 'azure' )
224- model = 'gpt4o'
225218 assert_answer_evaluation (
226219 llm_answer = llm_answer ,
227220 reference_answers = reference_answer ,
228221 question = question ,
229- model_name = model ,
230222 threshold = expected_low ,
231223 )
0 commit comments