@@ -827,12 +827,14 @@ impl<'a> Interpreter<'a> {
827827 eprintln ! ( "Model tools {:?} {:?}" , metadata. description, tools) ;
828828 }
829829
830+ let mut trace = block. clone ( ) ;
831+
830832 // The input messages to the model is either:
831833 // a) block.input, if given
832834 // b) the current state's accumulated messages
833835 let input_messages = match & block. input {
834836 Some ( input) => {
835- // TODO ignoring result, trace
837+ // TODO ignoring result and trace
836838 let ( _result, messages, _trace) = self . run_quiet ( & * input, state) . await ?;
837839 messages
838840 }
@@ -917,13 +919,28 @@ impl<'a> Interpreter<'a> {
917919 }
918920 }
919921
920- let mut trace = block. clone ( ) ;
922+ // TODO, does this belong in run_advanced(), and does
923+ // trace.context belong in Metadata rather than ModelBlock
924+ trace. context = Some (
925+ state
926+ . messages
927+ . iter ( )
928+ . map ( |m| MessageBlock {
929+ role : self . from_ollama_role ( & m. role ) ,
930+ content : Box :: new ( PdlBlock :: String ( m. content . clone ( ) ) ) ,
931+ name : None ,
932+ tool_call_id : None ,
933+ defsite : None ,
934+ } )
935+ . collect ( ) ,
936+ ) ;
937+ // TODO, what is the difference between context and pdl_model_input fields?
921938 trace. pdl_model_input = Some (
922939 input_messages
923- . into_iter ( )
940+ . iter ( )
924941 . map ( |m| MessageBlock {
925- role : self . from_ollama_role ( m. role ) ,
926- content : Box :: new ( PdlBlock :: String ( m. content ) ) ,
942+ role : self . from_ollama_role ( & m. role ) ,
943+ content : Box :: new ( PdlBlock :: String ( m. content . clone ( ) ) ) ,
927944 name : None ,
928945 tool_call_id : None ,
929946 defsite : None ,
@@ -1090,7 +1107,7 @@ impl<'a> Interpreter<'a> {
10901107 }
10911108 }
10921109
1093- fn from_ollama_role ( & self , role : MessageRole ) -> Role {
1110+ fn from_ollama_role ( & self , role : & MessageRole ) -> Role {
10941111 match role {
10951112 MessageRole :: User => Role :: User ,
10961113 MessageRole :: Assistant => Role :: Assistant ,
0 commit comments