* feat: update DifyPluginEnv to set default for REMOTE_INSTALL_URL and add unit tests for environment configurations
- Set default value of REMOTE_INSTALL_URL to None in DifyPluginEnv.
- Introduced unit tests for various installation methods including local, remote, and serverless configurations, ensuring proper functionality without parameters and with specific settings.
* fix: update condition for install_url check in Plugin class
- Changed the condition to explicitly check for None instead of a truthy value, improving clarity and preventing potential issues with falsy values.
* apply ruff
* feat: add unit test for AgentStrategy constructor
- Introduced a new test to validate the constructor of the AgentStrategy class, ensuring it is not overridden.
- Created an implementation of AgentStrategy for testing purposes, confirming that the constructor behaves as expected.
- Utilized ThreadPoolExecutor and session management to facilitate the test setup.
* fix: apply ruff
* fix: correct argument order in AgentStrategyImpl instantiation in test
* fix: improve buffer handling
* tests:add tests for StdioRequestReader
- Introduced a new private method `_read_async` to handle asynchronous reading from stdin.
- Updated `_read_stream` to utilize the new `_read_async` method for improved code clarity and maintainability.
- Added a new test file `test_stdio.py` to validate the functionality of the StdioRequestReader, ensuring correct handling of input data streams.
* fix: remove useless code
* fix: handle empty lines in StdioRequestReader
- Updated the StdioRequestReader to strip and skip empty lines during input processing.
- Added a new test to validate the handling of empty lines, ensuring the reader correctly processes a stream with mixed content.
* apply ruff
---------
Co-authored-by: Yeuoly <admin@srmxy.cn>
- Introduced a class method `_load_yaml_file` to encapsulate YAML file loading logic.
- Enhanced the `validate_endpoints` method to support both direct endpoint configurations and YAML file paths.
- Added unit tests for loading endpoint configurations from YAML strings and files.
* feat(http_parser): add functions to parse raw HTTP requests and convert Request objects to raw data
- Implemented `parse_raw_request` to convert raw HTTP data into a Request object, including support for headers and body.
- Added `convert_request_to_raw_data` to transform a Request object back into raw HTTP data.
- Created unit tests for both functions to ensure correct parsing and conversion behavior.
* apply ruff
- Changed minimum_dify_version from required to optional in PluginConfiguration.
- Added unit tests to verify behavior when minimum_dify_version is not provided.
* feat(python): Add specific error classes for StorageInvocation
Replace generic `Exception` raises with `NotFoundError` when the key is missing,
and `StorageInvocationError` for other response errors. This improves error
handling at call sites by avoiding overly generic exceptions.
# Conflicts:
# python/dify_plugin/invocations/storage.py
* test(python): Add test cases for `StorageInvocation`
- Ensure `StorageInvocation` raises the correct exceptions when data is missing
or `_backwards_invoke` returns an invalid response.
- Verify that `StorageInvocation` correctly processes the result returned
by `_backwards_invoke`.
* chore(python): fix linter violations
* feat(python): Change the exception `StorageInvocation.exist` raised
* test(python): Add test cases for `StorageInvocation.exist`.
* chore(python): temporarily disable `UP007` rule in Ruff
Disable the `UP007` rule temporarily due to numerous existing
violations in the current codebase.
* ci(python): add lint and test for Python SDK
* ci: Add mega-linter
* chore(python): Add final newline to markdown files
* fix(python): Fix linter issues by using ruff's auto fix
* fix(python): Fix TRY400 linter violations
Ruff suggests using `logger.exception` to log when
logging an exception, instead of using `logging.error`.
The former logs the exception and the traceback
automatically.
ref: https://docs.astral.sh/ruff/rules/error-instead-of-exception/
* fix(python): fix ruff linter violations
* test(python): Add Test cases for LLM entities
Test the initialization of `LLMResult` and `LLMResultChunk`.
* test(python): Add test for `AgentModelConfig`
Ensures that the `history_prompt_messages` attribute is
not shared between instances of `AgentModelConfig`.
* chore(python): output diffs in Ruff's format check
* style(python): format code with Ruff
* chore(python): Add a bash script for fix and format python code
* chore: add `persist-credentials: false` to checkout action
Enhances security by preventing subsequent
steps from accessing GitHub credentials, reducing
potential attack surfaces.
Ref: https://github.com/actions/checkout#checkout-v4
* refactor: remove prompt_messages from LLMResult and LLMResultChunk
* fix: add backward compatibility for deprecated prompt_messages field in LLMResult and LLMResultChunk
* fix: set default value for prompt_messages field to an empty list in LLMResult and LLMResultChunk for backward compatibility
* feat: add test for LLMResult to validate prompt_messages field and ensure backward compatibility
* apply ruff
* chore(*): Add pytest into test group
Signed-off-by: -LAN- <laipz8200@outlook.com>
* fix: Enhance content transformation to support Sequence type and add unit tests
Signed-off-by: -LAN- <laipz8200@outlook.com>
---------
Signed-off-by: -LAN- <laipz8200@outlook.com>
1. Use PDM and `pyproject.toml` instead of the `requirements.txt` under `python/dify_plugin`.
2. Use PDM and `setup-pdm` action instead of setuptools and publish manually.
> You can configure trusted publishers for PyPI so that you don't need to expose the PyPI tokens in the release workflow. To do this, follow [the guide](https://docs.pypi.org/trusted-publishers/adding-a-publisher/) to add a publisher.
Signed-off-by: -LAN- <laipz8200@outlook.com>