1818 EvaluatorStats ,
1919)
2020from langfuse .experiment import Evaluation
21- from tests .support .utils import create_uuid
21+ from tests .support .utils import create_uuid , get_api , wait_for_result
2222
2323# ============================================================================
2424# FIXTURES & SETUP
@@ -40,6 +40,40 @@ def sample_trace_name():
4040 return f"batch-eval-test-{ create_uuid ()} "
4141
4242
43+ def _seed_trace_corpus (
44+ * , trace_count : int = 6 , tag : str | None = None
45+ ) -> tuple [str , list [str ]]:
46+ langfuse_client = get_client ()
47+ corpus_tag = tag or f"batch-eval-seed-{ create_uuid ()} "
48+ trace_names : list [str ] = []
49+
50+ for index in range (trace_count ):
51+ trace_name = f"{ corpus_tag } -trace-{ index } "
52+ trace_names .append (trace_name )
53+ with langfuse_client .start_as_current_observation (name = trace_name ) as span :
54+ with propagate_attributes (tags = [corpus_tag ]):
55+ span .set_trace_io (
56+ input = f"Seed input { index } " ,
57+ output = f"Seed output { index } " ,
58+ )
59+
60+ langfuse_client .flush ()
61+
62+ filter_json = f'[{{"type": "arrayOptions", "column": "tags", "operator": "any of", "value": ["{ corpus_tag } "]}}]'
63+ api = get_api (retry = False )
64+ wait_for_result (
65+ lambda : api .trace .list (filter = filter_json , limit = trace_count ),
66+ is_result_ready = lambda response : len (response .data ) >= trace_count ,
67+ )
68+
69+ return corpus_tag , trace_names
70+
71+
72+ @pytest .fixture (scope = "module" , autouse = True )
73+ def seeded_batch_evaluation_traces ():
74+ _seed_trace_corpus ()
75+
76+
4377def simple_trace_mapper (* , item ):
4478 """Simple mapper for traces."""
4579 return EvaluatorInputs (
0 commit comments