Problem/Motivation
Currently, Mistral provider is implemented using the OpenAI SDK directly, with only minor variations.
This approach has led to significant code duplication (reused by other providers), especially evident when implementing new features like function calling. In such cases, nearly identical logic had to be added in multiple places, making the codebase harder to maintain, test, and evolve.
To address this, we already have an AiProviderClientBase class as a common foundation. The proposed direction is to introduce an OpenAiBasedProviderClientBase as an intermediate abstract layer that encapsulates shared OpenAI-specific logic (e.g., request formatting, operation types, basic behavior), reducing duplication and simplifying future enhancements.
Refactoring existing OpenAI-based clients to extend from this new base class will eliminate redundant code, improve maintainability, and align these implementations with the Drupal AI core module's architecture—paving the way for better standardisation and extensibility across AI providers.
Issue fork ai_provider_mistral-3532634
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
gxleano commentedComment #4
gxleano commentedComment #5
dan2k3k4 commentedWill take a look into this
Comment #6
dan2k3k4 commentedUnsure if this is because I'm testing with latest 1.2.x version of the AI module (SHA: 302ba82a8d89)
On route `/admin/config/ai/ai-external-moderation`
Also on the default settings route: `/admin/config/ai/settings` - I have no models listed for Mistral AI.
Comment #7
dan2k3k4 commentedI believe we need to push a 1.2.x branch and target 1.2.x of the AI module, same as the other provider modules
Comment #8
dan2k3k4 commentedWill re-test against recent changes
Comment #9
fagolet's pause this until we decided https://www.drupal.org/project/ai_provider_mistral/issues/3495572#commen... - if we switch the client we don't need to do this any more. 1.0.x I'd keep rather stable as is + focus on moving on with 1.1x
Comment #10
marcus_johansson commentedDecision was taken on #3532634: Remove OpenAI SDK dependency and extend it from Drupal AI core module, so we will close this. Thank you for the efforts!
Comment #12
dan2k3k4 commented