…ime unit is used while deserializing the duration values coming from Ollama.

Duration metrics are sent in nano seconds by Ollama, but interpreted as seconds by Spring AI. See issue #1796 for more details.

Comment From: markpollack

Thanks @jorander Were you planning to dig into this deeper?

Comment From: jorander

Hi @markpollack,

I've started working on a fix based on annotating attributed of type Duration with @JsonDeserialize and a custom deserializing-class handling the JSON INT as nanoseconds.

For symmetry I've thought about also adding @JsonSerialize that converts the Duration back to a JSON INT of nanoseconds, Event though it is not strictly necessary for the current use-case it will otherwise be surprising results for anyone attempting to serialize a OllamaApi.ChatResponse.

Finally, I'm also thinking that it might be a good thing to change the type of totalDuration and loadDuration in OllamaApi.EmbeddingsResponse from Long to Duration (and add the same serialization/deserialization) to make the two classes more similar.

If you agree on these, or part of them, I'll be happy to work on a PR including those changes.

Comment From: jorander

Added changes as outlined in comment above.

Note: For OllamaApi.EmbeddingsResponse this is an api-breaking change since datatypes for duration-attributes are changed from Long to Duration.

Comment From: jorander

Closing this PR since it is no longer needed. Issue #1796 is solved in https://github.com/spring-projects/spring-ai/commit/c4ca5826f79db851e466c9513818550cad64639e