Commit bcedafc 1 parent 653fb9c commit bcedafc Copy full SHA for bcedafc
File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,12 @@ impl Client for OllamaClient {
196
196
197
197
if let Some ( args) = call. function . arguments . as_ref ( ) {
198
198
for ( name, value) in args {
199
- let str_val = value. to_string ( ) . trim_matches ( '"' ) . to_string ( ) ;
199
+ let mut content = value. to_string ( ) ;
200
+ if let serde_json:: Value :: String ( escaped_json) = & value {
201
+ content = escaped_json. to_string ( ) ;
202
+ }
203
+
204
+ let str_val = content. trim_matches ( '"' ) . to_string ( ) ;
200
205
if name == "payload" {
201
206
payload = Some ( str_val) ;
202
207
} else {
Original file line number Diff line number Diff line change @@ -207,11 +207,16 @@ impl Action for AppendToFile {
207
207
208
208
let content_to_append = if extension == "json" || extension == "jsonl" {
209
209
// parse the payload as a JSON object
210
- if let Ok ( value) = serde_json:: from_str :: < serde_json:: Value > ( & payload) {
210
+ let parsed = serde_json:: from_str :: < serde_json:: Value > ( & payload) ;
211
+ if let Ok ( value) = parsed {
211
212
// reconvert to make sure it's on a single line
212
213
serde_json:: to_string ( & value) . unwrap ( )
213
214
} else {
214
- log:: error!( "can't parse payload as JSON: {}" , payload) ;
215
+ log:: error!(
216
+ "can't parse payload as JSON: {} - {}" ,
217
+ parsed. err( ) . unwrap( ) ,
218
+ payload
219
+ ) ;
215
220
serde_json:: to_string ( & InvalidJSON { data : payload } ) . unwrap ( )
216
221
}
217
222
} else {
You can’t perform that action at this time.
0 commit comments