Skip to content

Request to Make ChatOptions Runtime-Validated Instead of Required at Startup #3404

Open
@FFatTiger

Description

@FFatTiger

Expected Behavior

I would like to be able to dynamically configure ChatModel's Options, including the apiKey, at runtime during SpringAI's startup, without requiring these options to be initialized at startup.

Current Behavior

Currently, SpringAI initializes all imported spring-ai-starter-model-xxx at startup, which requires providing Options (like the apiKey) in the configuration. Sometimes our requirements are dynamic, and the model configurations might come from other sources (like a database). In such cases, I have to manually construct all the necessary ChatModels one by one, which involves a considerable amount of effort. Therefore, I wonder if there is a way to make ChatOptions runtime-validated instead of being required at startup. It feels somewhat unreasonable to have an invalid apiKey configured in the yml file and then override it at runtime.

Context

I have reviewed the official documentation, but I couldn’t find a suitable solution for my needs. I acknowledge that I may have a misunderstanding, and I would greatly appreciate any suggestions or guidance you might have.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions