Skip to content

Commit 0638e8d

Browse files
committed
graceful handling of tools_sse_urls
1 parent 37c952c commit 0638e8d

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/llm.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,21 @@ impl TryFrom<Vec<u8>> for LlmOptions {
197197
// Extract system_message
198198
let system_message = json["system_message"].as_str().map(|s| s.to_string());
199199

200-
// Extract tools_sse_urls
201-
let tools_sse_urls = json["tools_sse_urls"]
202-
.as_str()
203-
.map(|s| s.split(',').map(|s| s.trim().to_string()).collect());
200+
// Extract tools_sse_urls - can be an array or a comma-separated string
201+
let tools_sse_urls = if json["tools_sse_urls"].is_array() {
202+
// Handle array format - native runtime
203+
Some(
204+
json["tools_sse_urls"]
205+
.members()
206+
.filter_map(|v| v.as_str().map(|s| s.to_string()))
207+
.collect(),
208+
)
209+
} else if let Some(s) = json["tools_sse_urls"].as_str() {
210+
// Handle comma-separated string format - Browser runtime
211+
Some(s.split(',').map(|s| s.trim().to_string()).collect())
212+
} else {
213+
None
214+
};
204215

205216
Ok(LlmOptions {
206217
system_message: system_message,

0 commit comments

Comments
 (0)