Skip to content

Proposal: Add standalone Function Calling sample using ChatClient Fluent API #94

@hasiniran

Description

@hasiniran

Description

I would like to contribute a new sample module to models/chat that demonstrates AI Function Calling (Tools) using the modern ChatClient Fluent API.

While there are functional tests for this feature, a dedicated, beginner-friendly sample would help developers understand how to bridge existing Java services with LLMs.

Proposed Implementation

The sample will include:

  1. Tool Definition: A simple @bean function (e.g., a Weather or Stock price mock) using the 'Function' interface.
  2. ChatClient Integration: Demonstrating how to register the function using .functions("functionName") within the fluent API.
  3. Observability: Integration of SimpleLoggerAdvisor to show the underlying "Tool Call" interaction in the console logs—essential for debugging agentic behavior.
  4. Local-First: Configuration optimized for Ollama (llama3.2) to ensure users can run it without requiring external API keys.

Why this is valuable

Function calling is a core "Agentic" feature of Spring AI. This sample provides a clear "Hello World" for connecting LLMs to external Java logic, which is a primary use case for enterprise developers.

I would love to submit a PR if the maintainers find this valuable!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions