You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug description
All of the Beans in the OpenAiAutoConfiguration class that require an API key have an option to disable the particular bean with the @ConditionalOnProperty with the exception of the OpenAiModerationModel. This has two potential issues:
Inconsistent AutoConfiguration pattern as all of the other Client or Model beans support an enabled property.
If I want to use constructs/classes in the OpenAI library but do not necessarily need a client connection (i.e. I don't need to set the apiKey), I cannot load my application without setting a bogus API key. The alternative is to disable AutoConfiguration for this class, but are scenarios where I still may want to auto configure a particular client.
Environment
Spring Boot 3.4.x and spring-ai M6.
Steps to reproduce
Set the enabled flag for all models and client to false and do not set an apiKey (do not disable auto configuration). The application will crash with the following error:
OpenAI API key must be set. Use the connection property: spring.ai.openai.api-key or spring.ai.openai.moderation.api-key property
Expected behavior
I would expect there to be a consistent pattern for disabling the moderation client. Something like:
spring:
ai:
openai:
moderation:
enabled: false
Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.
Just create a trivial SpringBootApplication with the OpenAI starter. Use the following application.yaml.
Added the ability to disable auto configuration of the
OpenAiModerationModel bean. Addresses reported bug
[2373](spring-projects#2373)
Signed-off-by: Greg Meyer <[email protected]>
Bug description
All of the Beans in the
OpenAiAutoConfiguration
class that require an API key have an option to disable the particular bean with the@ConditionalOnProperty
with the exception of the OpenAiModerationModel. This has two potential issues:enabled
property.Environment
Spring Boot 3.4.x and spring-ai M6.
Steps to reproduce
Set the
enabled
flag for all models and client to false and do not set an apiKey (do not disable auto configuration). The application will crash with the following error:Expected behavior
I would expect there to be a consistent pattern for disabling the moderation client. Something like:
Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.
Just create a trivial SpringBootApplication with the OpenAI starter. Use the following application.yaml.
The text was updated successfully, but these errors were encountered: