dify icon indicating copy to clipboard operation
dify copied to clipboard

Improve Configuration Usage Experience

Open laipz8200 opened this issue 1 year ago • 10 comments

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
  • [ ] 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

laipz8200 avatar Jul 03 '24 13:07 laipz8200

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

Poorandy avatar Jul 06 '24 04:07 Poorandy

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 avatar Jul 08 '24 01:07 laipz8200

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

VickyGuo0907 avatar Jul 11 '24 02:07 VickyGuo0907

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

laipz8200 avatar Jul 11 '24 03:07 laipz8200

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

Tian-Hun avatar Jul 11 '24 08:07 Tian-Hun

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

laipz8200 avatar Jul 12 '24 03:07 laipz8200

@Poorandy @VickyGuo0907

Hi! Any updates on this?

laipz8200 avatar Jul 17 '24 11:07 laipz8200

@Poorandy @VickyGuo0907

Hi! Any updates on this?

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

VickyGuo0907 avatar Jul 19 '24 02:07 VickyGuo0907

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 avatar Jul 19 '24 11:07 morugu

@morugu Have fun!

laipz8200 avatar Jul 19 '24 11:07 laipz8200

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

laipz8200 avatar Jul 27 '24 06:07 laipz8200

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

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

VickyGuo0907 avatar Jul 27 '24 21:07 VickyGuo0907

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

laipz8200 avatar Jul 28 '24 02:07 laipz8200

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 avatar Jul 28 '24 14:07 VickyGuo0907

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

laipz8200 avatar Jul 30 '24 04:07 laipz8200