Commit Graph

546 Commits

Author SHA1 Message Date
Yeuoly c6c4bdc69c fix: improve description formatting for datasource manifest paths
- Updated the description of the `datasources` field in `PluginConfiguration` to enhance clarity and readability by splitting the text into two lines.
2025-05-23 19:06:45 +08:00
Yeuoly 0922b15e54 feat: implement datasource actions and validation methods
- Added new request models for datasource actions including validation, website crawling, and content retrieval.
- Enhanced `PluginExecutor` with methods to validate datasource credentials, crawl websites, and retrieve pages and content.
- Updated `PluginRegistration` to include methods for fetching datasource provider classes and handling website and online document datasources.
- Refined the `DatasourceProvider` interface to use `Mapping` for credentials, improving type safety.
2025-05-23 19:06:18 +08:00
Yeuoly d72b26ed76 feat: implement datasource provider mapping and actions
- Introduced `DatasourceProviderMapping` class to manage datasource provider configurations and mappings.
- Enhanced `PluginRegistration` to include datasource configuration and mapping logic.
- Added new `DatasourceActions` enum for handling datasource-related actions.
- Updated `PluginConfiguration` to include a list of datasource manifest paths, improving plugin extensibility.
2025-05-23 18:52:18 +08:00
Yeuoly 040d8d5ddd feat: enhance datasource provider model with validation and documentation
- Added validation for the `datasources` field in `DatasourceProviderManifest` to ensure it is a list of strings representing datasource paths.
- Introduced YAML loading for datasource configurations, improving the handling of datasource entities.
- Enhanced documentation annotations for `DatasourceProviderType`, `DatasourceParameter`, and `DatasourceIdentity` classes to clarify their purpose and usage.
2025-05-23 18:39:43 +08:00
Yeuoly 94d28ca13c feat: extend datasource and provider models with additional fields
- Added `DatasourceEntityExtra` and `DatasourceProviderConfigurationExtra` classes to encapsulate extra information for datasource and provider entities.
- Updated `DatasourceEntity` and `DatasourceProviderManifest` to include new `extra` fields, enhancing the data structure and documentation.
- Introduced documentation annotations for improved clarity on the purpose of new classes and fields.
2025-05-23 18:36:05 +08:00
Yeuoly da0b4ddd5d apply ruff 2025-05-23 18:31:24 +08:00
Yeuoly cae56704be feat: enhance entity models with new datasource and parameter options
- Introduced `DatasourceProviderType`, `DatasourceParameter`, and related classes to support new datasource functionalities.
- Added `ParameterOption`, `ParameterAutoGenerate`, and `ParameterTemplate` classes for improved parameter handling.
- Updated existing models to utilize the new parameter classes, enhancing type safety and documentation.
2025-05-23 18:30:41 +08:00
Yeuoly 0b496fb3ff feat: add tests 2025-05-23 18:22:21 +08:00
Yeuoly 8f5e27732c feat: add online document and website crawl datasource interfaces
- Introduced `OnlineDocumentDatasource` and `WebsiteCrawlDatasource` abstract classes for handling online document and website crawl functionalities.
- Added corresponding methods for retrieving pages and content, enhancing the datasource capabilities.
- Created new models for online document and website information to support the new interfaces.
2025-05-23 18:17:04 +08:00
Yeuoly 8af6e7d5e1 tests 2025-05-19 22:27:51 +08:00
Yeuoly 07cca4dc85 feat: datasource 2025-05-19 22:26:06 +08:00
Yeuoly 6d77e16b7d chore: update dependencies and remove pydub from main requirements (#135)
- Removed `pydub` from the main dependencies in `pyproject.toml`.
- Added `pydub` back to the `requirements.txt` for the OpenAI example.
2025-05-19 22:19:49 +08:00
Yeuoly 6d5d601804 feat[0.4.0](oauth): implement OAuth authorization URL and credentials retrieval (#116)
* feat(oauth): implement OAuth authorization URL and credentials retrieval

- Added OAuthGetAuthorizationUrlRequest and OAuthGetCredentialsRequest models for handling OAuth requests.
- Introduced methods in PluginExecutor for generating OAuth authorization URLs and retrieving OAuth credentials.
- Updated ToolProvider interface to include OAuth methods for authorization URL and credentials handling.
- Refactored PluginInvokeType and related action enums to support OAuth actions.
2025-05-19 22:13:53 +08:00
Yeuoly a4bad2b274 Bump to 0.3.0 (#146) 2025-05-19 15:00:25 +08:00
Yeuoly 46eb504125 feat[0.3.0]: add plugin runner functionality (#144)
* feat: add integration configuration and plugin runner functionality

- Introduced `IntegrationConfig` class for managing plugin testing configurations, including validation for the `dify_cli_path`.
- Added `PluginInvokeRequest` and `PluginGenericResponse` models to handle plugin invocation requests and responses.
- Implemented `PluginRunner` class to facilitate running plugins locally, including asynchronous message handling and process management.
- Merged access actions into a single `PluginAccessAction` for streamlined access control.

* apply ruff

* feat: enhance plugin runner with new response handling and exception management

- Added `PLUGIN_INVOKE_END` response type to manage the end of plugin invocations.
- Introduced `PluginStopped` exception to handle plugin termination gracefully.
- Updated `PluginRunner` to support stopping the plugin process and handling asynchronous message reading with improved error management.
- Modified message queue to accommodate `None` responses for completed invocations.

* refactor: rename PluginStopped exception to PluginStoppedError

- Renamed `PluginStopped` to `PluginStoppedError` for clarity and consistency.
- Updated references in the `run.py` file to reflect the new exception name.
- Added a docstring to `PluginStoppedError` to describe its purpose.

* fix: update version check for dify CLI in IntegrationConfig

- Modified the version check in the IntegrationConfig class to require a minimum version of 0.1.0 instead of 0.4.0.
- Ensured that the version validation logic is clearer and more robust.

* chore: update dependencies and lock file

- Updated the `content_hash` in `pdm.lock` to reflect changes in dependencies.
- Added `packaging>=25.0` to the dependencies in `pyproject.toml` to ensure compatibility with the latest packaging features.

* feat: enhance IntegrationConfig with improved CLI path validation

- Added a list of potential plugin names to search for the dify CLI executable.
- Updated the validation logic to check for the CLI path against multiple plugin names.
- Changed error handling to use ValidationError for invalid CLI path and version checks.

* feat: add setup script for dify-plugin-cli installation

- Introduced a new script to automate the installation of dify-plugin-cli, including OS and architecture detection.
- Updated the pull request workflow to include the setup of the dify-plugin-cli before installing dependencies.
- Refactored error handling in IntegrationConfig to use ValueError instead of ValidationError for CLI path and version checks.

* feat: add integration test for invoking LLM with mocked OpenAI server

- Introduced a new integration test in `test_invoke_llm.py` to validate the invocation of the LLM plugin using a mocked OpenAI server.
- Implemented a mock server to simulate OpenAI's chat completions API, supporting both streaming and non-streaming responses.
- The test downloads the latest `langgenius-openai` plugin, runs the plugin, and asserts the expected response from the LLM.

* fix: add timeout to requests in LLM integration test

- Updated the `test_invoke_llm.py` file to include a timeout of 10 seconds for both POST and GET requests to the marketplace API.
- This change aims to improve the reliability of the integration test by preventing indefinite blocking on network calls.

* feat: enhance dify-plugin-cli setup script with installation verification and PATH configuration

- Added verification to check if dify-plugin is available in the user's PATH after installation.
- Implemented logic to add dify-plugin to the system PATH for all users when run as root, or to the user's profile for non-root users.
- Created symlinks in common bin directories and provided usage instructions for the dify-plugin commands.

* refactor: update dify-plugin-cli setup script for improved PATH management

- Enhanced the script to add the installation directory to the GITHUB_PATH for GitHub Actions.
- Modified the PATH export for local development to ensure the installation directory is prioritized.
- Removed redundant installation verification and symlink creation logic, streamlining the setup process.

* test: add SSH support to pull request workflow

- Integrated SSH functionality into the pull request workflow using the mxschmitt/action-tmate@v3 action.
- This addition allows for interactive debugging and terminal access during pull request checks.

* chore: remove SSH step from pull request workflow and fix import in integration test

- Eliminated the SSH step from the pull request workflow to streamline the process.
- Fixed the import statement for the `requests` library in `test_invoke_llm.py` to ensure proper functionality during the test execution.

* wtf

* feat: implement OpenAI mock server for integration testing

- Added a new mock server in `python/tests/__mock_server` to simulate OpenAI's chat completions API, supporting both streaming and non-streaming responses.
- Updated the pull request workflow to install the `uv` tool and launch the mock server during testing.
- Refactored `test_invoke_llm.py` to utilize the mock server, ensuring reliable integration tests without external dependencies.

* apply ruff

* refactor: streamline mock server launch in pull request workflow

- Replaced inline mock server launch commands in the pull request workflow with a dedicated script `launch_mock_server.sh` for improved readability and maintainability.
- The new script handles the execution of the mock server, ensuring a cleaner workflow configuration.

* fix: update mock server launch path in pull request workflow

- Changed the path for launching the mock server script from `./scripts/launch_mock_server.sh` to `./python/scripts/launch_mock_server.sh` to ensure correct execution within the workflow.

* fix: run mock server in background during pull request workflow

- Updated the pull request workflow to launch the mock server script in the background by appending `&` to the command. This change allows subsequent steps to execute without waiting for the mock server to terminate.

* chore: clean up dify-plugin-cli setup script by removing outdated installation instructions

- Removed outdated comments regarding the download and installation of dify-plugin-cli, streamlining the script for clarity.

* feat: enhance PluginRunner with graceful shutdown and thread safety

- Introduced a stop flag and a lock to ensure thread-safe access to the stop flag in the PluginRunner class.
- Implemented a _close method to handle graceful termination of the plugin process, including sending a SIGTERM signal and closing pipes.
- Refactored the _read_async method to ensure proper cleanup and handling of messages, maintaining the integrity of the message queue.
2025-05-19 14:56:13 +08:00
Yeuoly e380493e25 Bump to 0.2.4 (#143) 2025-05-14 13:07:18 +08:00
Yeuoly 5078f9d390 fix: update DifyPluginEnv to set default for REMOTE_INSTALL_URL (#142)
* 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
2025-05-14 13:03:39 +08:00
Will 371bbbfc94 fix REMOTE_INSTALL_URL, need default value (#141) 2025-05-14 13:01:06 +08:00
Yeuoly ddb87f8605 Bump sdk to 0.2.3 (#139) 2025-05-13 15:46:31 +08:00
Bowen Liang 9353164ddb feat: support REMOTE_INSTALL_URL config for remote installing and debugging (#136)
* support REMOTE_INSTALL_URL

* nit

* nit

* passing remote_install_host and remote_install_port to TCPReaderWriter

* fix the host and port parsing approach without yarl

* extract method for parsing the host and port

* nit

* nit

* nit

* nit

* improve _get_remote_install_host_and_port method

* fix style

* fix style
2025-05-13 15:42:54 +08:00
Bowen Liang 08c596d077 httpx~=0.28.1 (#137) 2025-05-12 14:45:55 +08:00
Yeuoly dbcb96ba61 feat: add repository URL field to manifest (#134)
- Introduced an optional `repo` field in the `PluginConfiguration` class to store the repository URL of the plugin, enhancing the configuration capabilities.
2025-05-07 18:35:41 +08:00
Yeuoly 3033f3e6c2 chore: add unit test for AgentStrategy constructor (#133)
* 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
2025-05-07 13:52:33 +08:00
Yeuoly 5f517df4f5 feat: mark constructors as final in multiple classes (#132)
- Added `@final` decorator to the constructors of `AgentStrategy`, `Endpoint`, `AIModel`, and `Tool` classes to prevent overriding.
- Included documentation notes in each constructor to indicate that they should not be overridden.
2025-05-07 13:22:20 +08:00
Yeuoly 50a8b90223 Bump to 0.2.2 (#131) 2025-05-06 16:39:38 +08:00
kurokobo c61fa1282a fix: improve buffer handling for multimodal input (#128)
* 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>
2025-05-06 16:37:41 +08:00
Yeuoly e4b0d5a181 feat(endpoint): support declare endpoints in groups (#130)
- 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.
2025-05-06 15:57:32 +08:00
Tianyi Jing 931e4d1485 feat: support list in ToolInvokeMessage.JsonMessage (#122)
Signed-off-by: jingfelix <jingfelix@outlook.com>
2025-05-06 15:54:47 +08:00
Darlewo a35cb4c5e6 fix: remove unnecessary locking in _recv_from_sock method (#125) 2025-04-30 15:40:48 +08:00
Kalo Chin d8f9286eb3 fix(File): enhance error handling for unsupported URL protocols in file retrieval (#124)
- Added exception handling for unsupported protocols in the `get_blob` method.
- Raises a ValueError with a clear message if the URL is invalid, guiding users to check the `FILES_URL` environment variable.
- Maintained existing functionality while improving robustness against HTTP request failures.
2025-04-30 15:34:25 +08:00
Yeuoly 038edf957e feat: generate docs automatically (#121)
- Added CLI for generating documentation with `generate-docs` command.
- Introduced `SchemaDocumentationGenerator` to create structured documentation from schemas.
- Implemented `SchemaDoc` class for schema metadata and documentation management.
- Updated `PluginConfiguration` to include descriptions for plugin components.
- Added support for outside reference fields in the SchemaDocumentationGenerator to improve documentation clarity.
- Updated SchemaDoc to include outside_reference_fields parameter.
- Modified various entity classes to utilize outside_reference_fields for better schema representation.
- Introduced new container type checks and helper methods for handling dynamic fields in documentation generation.
2025-04-30 14:48:03 +08:00
Kollin bed0cc106c agent node add runtime(user_id) (#115)
* agent node add runtime(user_id)

* add optional for user_id
2025-04-27 16:46:56 +08:00
Yeuoly 29a15ccdd7 feat(http_parser): add functions to parse raw HTTP requests and conve… (#119)
* 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
2025-04-27 15:02:42 +08:00
cirtron 64ee98d533 Update README.md to new version (#118) 2025-04-27 15:01:26 +08:00
Chieh Wang 293d622e68 feat: Add Citations and Attributions to Agent Node (#107)
* feat: support var-selector params & surpport retriever_resources messsage

* opt: rename var-select to any

* fix: line too long

* opt: Add RetrieverResource Type
2025-04-27 13:54:22 +08:00
Yeuoly 2c208ebe23 fix: update storage field to be optional in PluginResourceRequirements class (#114) 2025-04-25 15:29:17 +08:00
Yeuoly c278653d49 chore: bump version to 0.2.1 (#112) 2025-04-25 14:15:24 +08:00
Yeuoly f14a1f9416 fix: update minimum_dify_version to be optional in PluginConfiguration (#111)
- Changed minimum_dify_version from required to optional in PluginConfiguration.
- Added unit tests to verify behavior when minimum_dify_version is not provided.
2025-04-25 14:15:09 +08:00
Chieh Wang bfbf7ced91 fix: ignore abnormal chunk (#109) 2025-04-25 14:12:38 +08:00
Vitor a39ec2c948 fix: incorrectly uses new_tool_call.function.name while getting existing tool calls (#104) 2025-04-25 14:00:23 +08:00
Yeuoly b884686d5e chore: bump version to 0.2.0 (#110) 2025-04-25 13:58:29 +08:00
Chieh Wang 8b63710a06 fix: debug mode cannot get app_id (#106) 2025-04-25 13:51:21 +08:00
Yeuoly 9c324aab14 optimize: replace json.loads with TypeAdapter for JSON unmarshaling (#103)
* refactor: replace json.loads with TypeAdapter for JSON validation in request readers and model

- Updated JSON parsing in BackwardsInvocation, StdioRequestReader, and TCPReaderWriter to use TypeAdapter for improved validation.
- Enhanced error handling in OAICompatLargeLanguageModel by replacing json.loads with TypeAdapter, ensuring better compliance with expected JSON schema.

* fix: linter
2025-04-17 16:31:40 +08:00
Junjie.M f714fc9bf7 feat: agent strategy parameter add help field (#99) 2025-04-17 14:00:32 +08:00
Yeuoly ca736effd7 feat(invocation): add FetchAppInvocation and update type hints for improved clarity (#100)
* feat(invocation): add FetchAppInvocation and update type hints for improved clarity

- Introduced FetchAppInvocation class to handle fetching app data.
- Updated type hints in ToolInvokeMessage and related classes to use Mapping for better type safety.
- Added FetchApp enum value to InvokeType for consistency in invocation types.

* apply ruff
2025-04-16 20:25:39 +08:00
Novice 0690573a87 feat(model): add structured output feature to model 2025-04-16 08:59:06 +08:00
QuantumGhost 182828657b feat(python): Add specific error classes for StorageInvocation (#90)
* 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`.
2025-04-15 14:51:43 +08:00
Novice e2447622a8 feat(model): add structured output feature to model 2025-04-15 14:00:27 +08:00
Novice 9cc8f27102 chore: fix ruff issue 2025-04-15 13:34:25 +08:00
Novice aa71d8dc12 fix(agent_node): support tool parameters of select type 2025-04-15 13:24:55 +08:00