Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
spring-ai-startermodule: thin adapter layer over the SB4 starter thatexposes 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 satisfiesStreamingChatModel) — maps Prompt/ChatOptionsonto 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, joinsmulti-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, infersContent-Type from filename extension, always requests text format.
FanarSpringAiAutoConfigurationregisters all four as @ConditionalOnMissingBeanso 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:
Fanar returns continuous safety + culturalAwareness scores). Would always
return Categories.isHate()=false etc., misleading consumers.
RAG users bring their own EmbeddingModel from spring-ai-openai, etc.
Type of change
Test plan
mvn verifypasses locallyFANAR_API_KEYset)--self-testpasses (if the SDK's reflective surface changed)