File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
pdl-live-react/src-tauri/src/pdl Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -931,6 +931,22 @@ impl<'a> Interpreter<'a> {
931931 // The input messages to the model is either:
932932 // a) block.input, if given
933933 // b) the current state's accumulated messages
934+ if let Some ( c) = & block. context {
935+ state. scope . insert (
936+ "pdl_context" . to_string ( ) ,
937+ PdlResult :: List (
938+ c. iter ( )
939+ . map ( |m| {
940+ PdlResult :: Block ( PdlBlock :: Advanced ( Block {
941+ metadata : None ,
942+ body : Body :: Message ( m. clone ( ) ) ,
943+ } ) )
944+ } )
945+ . collect ( ) ,
946+ ) ,
947+ ) ;
948+ }
949+
934950 let input_messages = match & block. input {
935951 Some ( input) => {
936952 // TODO ignoring result and trace
@@ -1027,7 +1043,23 @@ impl<'a> Interpreter<'a> {
10271043 true ,
10281044 ) ?;
10291045 trace. data = from_str ( to_string ( & result) ?. as_str ( ) ) ?;
1030- Ok ( ( result, vec ! [ ] , Data ( trace) ) )
1046+ let messages = match & trace. data {
1047+ Value :: Object ( m) => match m. get ( "pdl__result" ) {
1048+ Some ( Value :: Array ( a) ) => a
1049+ . iter ( )
1050+ . filter_map ( |m| match m {
1051+ Value :: Object ( d) => match d. get ( "content" ) {
1052+ Some ( Value :: String ( s) ) => Some ( ChatMessage :: user ( s. clone ( ) ) ) ,
1053+ _ => None ,
1054+ } ,
1055+ _ => None ,
1056+ } )
1057+ . collect ( ) ,
1058+ _ => vec ! [ ] ,
1059+ } ,
1060+ _ => vec ! [ ] ,
1061+ } ;
1062+ Ok ( ( result, messages, Data ( trace) ) )
10311063 }
10321064 }
10331065
You can’t perform that action at this time.
0 commit comments