Skip to content

feat : Spring AI 2.0 starter — chat, image, audio adapters#27

Merged
omahjoub merged 3 commits intomainfrom
spring-ai
Apr 28, 2026
Merged

feat : Spring AI 2.0 starter — chat, image, audio adapters#27
omahjoub merged 3 commits intomainfrom
spring-ai

Conversation

@omahjoub
Copy link
Copy Markdown
Owner

Summary

Adds spring-ai-starter module: thin adapter layer over the SB4 starter that
exposes the FanarClient as Spring AI's typed model SPIs. One dep, four beans —
applications use Spring AI's ChatClient, advisors, prompt templates, and reactive
streaming without touching the Fanar SDK directly.

Adapters:

  • FanarChatModel (also satisfies StreamingChatModel) — maps Prompt/ChatOptions
    onto ChatRequest, bridges Flow.Publisher to Flux,
    silently drops TOOL messages and ProgressChunk/ToolCallChunk/ToolResultChunk
    (Fanar rejects user tools server-side).
  • FanarImageModel — maps ImagePrompt onto ImageGenerationRequest, joins
    multi-message prompts with newlines, returns b64Json.
  • FanarTextToSpeechModel (+ StreamingTextToSpeechModel) — Fanar TTS is one-shot;
    stream() wraps the call() result as a single-element Flux for API symmetry.
  • FanarTranscriptionModel — reads bytes from Spring's Resource, infers
    Content-Type from filename extension, always requests text format.

FanarSpringAiAutoConfiguration registers all four as @ConditionalOnMissingBean
so users can override per slot. Activates only when both Spring AI and a
FanarClient bean are present.

Build wiring: pin spring-ai.version=2.0.0-M4 (aligned with SB4 / Spring 7),
import spring-ai-bom, add spring-milestones repo at parent level scoped to
milestones-only via releases.enabled=false.

Deferred:

  • ModerationModel — shape mismatch (Spring AI expects 16-category booleans;
    Fanar returns continuous safety + culturalAwareness scores). Would always
    return Categories.isHate()=false etc., misleading consumers.
  • EmbeddingModel — no Fanar embeddings endpoint exists. Documented gap;
    RAG users bring their own EmbeddingModel from spring-ai-openai, etc.

Type of change

  • Bug fix
  • New feature / capability
  • New module
  • Refactoring (no behavior change)
  • Breaking change
  • Documentation / tooling / CI only

Test plan

  • mvn verify passes locally
  • Live tests pass against the real Fanar API (if applicable, with FANAR_API_KEY set)
  • GraalVM --self-test passes (if the SDK's reflective surface changed)

@omahjoub omahjoub merged commit d324f7a into main Apr 28, 2026
5 checks passed
@omahjoub omahjoub deleted the spring-ai branch April 28, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant