Skip to content

Commit afe726e

Browse files
committed
backend unit tests fixed according to new ragas generation config
1 parent 6003298 commit afe726e

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

backend/tests/unit/backend/qa_catalog/logic/test_generation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def catalog_generator_config(
8787
type=generator_type,
8888
sample_count=10,
8989
knowledge_graph_location=None,
90-
query_distribution={
91-
RagasQACatalogQuerySynthesizer.SINGLE_HOP_SPECIFIC: 1.0,
92-
},
90+
query_distribution=[
91+
RagasQACatalogQuerySynthesizer.SINGLE_HOP_SPECIFIC,
92+
],
9393
personas=[
9494
RagasQACatalogGeneratorPersona(
9595
name="test-persona", description="test description"

backend/tests/unit/backend/qa_catalog/test_router.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ async def test_generate(
300300
"type": "RAGAS",
301301
"knowledge_graph_location": "/tmp/somefile.pdf",
302302
"sample_count": 5,
303-
"query_distribution": {
304-
"SINGLE_HOP_SPECIFIC": 1.5,
305-
},
303+
"query_distribution": [
304+
"SINGLE_HOP_SPECIFIC",
305+
],
306306
"personas": [
307307
{"name": "person1", "description": "Beschreibung Persona 1"}
308308
],

backend/tests/unit/qa_catalog/generator/implementation/ragas/test_generator.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def config() -> RagasQACatalogGeneratorConfig:
3030
type="RAGAS",
3131
knowledge_graph_location=None,
3232
sample_count=10,
33-
query_distribution={
34-
RagasQACatalogQuerySynthesizer.SINGLE_HOP_SPECIFIC: 0.5,
35-
RagasQACatalogQuerySynthesizer.MULTI_HOP_SPECIFIC: 0.3,
36-
RagasQACatalogQuerySynthesizer.MULTI_HOP_ABSTRACT: 0.2,
37-
},
33+
query_distribution=[
34+
RagasQACatalogQuerySynthesizer.SINGLE_HOP_SPECIFIC,
35+
RagasQACatalogQuerySynthesizer.MULTI_HOP_SPECIFIC,
36+
RagasQACatalogQuerySynthesizer.MULTI_HOP_ABSTRACT,
37+
],
3838
personas=None,
3939
)
4040

@@ -173,25 +173,17 @@ async def test_ragas_generator__load_and_process_documents_correctly(
173173

174174

175175
@pytest.mark.asyncio
176-
@pytest.mark.parametrize("weights", [[0.5, 0.3, 0.0], [0.5, 1, 0.2]])
177176
@patch(
178177
"llm_eval.qa_catalog.generator.implementation.ragas.generator.RagasQACatalogGenerator.load_chat_model"
179178
)
180-
async def test_init_ragas_generator_fails_for_invalid_query_synthesizer(
179+
async def test_init_ragas_generator_fails_for_empty_query_distribution(
181180
_: MagicMock,
182181
config: RagasQACatalogGeneratorConfig,
183182
data_source_config: QACatalogGeneratorDataSourceConfig,
184183
ragas_model_config: RagasQACatalogGeneratorModelConfig,
185-
weights: list[float],
186184
) -> None:
187-
invalid_query_synthesizer: dict = {
188-
RagasQACatalogQuerySynthesizer.SINGLE_HOP_SPECIFIC: weights[0],
189-
RagasQACatalogQuerySynthesizer.MULTI_HOP_ABSTRACT: weights[1],
190-
RagasQACatalogQuerySynthesizer.MULTI_HOP_SPECIFIC: weights[2],
191-
}
192-
193-
with pytest.raises(ValueError, match="distribution weights should sum up to 1"):
194-
config.query_distribution = invalid_query_synthesizer
185+
with pytest.raises(ValueError, match="At least one query synthesizer"):
186+
config.query_distribution = []
195187
RagasQACatalogGenerator(config, data_source_config, ragas_model_config)
196188

197189

0 commit comments

Comments
 (0)