@@ -342,32 +342,39 @@ def _upload_invalid_data_rows_for_dataset(dataset: Dataset):
342
342
343
343
return _upload_invalid_data_rows_for_dataset
344
344
345
+
345
346
@pytest .fixture
346
- def prompt_response_generation_project_with_new_dataset (client : Client , rand_gen , request ):
347
+ def prompt_response_generation_project_with_new_dataset (client : Client ,
348
+ rand_gen , request ):
347
349
"""fixture is parametrize and needs project_type in request"""
348
350
media_type = request .param
349
- prompt_response_project = client .create_prompt_response_generation_project (name = f"{ media_type .value } -{ rand_gen (str )} " ,
350
- dataset_name = f"{ media_type .value } -{ rand_gen (str )} " ,
351
- data_row_count = 1 ,
352
- media_type = media_type )
353
-
351
+ prompt_response_project = client .create_prompt_response_generation_project (
352
+ name = f"{ media_type .value } -{ rand_gen (str )} " ,
353
+ dataset_name = f"{ media_type .value } -{ rand_gen (str )} " ,
354
+ data_row_count = 1 ,
355
+ media_type = media_type )
356
+
354
357
yield prompt_response_project
355
-
358
+
356
359
prompt_response_project .delete ()
357
360
361
+
358
362
@pytest .fixture
359
- def prompt_response_generation_project_with_dataset_id (client : Client , dataset , rand_gen , request ):
363
+ def prompt_response_generation_project_with_dataset_id (client : Client , dataset ,
364
+ rand_gen , request ):
360
365
"""fixture is parametrized and needs project_type in request"""
361
366
media_type = request .param
362
- prompt_response_project = client .create_prompt_response_generation_project (name = f"{ media_type .value } -{ rand_gen (str )} " ,
363
- dataset_id = dataset .uid ,
364
- data_row_count = 1 ,
365
- media_type = media_type )
366
-
367
+ prompt_response_project = client .create_prompt_response_generation_project (
368
+ name = f"{ media_type .value } -{ rand_gen (str )} " ,
369
+ dataset_id = dataset .uid ,
370
+ data_row_count = 1 ,
371
+ media_type = media_type )
372
+
367
373
yield prompt_response_project
368
-
374
+
369
375
prompt_response_project .delete ()
370
376
377
+
371
378
@pytest .fixture
372
379
def response_creation_project (client : Client , rand_gen ):
373
380
project_name = f"response-creation-project-{ rand_gen (str )} "
@@ -377,87 +384,105 @@ def response_creation_project(client: Client, rand_gen):
377
384
378
385
project .delete ()
379
386
380
- @pytest .fixture
387
+
388
+ @pytest .fixture
381
389
def prompt_response_features (rand_gen ):
382
-
383
- prompt_text = PromptResponseClassification (class_type = PromptResponseClassification .Type .PROMPT ,
384
- name = f"{ rand_gen (str )} -prompt text" )
385
-
386
- response_radio = PromptResponseClassification (class_type = PromptResponseClassification .Type .RESPONSE_RADIO ,
387
- name = f"{ rand_gen (str )} -response radio classification" ,
388
- options = [
389
- ResponseOption (value = f"{ rand_gen (str )} -first radio option answer" ),
390
- ResponseOption (value = f"{ rand_gen (str )} -second radio option answer" ),
391
- ])
392
-
393
- response_checklist = PromptResponseClassification (class_type = PromptResponseClassification .Type .RESPONSE_CHECKLIST ,
394
- name = f"{ rand_gen (str )} -response checklist classification" ,
395
- options = [
396
- ResponseOption (value = f"{ rand_gen (str )} -first checklist option answer" ),
397
- ResponseOption (value = f"{ rand_gen (str )} -second checklist option answer" ),
398
- ])
399
-
400
- response_text_with_char = PromptResponseClassification (class_type = PromptResponseClassification .Type .RESPONSE_TEXT ,
401
- name = f"{ rand_gen (str )} -response text with character min and max" ,
402
- character_min = 1 ,
403
- character_max = 10 )
404
-
405
- response_text = PromptResponseClassification (class_type = PromptResponseClassification .Type .RESPONSE_TEXT ,
406
- name = f"{ rand_gen (str )} -response text" )
407
-
408
- nested_response_radio = PromptResponseClassification (class_type = PromptResponseClassification .Type .RESPONSE_RADIO ,
409
- name = f"{ rand_gen (str )} -nested response radio classification" ,
410
- options = [
411
- ResponseOption (f"{ rand_gen (str )} -first_radio_answer" ,
412
- options = [
413
- PromptResponseClassification (
414
- class_type = PromptResponseClassification .Type .RESPONSE_RADIO ,
415
- name = f"{ rand_gen (str )} -sub_radio_question" ,
416
- options = [ResponseOption (f"{ rand_gen (str )} -first_sub_radio_answer" )])
417
- ])
418
- ])
390
+
391
+ prompt_text = PromptResponseClassification (
392
+ class_type = PromptResponseClassification .Type .PROMPT ,
393
+ name = f"{ rand_gen (str )} -prompt text" )
394
+
395
+ response_radio = PromptResponseClassification (
396
+ class_type = PromptResponseClassification .Type .RESPONSE_RADIO ,
397
+ name = f"{ rand_gen (str )} -response radio classification" ,
398
+ options = [
399
+ ResponseOption (value = f"{ rand_gen (str )} -first radio option answer" ),
400
+ ResponseOption (value = f"{ rand_gen (str )} -second radio option answer" ),
401
+ ])
402
+
403
+ response_checklist = PromptResponseClassification (
404
+ class_type = PromptResponseClassification .Type .RESPONSE_CHECKLIST ,
405
+ name = f"{ rand_gen (str )} -response checklist classification" ,
406
+ options = [
407
+ ResponseOption (
408
+ value = f"{ rand_gen (str )} -first checklist option answer" ),
409
+ ResponseOption (
410
+ value = f"{ rand_gen (str )} -second checklist option answer" ),
411
+ ])
412
+
413
+ response_text_with_char = PromptResponseClassification (
414
+ class_type = PromptResponseClassification .Type .RESPONSE_TEXT ,
415
+ name = f"{ rand_gen (str )} -response text with character min and max" ,
416
+ character_min = 1 ,
417
+ character_max = 10 )
418
+
419
+ response_text = PromptResponseClassification (
420
+ class_type = PromptResponseClassification .Type .RESPONSE_TEXT ,
421
+ name = f"{ rand_gen (str )} -response text" )
422
+
423
+ nested_response_radio = PromptResponseClassification (
424
+ class_type = PromptResponseClassification .Type .RESPONSE_RADIO ,
425
+ name = f"{ rand_gen (str )} -nested response radio classification" ,
426
+ options = [
427
+ ResponseOption (
428
+ f"{ rand_gen (str )} -first_radio_answer" ,
429
+ options = [
430
+ PromptResponseClassification (
431
+ class_type = PromptResponseClassification .Type .
432
+ RESPONSE_RADIO ,
433
+ name = f"{ rand_gen (str )} -sub_radio_question" ,
434
+ options = [
435
+ ResponseOption (
436
+ f"{ rand_gen (str )} -first_sub_radio_answer" )
437
+ ])
438
+ ])
439
+ ])
419
440
yield {
420
441
"prompts" : [prompt_text ],
421
- "responses" : [response_text , response_radio , response_checklist , response_text_with_char , nested_response_radio ]
442
+ "responses" : [
443
+ response_text , response_radio , response_checklist ,
444
+ response_text_with_char , nested_response_radio
445
+ ]
422
446
}
423
447
448
+
424
449
@pytest .fixture
425
- def prompt_response_ontology (client : Client , rand_gen , prompt_response_features , request ):
450
+ def prompt_response_ontology (client : Client , rand_gen , prompt_response_features ,
451
+ request ):
426
452
"""fixture is parametrize and needs project_type in request"""
427
-
453
+
428
454
project_type = request .param
429
455
if project_type == MediaType .LLMPromptCreation :
430
456
ontology_builder = OntologyBuilder (
431
- tools = [],
432
- classifications = prompt_response_features ["prompts" ])
457
+ tools = [], classifications = prompt_response_features ["prompts" ])
433
458
elif project_type == MediaType .LLMPromptResponseCreation :
434
459
ontology_builder = OntologyBuilder (
435
460
tools = [],
436
- classifications = prompt_response_features ["prompts" ] + prompt_response_features ["responses" ])
461
+ classifications = prompt_response_features ["prompts" ] +
462
+ prompt_response_features ["responses" ])
437
463
else :
438
464
ontology_builder = OntologyBuilder (
439
- tools = [],
440
- classifications = prompt_response_features ["responses" ]
441
- )
442
-
465
+ tools = [], classifications = prompt_response_features ["responses" ])
466
+
443
467
ontology_name = f"prompt-response-{ rand_gen (str )} "
444
468
445
469
if project_type in MediaType :
446
- ontology = client .create_ontology (
447
- ontology_name ,
448
- ontology_builder .asdict (),
449
- media_type = project_type )
470
+ ontology = client .create_ontology (ontology_name ,
471
+ ontology_builder .asdict (),
472
+ media_type = project_type )
450
473
else :
451
474
ontology = client .create_ontology (
452
475
ontology_name ,
453
476
ontology_builder .asdict (),
454
477
media_type = MediaType .Text ,
455
- ontology_kind = OntologyKind .ResponseCreation
456
- )
478
+ ontology_kind = OntologyKind .ResponseCreation )
457
479
yield ontology
458
-
459
- featureSchemaIds = [feature ["featureSchemaId" ] for feature in ontology .normalized ["classifications" ]]
460
-
480
+
481
+ featureSchemaIds = [
482
+ feature ["featureSchemaId" ]
483
+ for feature in ontology .normalized ["classifications" ]
484
+ ]
485
+
461
486
try :
462
487
client .delete_unused_ontology (ontology .uid )
463
488
for featureSchemaId in featureSchemaIds :
@@ -466,6 +491,24 @@ def prompt_response_ontology(client: Client, rand_gen, prompt_response_features,
466
491
print (f"Failed to delete ontology { ontology .uid } : { str (e )} " )
467
492
468
493
494
+ @pytest .fixture
495
+ def point ():
496
+ return Tool (
497
+ tool = Tool .Type .POINT ,
498
+ name = "name" ,
499
+ color = "#ff0000" ,
500
+ )
501
+
502
+
503
+ @pytest .fixture
504
+ def feature_schema (client , point ):
505
+ created_feature_schema = client .upsert_feature_schema (point .asdict ())
506
+
507
+ yield created_feature_schema
508
+ client .delete_unused_feature_schema (
509
+ created_feature_schema .normalized ['featureSchemaId' ])
510
+
511
+
469
512
@pytest .fixture
470
513
def chat_evaluation_ontology (client , rand_gen ):
471
514
ontology_name = f"test-chat-evaluation-ontology-{ rand_gen (str )} "
@@ -682,13 +725,12 @@ def offline_conversational_data_row(initial_dataset):
682
725
683
726
return data_row
684
727
728
+
685
729
@pytest .fixture
686
730
def response_data_row (initial_dataset ):
687
- text_asset = {
688
- "row_data" : "response sample text"
689
- }
731
+ text_asset = {"row_data" : "response sample text" }
690
732
data_row = initial_dataset .create_data_row (text_asset )
691
-
733
+
692
734
return data_row
693
735
694
736
0 commit comments