@@ -641,6 +641,14 @@ pub fn transform_conversational_json(
641
641
inputs : default ! ( Vec <JsonB >, "ARRAY[]::JSONB[]" ) ,
642
642
cache : default ! ( bool , false ) ,
643
643
) -> JsonB {
644
+ if !task. 0 [ "task" ]
645
+ . as_str ( )
646
+ . is_some_and ( |v| v == "conversational" )
647
+ {
648
+ error ! (
649
+ "ARRAY[]::JSONB inputs for transformer should only be used with a conversational task"
650
+ ) ;
651
+ }
644
652
match crate :: bindings:: transformers:: transform ( & task. 0 , & args. 0 , inputs) {
645
653
Ok ( output) => JsonB ( output) ,
646
654
Err ( e) => error ! ( "{e}" ) ,
@@ -656,6 +664,11 @@ pub fn transform_conversational_string(
656
664
inputs : default ! ( Vec <JsonB >, "ARRAY[]::JSONB[]" ) ,
657
665
cache : default ! ( bool , false ) ,
658
666
) -> JsonB {
667
+ if task != "conversational" {
668
+ error ! (
669
+ "ARRAY[]::JSONB inputs for transformer should only be used with a conversational task"
670
+ ) ;
671
+ }
659
672
let task_json = json ! ( { "task" : task } ) ;
660
673
match crate :: bindings:: transformers:: transform ( & task_json, & args. 0 , inputs) {
661
674
Ok ( output) => JsonB ( output) ,
@@ -710,12 +723,13 @@ pub fn transform_stream_conversational_json(
710
723
input : default ! ( JsonB , "'[]'::JSONB" ) ,
711
724
cache : default ! ( bool , false ) ,
712
725
) -> SetOfIterator < ' static , String > {
713
- // If they have Vec<JsonB> inputs lets make sure they have the write task
714
726
if !task. 0 [ "task" ]
715
727
. as_str ( )
716
728
. is_some_and ( |v| v == "conversational" )
717
729
{
718
- error ! ( "ARRAY[]::JSONB inputs for transformer_stream should only be used with a conversational task" ) ;
730
+ error ! (
731
+ "JSONB inputs for transformer_stream should only be used with a conversational task"
732
+ ) ;
719
733
}
720
734
// We can unwrap this becuase if there is an error the current transaction is aborted in the map_err call
721
735
let python_iter =
@@ -735,7 +749,9 @@ pub fn transform_stream_conversational_string(
735
749
cache : default ! ( bool , false ) ,
736
750
) -> SetOfIterator < ' static , String > {
737
751
if task != "conversational" {
738
- error ! ( "ARRAY[]::JSONB inputs for transformer_stream should only be used with a conversational task" ) ;
752
+ error ! (
753
+ "JSONB inputs for transformer_stream should only be used with a conversational task"
754
+ ) ;
739
755
}
740
756
let task_json = json ! ( { "task" : task } ) ;
741
757
// We can unwrap this becuase if there is an error the current transaction is aborted in the map_err call
0 commit comments