@@ -7,9 +7,14 @@ use ::std::path::PathBuf;
77
88use minijinja:: value:: ValueKind ;
99use minijinja:: Environment ;
10- use ollama_rs:: generation:: chat:: { request:: ChatMessageRequest , ChatMessage , MessageRole } ;
11- use ollama_rs:: models:: ModelOptions ;
12- use ollama_rs:: Ollama ;
10+ use ollama_rs:: {
11+ generation:: {
12+ chat:: { request:: ChatMessageRequest , ChatMessage , MessageRole } ,
13+ tools:: ToolInfo ,
14+ } ,
15+ models:: ModelOptions ,
16+ Ollama ,
17+ } ;
1318use serde_json:: { from_str, to_string, Value } ;
1419use serde_norway:: from_reader;
1520use tokio:: runtime:: Runtime ;
@@ -98,7 +103,7 @@ impl<'a> Interpreter<'a> {
98103 fn to_ollama_model_options (
99104 & self ,
100105 maybe_parameters : & Option < HashMap < String , Value > > ,
101- ) -> ModelOptions {
106+ ) -> ( ModelOptions , Vec < ToolInfo > ) {
102107 let options = ModelOptions :: default ( ) ;
103108 if let Some ( parameters) = maybe_parameters {
104109 let temp = if let Some ( Value :: Number ( num) ) = parameters. get ( & "temperature" . to_string ( ) )
@@ -114,9 +119,17 @@ impl<'a> Interpreter<'a> {
114119 0.0
115120 } ;
116121
117- options. temperature ( temp)
122+ let tools = if let Some ( Value :: Array ( tools) ) = parameters. get ( & "tools" . to_string ( ) ) {
123+ // TODO
124+ //tools.into_iter().map(|tool| function!()).collect()
125+ vec ! [ ]
126+ } else {
127+ vec ! [ ]
128+ } ;
129+
130+ ( options. temperature ( temp) , tools)
118131 } else {
119- options
132+ ( options, vec ! [ ] )
120133 }
121134 }
122135
@@ -131,7 +144,8 @@ impl<'a> Interpreter<'a> {
131144 } else {
132145 & pdl_model[ 12 ..]
133146 } ;
134- let options = self . to_ollama_model_options ( & block. parameters ) ;
147+
148+ let ( options, tools) = self . to_ollama_model_options ( & block. parameters ) ;
135149
136150 let messages = match & block. input {
137151 Some ( input) => {
@@ -157,9 +171,13 @@ impl<'a> Interpreter<'a> {
157171 ) ;
158172 }
159173
174+ let req = ChatMessageRequest :: new ( model. into ( ) , vec ! [ prompt. clone( ) ] )
175+ . options ( options)
176+ . tools ( tools) ;
160177 let res = self . rt . block_on ( ollama. send_chat_messages_with_history (
161178 & mut history,
162- ChatMessageRequest :: new ( model. into ( ) , vec ! [ prompt. clone( ) ] ) . options ( options) , //ollama.generate(GenerationRequest::new(model.into(), prompt),
179+ req,
180+ //ollama.generate(GenerationRequest::new(model.into(), prompt),
163181 ) ) ?;
164182 // dbg!("Model result {:?}", &res);
165183
0 commit comments