Improve Configuration Usage Experience
Currently, we have implemented a configuration based on Pydantic. However, we read the configuration through Flask.config or environment variables, which prevents us from utilizing Pydantic’s type system.
I have the following refactoring plan:
- Create a singleton
DifyConfig - Use this singleton to replace all logic that currently retrieves values from
current_app.configand environment variables - Modify any existing mock cases that might be affected
Since this refactoring involves a lot of code, we hope to complete it in multiple stages. If you're interested in helping us with this task, please leave a message here.🙏
Refactoring isn't too difficult, and even those who are not yet familiar with Dify can join in. If you're unsure about how to proceed, you can refer to #6025 and #5938.
Don't be shy, come and get involved!
Current progress
- [x]
api/core/extension#6025 - [x]
api/core/model_runtime#6025 - [x]
api/models#6394 - [x]
api/core/workflow#6394 - [x]
api/core/tools#6394 - [x]
api/core/rag#6410 - [ ]
api/core/file- @VickyGuo0907 - [ ]
api/core/moderation- @VickyGuo0907 - [ ]
api/core/app- @VickyGuo0907 - [x]
api/controllers/console#6485 - [x]
api/controllers/inner_api#6237 - [x]
api/controllers/service_api#6237 - [x]
api/controllers/web#6237 - [x]
api/scheduler#6237 - [x]
api/services#6203 - [x]
api/tasks#6203 - [ ] others
I'm in. Just let me know if there's anything I can do.
Hi @Poorandy! Thank you for your response. Could you please check the directories api/models, api/core/tools, and api/core/workflow? Please modify the parts where current_app.config is used.
You need to read our Contribution Guide first. Once you are done, please open a pull request and refer to this issue.
I want to contribute to this code refactoring. Please count me in. Let me know which directories I should work on.
Hi, @VickyGuo0907! Thank you for your reply. I've marked some directories for you, please check them. Have fun!
I would like to contribute to this issue. Please assign me some files or directories to work on.
Hi, @Tian-Hun! Thank you for your reply. I've marked some directories for you, please check them. Have fun!
@Poorandy @VickyGuo0907
Hi! Any updates on this?
@Poorandy @VickyGuo0907
Hi! Any updates on this?
Hi @laipz8200 , sorry I just saw this and will work on it.
Hi @laipz8200
I'd like to work on the api/controllers/console directory for this refactoring task.
I'm excited to help improve Dify.
@morugu Have fun!
Hi @VickyGuo0907, are you still working on this issue?
Hi @VickyGuo0907, are you still working on this issue?
Hi @ laipz8200, those folders you assigned me have already implemented these changes.
@VickyGuo0907 It is not implemented yet, like this line. Are you still interested in completing it?
Hi @laipz8200 sorry about the confusion early. I submitted a pull request https://github.com/langgenius/dify/pull/6747, Please review it. any issue please let me know. Thanks!
Just to let you know, we have completed this work. Thanks to every contributor.