Improve Configuration Usage Experience #4425

Closed
opened 2026-02-21 18:06:21 -05:00 by yindo · 15 comments
Owner

Originally created by @laipz8200 on GitHub (Jul 3, 2024).

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:

  1. Create a singleton DifyConfig
  2. Use this singleton to replace all logic that currently retrieves values from current_app.config and environment variables
  3. 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

Originally created by @laipz8200 on GitHub (Jul 3, 2024). 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: 1. Create a singleton `DifyConfig` 2. Use this singleton to replace all logic that currently retrieves values from `current_app.config` ~~and environment variables~~ 3. 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 - [x] `api/core/file` #6747 - [x] `api/core/moderation` #6747 - [x] `api/core/app` #6747 - [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 - [x] others #6750
yindo added the 💪 enhancementgood first issue🙏 help wanted labels 2026-02-21 18:06:21 -05:00
yindo closed this issue 2026-02-21 18:06:21 -05:00
Author
Owner

@Poorandy commented on GitHub (Jul 6, 2024):

I'm in. Just let me know if there's anything I can do.

@Poorandy commented on GitHub (Jul 6, 2024): I'm in. Just let me know if there's anything I can do.
Author
Owner

@laipz8200 commented on GitHub (Jul 7, 2024):

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.

@laipz8200 commented on GitHub (Jul 7, 2024): 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](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) first. Once you are done, please open a pull request and refer to this issue.
Author
Owner

@VickyGuo0907 commented on GitHub (Jul 10, 2024):

I want to contribute to this code refactoring. Please count me in. Let me know which directories I should work on.

@VickyGuo0907 commented on GitHub (Jul 10, 2024): I want to contribute to this code refactoring. Please count me in. Let me know which directories I should work on.
Author
Owner

@laipz8200 commented on GitHub (Jul 10, 2024):

Hi, @VickyGuo0907! Thank you for your reply. I've marked some directories for you, please check them. Have fun!

@laipz8200 commented on GitHub (Jul 10, 2024): Hi, @VickyGuo0907! Thank you for your reply. I've marked some directories for you, please check them. Have fun!
Author
Owner

@Tian-Hun commented on GitHub (Jul 11, 2024):

I would like to contribute to this issue. Please assign me some files or directories to work on.

@Tian-Hun commented on GitHub (Jul 11, 2024): I would like to contribute to this issue. Please assign me some files or directories to work on.
Author
Owner

@laipz8200 commented on GitHub (Jul 11, 2024):

Hi, @Tian-Hun! Thank you for your reply. I've marked some directories for you, please check them. Have fun!

@laipz8200 commented on GitHub (Jul 11, 2024): Hi, @Tian-Hun! Thank you for your reply. I've marked some directories for you, please check them. Have fun!
Author
Owner

@laipz8200 commented on GitHub (Jul 17, 2024):

@Poorandy @VickyGuo0907

Hi! Any updates on this?

@laipz8200 commented on GitHub (Jul 17, 2024): @Poorandy @VickyGuo0907 Hi! Any updates on this?
Author
Owner

@VickyGuo0907 commented on GitHub (Jul 18, 2024):

@Poorandy @VickyGuo0907

Hi! Any updates on this?

Hi @laipz8200 , sorry I just saw this and will work on it.

@VickyGuo0907 commented on GitHub (Jul 18, 2024): > @Poorandy @VickyGuo0907 > > Hi! Any updates on this? Hi @laipz8200 , sorry I just saw this and will work on it.
Author
Owner

@morugu commented on GitHub (Jul 19, 2024):

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 commented on GitHub (Jul 19, 2024): Hi @laipz8200 I'd like to work on the `api/controllers/console` directory for this refactoring task. I'm excited to help improve Dify.
Author
Owner

@laipz8200 commented on GitHub (Jul 19, 2024):

@morugu Have fun!

@laipz8200 commented on GitHub (Jul 19, 2024): @morugu Have fun!
Author
Owner

@laipz8200 commented on GitHub (Jul 27, 2024):

Hi @VickyGuo0907, are you still working on this issue?

@laipz8200 commented on GitHub (Jul 27, 2024): Hi @VickyGuo0907, are you still working on this issue?
Author
Owner

@VickyGuo0907 commented on GitHub (Jul 27, 2024):

Hi @VickyGuo0907, are you still working on this issue?

Hi @ laipz8200, those folders you assigned me have already implemented these changes.

@VickyGuo0907 commented on GitHub (Jul 27, 2024): > Hi @VickyGuo0907, are you still working on this issue? Hi @ laipz8200, those folders you assigned me have already implemented these changes.
Author
Owner

@laipz8200 commented on GitHub (Jul 27, 2024):

@VickyGuo0907 It is not implemented yet, like this line. Are you still interested in completing it?

@laipz8200 commented on GitHub (Jul 27, 2024): @VickyGuo0907 It is not implemented yet, like [this line](https://github.com/langgenius/dify/blob/6ef401a9f0b557a37838f6cfd0446f2e97bd5b1f/api/core/app/apps/base_app_queue_manager.py#L51). Are you still interested in completing it?
Author
Owner

@VickyGuo0907 commented on GitHub (Jul 28, 2024):

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!

@VickyGuo0907 commented on GitHub (Jul 28, 2024): 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!
Author
Owner

@laipz8200 commented on GitHub (Jul 30, 2024):

Just to let you know, we have completed this work. Thanks to every contributor.

@laipz8200 commented on GitHub (Jul 30, 2024): Just to let you know, we have completed this work. Thanks to every contributor.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4425