davsclaus commented on code in PR #27976:
URL: https://github.com/apache/camel/pull/27976#discussion_r4299489611
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/LlmClient.java:
##########
@@ -1711,11 +1734,17 @@ private ChatResponse parseOpenAiChatResponse(JsonObject
response) {
JsonObject function = (JsonObject) tc.get("function");
String id = tc.getString("id");
String name = function.getString("name");
+ // the arguments are JSON text, or an object with some
OpenAI-compatible servers (as with Ollama)
JsonObject args;
- try {
- args = (JsonObject)
Jsoner.deserialize(function.getString("arguments"));
- } catch (Exception e) {
- args = new JsonObject();
+ Object argsObj = function.get("arguments");
+ if (argsObj instanceof JsonObject jo) {
+ args = jo;
+ } else {
+ try {
+ args = (JsonObject) Jsoner.deserialize((String)
argsObj);
+ } catch (Exception e) {
+ args = new JsonObject();
+ }
}
Review Comment:
Done in 315e55e7b7bf: the three cases as in the Ollama parsers (an object,
text, or anything else gives no arguments), without the cast that relied on the
catch.
_Claude Code on behalf of davsclaus_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]