dify icon indicating copy to clipboard operation
dify copied to clipboard

fix: resolve plugin model.position parsing in legacy DSL (≤0.1.5)

Open obelieve opened this issue 7 months ago • 4 comments

Summary

Fixes https://github.com/langgenius/dify/issues/20081 Fixes https://github.com/langgenius/dify/issues/19219 Fixes https://github.com/langgenius/dify/issues/20346

Reason: The ModelPosition definition in the following file is of type Optional[list[str]]:

https://github.com/langgenius/dify-plugin-sdks/blob/main/python/dify_plugin/entities/model/provider.py#L156

Whereas in api/../provider_entities.py, the position is defined as list[str] type (non-optional).

In other words:

  • In provider.py: position: Optional[list[str]]
  • In provider_entities.py: position: list[str]

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

[!Tip] Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

Screenshots

Before After
before after

Checklist

[!IMPORTANT]
Please review the checklist below before submitting your pull request.

  • [ ] This change requires a documentation update, included: Dify Document
  • [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • [x] I've updated the documentation accordingly.
  • [x] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

obelieve avatar May 25 '25 14:05 obelieve

We do not intend to continue supporting DSL files prior to version 1.0.0. As you can see, allowing fields to be empty would introduce a substantial amount of code to handle types, which is something we prefer to avoid.

laipz8200 avatar May 26 '25 14:05 laipz8200

We do not intend to continue supporting DSL files prior to version 1.0.0. As you can see, allowing fields to be empty would introduce a substantial amount of code to handle types, which is something we prefer to avoid.

If the requested API returns an optional type, the ProviderEntity should still need to be parsed. May I resubmit a fix to improve the reference checking?

obelieve avatar May 27 '25 14:05 obelieve

If the requested API returns an optional type, the ProviderEntity should still need to be parsed.

Could you please explain which types of APIs return data that requires compatibility?

laipz8200 avatar May 27 '25 15:05 laipz8200

If the requested API returns an optional type, the ProviderEntity should still need to be parsed.

Could you please explain which types of APIs return data that requires compatibility?

I found out that if we need to parse this API: https://marketplace.dify.ai/api/v1/plugins/batch

obelieve avatar May 28 '25 10:05 obelieve