Return OllamaResult from Message::tool_response instead of panicking
Replaced unwrap() with ? operator so serialization errors propagate as OllamaError::ResponseParseError instead of panicking. This is safer for a library API where callers should decide how to handle errors.
This commit is contained in:
@@ -74,7 +74,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let tool_call = &response.message.tool_calls[0];
|
||||
let arg: GetWeatherArgs = serde_json::from_value(tool_call.function.arguments.clone())?;
|
||||
let result = get_weather(&arg.city);
|
||||
messages.push(Message::tool_response(&result));
|
||||
messages.push(Message::tool_response(&result)?);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user