3
3
4
4
import pytest
5
5
6
+ from labelbox .schema .data_row_payload_templates import ModelEvaluationTemplate
7
+
6
8
7
9
@pytest .fixture
8
- def mmc_data_row (dataset , make_metadata_fields , embedding ):
9
- row_data = {
10
- "type" : "application/vnd.labelbox.conversational.model-chat-evaluation" ,
11
- "draft" : True ,
12
- "rootMessageIds" : ["root1" ],
13
- "actors" : {},
14
- "messages" : {},
15
- }
10
+ def mmc_data_row (dataset ):
11
+ data = ModelEvaluationTemplate ()
12
+
13
+ content_all = data .model_dump ()
14
+ task = dataset .create_data_rows ([content_all ])
15
+ task .wait_till_done ()
16
+ assert task .status == "COMPLETE"
17
+
18
+ data_row = list (dataset .data_rows ())[0 ]
19
+
20
+ yield data_row
21
+
22
+ data_row .delete ()
23
+
16
24
25
+ @pytest .fixture
26
+ def mmc_data_row_all (dataset , make_metadata_fields , embedding ):
27
+ data = ModelEvaluationTemplate ()
28
+ data .row_data .rootMessageIds = ["root1" ]
17
29
vector = [random .uniform (1.0 , 2.0 ) for _ in range (embedding .dims )]
18
- embeddings = [{"embedding_id" : embedding .id , "vector" : vector }]
30
+ data .embeddings = [{"embedding_id" : embedding .id , "vector" : vector }]
31
+ data .metadata_fields = make_metadata_fields
32
+ data .attachments = [{"type" : "RAW_TEXT" , "value" : "attachment value" }]
19
33
20
- content_all = {
21
- "row_data" : row_data ,
22
- "attachments" : [{"type" : "RAW_TEXT" , "value" : "attachment value" }],
23
- "metadata_fields" : make_metadata_fields ,
24
- "embeddings" : embeddings ,
25
- }
34
+ content_all = data .model_dump ()
26
35
task = dataset .create_data_rows ([content_all ])
27
36
task .wait_till_done ()
28
37
assert task .status == "COMPLETE"
@@ -34,14 +43,27 @@ def mmc_data_row(dataset, make_metadata_fields, embedding):
34
43
data_row .delete ()
35
44
36
45
37
- def test_mmc (mmc_data_row , embedding , constants ):
46
+ def test_mmc (mmc_data_row ):
38
47
data_row = mmc_data_row
48
+ assert json .loads (data_row .row_data ) == {
49
+ "type" : "application/vnd.labelbox.conversational.model-chat-evaluation" ,
50
+ "draft" : True ,
51
+ "rootMessageIds" : [],
52
+ "actors" : {},
53
+ "messages" : {},
54
+ "version" : 2 ,
55
+ }
56
+
57
+
58
+ def test_mmc_all (mmc_data_row_all , embedding , constants ):
59
+ data_row = mmc_data_row_all
39
60
assert json .loads (data_row .row_data ) == {
40
61
"type" : "application/vnd.labelbox.conversational.model-chat-evaluation" ,
41
62
"draft" : True ,
42
63
"rootMessageIds" : ["root1" ],
43
64
"actors" : {},
44
65
"messages" : {},
66
+ "version" : 2 ,
45
67
}
46
68
47
69
metadata_fields = data_row .metadata_fields
0 commit comments