File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed
src/ragas/testset/synthesizers/multi_hop Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ class MultiHopAbstractQuerySynthesizer(MultiHopQuerySynthesizer):
42
42
def get_node_clusters (self , knowledge_graph : KnowledgeGraph ) -> t .List [t .Set [Node ]]:
43
43
"""Identify clusters of nodes based on the specified relationship condition."""
44
44
node_clusters = knowledge_graph .find_indirect_clusters (
45
- relationship_condition = lambda rel : bool (rel .get_property (self .relation_property )),
45
+ relationship_condition = lambda rel : bool (
46
+ rel .get_property (self .relation_property )
47
+ ),
46
48
depth_limit = 3 ,
47
49
)
48
50
logger .info ("found %d clusters" , len (node_clusters ))
@@ -89,7 +91,9 @@ async def _generate_scenarios(
89
91
nodes .append (node )
90
92
91
93
base_scenarios = []
92
- node_themes = [node .properties .get (self .abstract_property_name , []) for node in nodes ]
94
+ node_themes = [
95
+ node .properties .get (self .abstract_property_name , []) for node in nodes
96
+ ]
93
97
prompt_input = ConceptsList (
94
98
lists_of_concepts = node_themes , max_combinations = num_sample_per_cluster
95
99
)
Original file line number Diff line number Diff line change 2
2
3
3
import logging
4
4
import typing as t
5
+ from collections .abc import Iterable
5
6
from dataclasses import dataclass
6
7
7
8
import numpy as np
@@ -81,7 +82,16 @@ async def _generate_scenarios(
81
82
overlapped_items = []
82
83
overlapped_items = triplet [1 ].properties [self .relation_overlap_property ]
83
84
if overlapped_items :
84
- themes = list (dict (overlapped_items ).keys ())
85
+ if not all (
86
+ isinstance (item , (str , Iterable )) for item in overlapped_items
87
+ ):
88
+ logger .debug ("Overlapped items are not strings or iterables." )
89
+ continue
90
+ themes = (
91
+ list (overlapped_items .keys ())
92
+ if isinstance (overlapped_items , dict )
93
+ else overlapped_items
94
+ )
85
95
prompt_input = ThemesPersonasInput (
86
96
themes = themes , personas = persona_list
87
97
)
@@ -90,10 +100,13 @@ async def _generate_scenarios(
90
100
data = prompt_input , llm = self .llm , callbacks = callbacks
91
101
)
92
102
)
93
- overlapped_items = [list (item ) for item in overlapped_items ]
103
+ combinations = [
104
+ [item ] if isinstance (item , str ) else list (item )
105
+ for item in themes
106
+ ]
94
107
base_scenarios = self .prepare_combinations (
95
108
[node_a , node_b ],
96
- overlapped_items ,
109
+ combinations ,
97
110
personas = persona_list ,
98
111
persona_item_mapping = persona_concepts .mapping ,
99
112
property_name = self .property_name ,
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ def test_testset_generation_tracking(monkeypatch):
135
135
)
136
136
137
137
assert testset_event_payload .model_dump ()["evolution_names" ] == [
138
- "single_hop_specifc_query_synthesizer " ,
138
+ "single_hop_specific_query_synthesizer " ,
139
139
"multi_hop_abstract_query_synthesizer" ,
140
140
"multi_hop_specific_query_synthesizer" ,
141
141
]
You can’t perform that action at this time.
0 commit comments