@@ -632,6 +632,50 @@ pub fn transform_string(
632632}
633633}
634634
635+ #[ cfg( all( feature ="python" , not( feature ="use_as_lib" ) ) ) ]
636+ #[ pg_extern( immutable, parallel_safe, name ="transform" ) ]
637+ #[ allow( unused_variables) ] // cache is maintained for api compatibility
638+ pub fn transform_conversational_json (
639+ task : JsonB ,
640+ args : default ! ( JsonB , "'{}'" ) ,
641+ inputs : default ! ( Vec <JsonB >, "ARRAY[]::JSONB[]" ) ,
642+ cache : default ! ( bool , false ) ,
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 transform should only be used with a conversational task"
650+ ) ;
651+ }
652+ match crate :: bindings:: transformers:: transform ( & task. 0 , & args. 0 , inputs) {
653+ Ok ( output) =>JsonB ( output) ,
654+ Err ( e) =>error ! ( "{e}" ) ,
655+ }
656+ }
657+
658+ #[ cfg( all( feature ="python" , not( feature ="use_as_lib" ) ) ) ]
659+ #[ pg_extern( immutable, parallel_safe, name ="transform" ) ]
660+ #[ allow( unused_variables) ] // cache is maintained for api compatibility
661+ pub fn transform_conversational_string (
662+ task : String ,
663+ args : default ! ( JsonB , "'{}'" ) ,
664+ inputs : default ! ( Vec <JsonB >, "ARRAY[]::JSONB[]" ) ,
665+ cache : default ! ( bool , false ) ,
666+ ) ->JsonB {
667+ if task !="conversational" {
668+ error ! (
669+ "ARRAY[]::JSONB inputs for transform should only be used with a conversational task"
670+ ) ;
671+ }
672+ let task_json =json ! ( { "task" : task} ) ;
673+ match crate :: bindings:: transformers:: transform ( & task_json, & args. 0 , inputs) {
674+ Ok ( output) =>JsonB ( output) ,
675+ Err ( e) =>error ! ( "{e}" ) ,
676+ }
677+ }
678+
635679#[ cfg( all( feature ="python" , not( feature ="use_as_lib" ) ) ) ]
636680#[ pg_extern( immutable, parallel_safe, name ="transform_stream" ) ]
637681#[ allow( unused_variables) ] // cache is maintained for api compatibility
@@ -640,7 +684,7 @@ pub fn transform_stream_json(
640684args : default ! ( JsonB , "'{}'" ) ,
641685input : default ! ( & str , "''" ) ,
642686cache : default ! ( bool , false ) ,
643- ) ->SetOfIterator < ' static , String > {
687+ ) ->SetOfIterator < ' static , JsonB > {
644688// We can unwrap this becuase if there is an error the current transaction is aborted in the map_err call
645689let python_iter =
646690crate :: bindings:: transformers:: transform_stream_iterator ( & task. 0 , & args. 0 , input)
@@ -657,7 +701,7 @@ pub fn transform_stream_string(
657701args : default ! ( JsonB , "'{}'" ) ,
658702input : default ! ( & str , "''" ) ,
659703cache : default ! ( bool , false ) ,
660- ) ->SetOfIterator < ' static , String > {
704+ ) ->SetOfIterator < ' static , JsonB > {
661705let task_json =json ! ( { "task" : task} ) ;
662706// We can unwrap this becuase if there is an error the current transaction is aborted in the map_err call
663707let python_iter =
@@ -667,6 +711,54 @@ pub fn transform_stream_string(
667711SetOfIterator :: new ( python_iter)
668712}
669713
714+ #[ cfg( all( feature ="python" , not( feature ="use_as_lib" ) ) ) ]
715+ #[ pg_extern( immutable, parallel_safe, name ="transform_stream" ) ]
716+ #[ allow( unused_variables) ] // cache is maintained for api compatibility
717+ pub fn transform_stream_conversational_json (
718+ task : JsonB ,
719+ args : default ! ( JsonB , "'{}'" ) ,
720+ inputs : default ! ( Vec <JsonB >, "ARRAY[]::JSONB[]" ) ,
721+ cache : default ! ( bool , false ) ,
722+ ) ->SetOfIterator < ' static , JsonB > {
723+ if !task. 0 [ "task" ]
724+ . as_str ( )
725+ . is_some_and ( |v| v =="conversational" )
726+ {
727+ error ! (
728+ "ARRAY[]::JSONB inputs for transform_stream should only be used with a conversational task"
729+ ) ;
730+ }
731+ // We can unwrap this becuase if there is an error the current transaction is aborted in the map_err call
732+ let python_iter =
733+ crate :: bindings:: transformers:: transform_stream_iterator ( & task. 0 , & args. 0 , inputs)
734+ . map_err ( |e|error ! ( "{e}" ) )
735+ . unwrap ( ) ;
736+ SetOfIterator :: new ( python_iter)
737+ }
738+
739+ #[ cfg( all( feature ="python" , not( feature ="use_as_lib" ) ) ) ]
740+ #[ pg_extern( immutable, parallel_safe, name ="transform_stream" ) ]
741+ #[ allow( unused_variables) ] // cache is maintained for api compatibility
742+ pub fn transform_stream_conversational_string (
743+ task : String ,
744+ args : default ! ( JsonB , "'{}'" ) ,
745+ inputs : default ! ( Vec <JsonB >, "ARRAY[]::JSONB[]" ) ,
746+ cache : default ! ( bool , false ) ,
747+ ) ->SetOfIterator < ' static , JsonB > {
748+ if task !="conversational" {
749+ error ! (
750+ "ARRAY::JSONB inputs for transform_stream should only be used with a conversational task"
751+ ) ;
752+ }
753+ let task_json =json ! ( { "task" : task} ) ;
754+ // We can unwrap this becuase if there is an error the current transaction is aborted in the map_err call
755+ let python_iter =
756+ crate :: bindings:: transformers:: transform_stream_iterator ( & task_json, & args. 0 , inputs)
757+ . map_err ( |e|error ! ( "{e}" ) )
758+ . unwrap ( ) ;
759+ SetOfIterator :: new ( python_iter)
760+ }
761+
670762#[ cfg( feature ="python" ) ]
671763#[ pg_extern( immutable, parallel_safe, name ="generate" ) ]
672764fn generate ( project_name : & str , inputs : & str , config : default ! ( JsonB , "'{}'" ) ) ->String {