Zhuoxi2000 opened a new issue, #1395:
URL: https://github.com/apache/flink-agents/issues/1395

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/issues) and found nothing 
similar.
   
   ### Description
   
   A Java function tool with a nullable parameter cannot be used with the Java 
Ollama chat model.
   
   `FunctionSchema` writes `@ToolParam(nullable = true)` as `"type": [<type>, 
"null"]` 
(plan/src/main/java/org/apache/flink/agents/plan/tools/FunctionSchema.java:186).
 `OllamaChatModelConnection.convertToOllamaTools` reads every property's `type` 
as a `String` 
(integrations/chat-models/ollama/src/main/java/org/apache/flink/agents/integrations/chatmodels/ollama/OllamaChatModelConnection.java:158).
   
   Expected: the tool converts, with the parameter sent as its non-null type.
   Actual: every chat call with that tool fails with `RuntimeException: 
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class 
java.lang.String`.
   
   The Python Ollama connection passes the schema through and is not affected.
   
   ### How to reproduce
   
   In `OllamaChatModelConnectionTest`, convert a tool whose schema is:
   
   ```json
   
{"type":"object","properties":{"city":{"type":["string","null"]}},"required":["city"]}
   ```
   
   `connection().convertToOllamaTools(List.of(new SchemaOnlyTool(schema)))` 
throws the `ClassCastException` above.
   
   ### Version and environment
   
   main at 5b0b5531, Java 17, macOS.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!
   


-- 
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]

Reply via email to