Repository navigation
feat(gpt): add multi-provider AI support for TinyMCE - #116
Open
sebastienheyd wants to merge 3 commits into
Open
sebastienheyd wants to merge 3 commits into
sebastienheyd wants to merge 3 commits into
Conversation
Refactor the hardcoded OpenAI integration into an extensible multi-provider
architecture supporting OpenAI, Anthropic Claude, Ollama, and custom providers.
- Add AiProvider abstract base class and AiProvidersRepository singleton
- Create OpenAiProvider, AnthropicProvider, OllamaProvider implementations
- Add AiStreamer service to normalize streaming responses across providers
- Update config/app.php with provider selection and per-provider settings
- Refactor GptController.stream() to delegate to AiStreamer
- Normalize SSE payload to {"content":"..."} for all providers
- Update TinyMCE view/composer to check for any configured provider
- Fix generator.js to parse normalized SSE format
- Maintain backward compatibility with legacy boilerplate.app.openai config
New config structure:
AI_PROVIDER=openai|anthropic|ollama|custom
OPENAI_API_KEY, OPENAI_MODEL, OPENAI_API_ORGANIZATION
ANTHROPIC_API_KEY, ANTHROPIC_MODEL
OLLAMA_ENDPOINT, OLLAMA_MODEL
Custom providers can be registered via:
app('boilerplate.ai.providers')->registerAiProvider(CustomProvider::class)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ddb014d44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Route registration was still checking boilerplate.app.openai.key while the view used hasConfiguredProvider(), causing a RouteNotFoundException when using Anthropic or Ollama without an OpenAI key configured. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This branch has not been deployed
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
Refactor the hardcoded OpenAI integration into an extensible multi-provider architecture supporting OpenAI, Anthropic Claude, Ollama, and custom providers.
AiProviderbase class withAiProvidersRepositorysingleton (follows existing pattern fromDashboardWidgetsRepository){"content":"..."}for frontend compatibilityAI_PROVIDER=openai|anthropic|ollamain.env, or register custom providersChanges
New files
src/Ai/AiProvider.php— abstract base classsrc/Ai/AiProvidersRepository.php— registry singletonsrc/Ai/AiStreamer.php— provider-agnostic cURL + SSE handlersrc/Ai/Providers/OpenAiProvider.php— with legacy config fallbacksrc/Ai/Providers/AnthropicProvider.php— Anthropic Claude supportsrc/Ai/Providers/OllamaProvider.php— Ollama local LLM supportModified files
src/config/app.php— newaisection with provider selection + per-provider configsrc/BoilerplateServiceProvider.php— registerboilerplate.ai.providerssingletonsrc/Controllers/GptController.php—stream()delegates toAiStreamer;sendRequest()removedsrc/View/Composers/TinymceLoadComposer.php— inject$aiEnabledvariablesrc/resources/views/load/tinymce.blade.php— use$aiEnabledinstead of OpenAI config checksrc/resources/assets/js/vendor/tinymce/plugins/gpt/generator.js— parse normalized SSE payloadConfiguration examples
Using default OpenAI (backward compatible):
Using Anthropic Claude:
Using Ollama (local):
Custom provider:
Test plan
OPENAI_API_KEYonly) — button visible, generation worksAI_PROVIDER=anthropicandANTHROPIC_API_KEYAI_PROVIDER=ollamaandOLLAMA_MODELset (no API key needed)