[FEATURE] Support Configuration-Based Model Names in @AiService Annotations
- LangChain4j version: 1.0.0-beta2
- LLM(s) used: Gemma3
- Java version: 17
- Spring Boot version (if applicable): 3.4.3
Hello,
First of all, thank you for creating such an amazing project!
I am integrating langchain4j with Spring Boot and working with multiple models. Since the models change frequently, I have configured them in the application.yml file as shown below:
ai:
api:
modelA: gemma-3-27B:latest
modelB: QwQ-32B:latestHowever, I encountered an issue when using the @AiService annotation. Currently, the model specification requires a hard-coded plain text string and does not allow reading the model name from the configuration file. For example, the following approach does not work because it attempts to read the model name from the configuration:
@AiService(wiringMode = AiServiceWiringMode.EXPLICIT, chatModel = "${ai.api.modelA}")
public interface QwQ32BAssistant {
String chat(String text);
}Feature Request:
Could you please support this usage pattern, allowing the model name to be read from the configuration file? This would enable us to change models by simply updating the configuration file without modifying the codebase.
Expected Behavior:
The @AiService annotation should be able to resolve placeholders from the application.yml (or other configuration sources), enabling dynamic model configuration.
Current Behavior:
Model names must be specified as hard-coded strings within the @AiService annotation, preventing dynamic configuration.
Additional Context:
This feature would greatly enhance flexibility and maintainability, especially in environments where model updates are frequent.
Thank you for your attention to this matter. I look forward to your response!
Source: langchain4j/langchain4j