spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/index.html
Apache License 2.0
2.89k stars 721 forks source link

Reconsider the Type float/Float in the API #712

Closed ullenboom closed 1 day ago

ullenboom commented 4 months ago

A floating-point number with limited precision is commonly used in AI. However, using float or Float as a data type in the API might be impractical, and it could be worth reevaluating this decision.

For instance, your own example in the reference documentation (https://docs.spring.io/spring-ai/reference/api/clients/ollama-chat.html) results in a compiler error, guess why :)

ChatResponse response = chatClient.call(
    new Prompt(
        "Generate the names of 5 famous pirates.",
        OllamaOptions.create()
            .withModel("llama2")
            .withTemperature(0.4)
    ));
ThomasVitale commented 1 month ago

It would be nice to use Double instead of Float in all the ModelOptions implementations. It would make the API more convenient to work with and the code more readable.

markpollack commented 1 month ago

I agree, thanks for raising the issue. I will aim to fix this for the M2 release that is coming up shortly.

csterwa commented 1 week ago

@markpollack should this be moved to next milestone or release candidate?

ThomasVitale commented 1 week ago

I'm available to submit a PR on this. I had already done some preliminary analysis when working on the observability features. I should have the PR ready by the end of this week.

ThomasVitale commented 1 week ago

The PR is ready for review: https://github.com/spring-projects/spring-ai/pull/1325