Commit Graph

429 Commits

Author SHA1 Message Date
Harry 129c43dad0 fix: update EventConfiguration to use default_factory for parameters and enhance file_changes YAML schema
- Changed parameters in EventConfiguration to use default_factory for better initialization.
- Added parameters section in file_changes YAML to improve event documentation.
2025-10-27 11:29:30 +08:00
Harry df2073fbb1 Merge remote-tracking branch 'origin/main' into feat/trigger 2025-10-20 14:39:39 +08:00
Maries 569e68ac62 refactor: update model provider to use ModelFactory for instance mana… (#223)
* refactor: update model provider to use ModelFactory for instance management

* refactor: integrate ModelFactory for model instance mapping in tests

* refactor: remove unused imports and clean up test files
2025-10-20 14:27:20 +08:00
Harry 39a9a04d64 chore: bump plugin version to 0.6.0b13 and update response field in TriggerDispatchResponse model
- Updated version in pyproject.toml and requirements.txt to 0.6.0b13.
- Changed 'raw_http_response' to 'response' in TriggerDispatchResponse model for clarity.
- Updated GitHub trigger manifest version to 1.3.8.
2025-10-20 12:28:33 +08:00
Yeuoly 77a503422f add payload to 2025-10-18 18:20:35 +08:00
Yeuoly 8fc93f4024 feat: support payload in distaptch_event and _on_event 2025-10-18 18:18:43 +08:00
Harry cad974b207 feat: enhance GitHub trigger plugin with user ID tracking and event updates
- Added user_id field to EventDispatch and TriggerDispatchResponse models to track the user triggering events.
- Updated GitHub trigger provider to include user_id in event dispatching.
- Modified star event parameters in YAML to simplify naming conventions from "star_created" and "star_deleted" to "created" and "deleted".
- Bumped plugin version in manifest.yaml from 1.3.5 to 1.3.6 to reflect these changes.
2025-10-17 20:58:56 +08:00
Harry 9bbbf70423 refactor: update event description type and clean up YAML files
- Changed the type of the event description in EventConfiguration from EventDescription to I18nObject for better internationalization support.
- Updated related test cases to reflect this change.
- Simplified the description fields in various issue and star event YAML files by removing redundant human and llm sections, retaining only the essential translations.

These changes enhance the clarity and maintainability of event configurations and improve support for multiple languages.
2025-10-13 20:48:51 +08:00
Harry e526acc498 refactor: enhance subscription handling in PluginExecutor and related classes
- Added subscription handling to the EventRuntime and TriggerInvokeEventRequest classes, improving the management of event subscriptions.
- Updated the PluginExecutor to include subscription details when invoking events, ensuring better integration with subscription-based workflows.
- Modified test cases to reflect the new subscription structure, enhancing test coverage and reliability.

These changes improve the overall functionality and clarity of the subscription system within the plugin.
2025-10-13 18:12:54 +08:00
Harry 0f7d824c66 refactor: update OAuth provider instance retrieval and enhance type annotations
- Modified the `_get_oauth_provider_instance` method in `PluginExecutor` to accept a `Session` parameter and return the appropriate OAuth provider instance.
- Updated the `get_supported_oauth_provider_cls` method in `PluginRegistration` to `get_supported_oauth_provider`, improving its signature and functionality.
- Enhanced type annotations across methods to improve clarity and type safety.

These changes streamline the OAuth provider handling and improve code maintainability.
2025-10-11 21:55:36 +08:00
Harry b9ffc8334a refactor: improve type annotations and documentation clarity
- Enhanced type annotations in the PluginExecutor by adding Mapping to the import statements for better type safety.
- Reformatted the docstring in TriggerSubscriptionConstructor to improve readability by breaking long lines into multiple lines.

These changes contribute to better code clarity and maintainability across the plugin.
2025-10-11 21:10:50 +08:00
Harry 8cdd62509d refactor: enhance trigger subscription handling and improve type annotations
- Updated the PluginExecutor and related classes to improve type annotations and clarity, particularly in methods handling OAuth credentials and trigger subscriptions.
- Refactored the PluginRegistration and TriggerFactory classes to streamline the retrieval of trigger providers and event handlers, ensuring better type safety and consistency.
- Adjusted the YAML loader function to specify return types, enhancing code readability and maintainability.

These changes improve the overall structure and usability of the trigger subscription system, making it more robust and easier to understand.
2025-10-11 21:09:12 +08:00
Harry d6fa7bfb7e chore: bump dify_plugin version to 0.6.0b7 and update trigger event handling
- Updated the version in pyproject.toml from 0.6.0b6 to 0.6.0b7.
- Renamed trigger-related methods and classes for clarity, changing invoke_trigger to invoke_trigger_event and updating associated request and response classes.
- Adjusted event handling in the GithubTrigger class to improve event dispatching.

These changes ensure the plugin is up-to-date and enhance the clarity and functionality of event handling.
2025-10-10 19:31:28 +08:00
Harry ec9bb73fbe refactor: streamline trigger imports and enhance plugin registration logic
- Simplified import statements across various files by reordering and consolidating imports for better readability.
- Refactored the PluginRegistration class to improve the clarity of the configuration handling logic, ensuring more concise checks for subscription constructors.

These changes enhance code maintainability and readability throughout the plugin structure.
2025-10-10 14:31:49 +08:00
Harry 656037254e chore: bump dify_plugin version to 0.6.0b6 in pyproject.toml
- Updated the version of dify_plugin from 0.6.0b5 to 0.6.0b6 in pyproject.toml.

This change ensures that the project dependencies are aligned with the latest plugin version.
2025-10-10 13:10:44 +08:00
Harry 7b432936e2 docs: update TriggerSubscriptionConstructor to clarify selected_events parameter
- Added documentation for the selected_events parameter in TriggerSubscriptionConstructor, explaining its optional nature and behavior when set to None or provided with specific event types.

This change enhances the clarity of the subscription configuration for users, improving the overall usability of the trigger interface.
2025-10-10 10:55:36 +08:00
Harry aba2f88492 refactor: update event handling and parameter types in GitHub trigger
- Introduced new event mappings for issue comments in the GithubTrigger class, enhancing event handling capabilities.
- Updated the TriggerSubscribeRequest to allow for optional selected_events.
- Modified the YAML configuration to change the 'triggers' parameter to 'events' and added options for issue comments.

These changes improve the flexibility and clarity of event handling in the GitHub trigger implementation.
2025-10-09 17:44:44 +08:00
Harry 3fe764c6d2 refactor: update terminology in PluginExecutor and TriggerDispatchResponse
- Renamed the 'triggers' attribute to 'events' in TriggerDispatchResponse for consistency with event terminology.
- Updated method signatures in IssueOpenedEvent to use Mapping instead of dict for better type clarity.

These changes enhance the coherence of the codebase and align with the recent terminology updates across the project.
2025-10-09 14:48:44 +08:00
Harry a9b6abf9fc refactor: update trigger and event terminology across the codebase
- Renamed classes and methods related to triggers to use "Event" terminology for consistency and clarity.
- Updated the PluginExecutor, PluginRegistration, and TriggerFactory to reflect the new event handling structure.
- Adjusted YAML configurations and example implementations to align with the new event definitions.
- Enhanced the .gitignore file to include .DS_Store and ensure cleaner project management.

These changes improve the overall coherence of the codebase and enhance the clarity of event-driven functionality.
2025-09-30 20:10:16 +08:00
Harry 891e678e3a fix: no argument when provider created for oauth & credential validation 2025-09-29 23:11:38 +08:00
Harry 46b1ef471a refactor: streamline GitHub issue trigger implementation
- Removed the deprecated IssuesTrigger class and replaced it with a more focused IssueOpenedTrigger class to handle specific events when a new issue is opened.
- Updated the GitHub trigger YAML configuration to reflect changes in the subscription schema and parameters.
- Enhanced the validation logic for issue parameters, including title patterns, labels, assignees, authors, milestones, and body content.
- Improved the overall structure and clarity of the trigger implementation, ensuring better maintainability and functionality.

These changes contribute to a more efficient and organized handling of GitHub issue events, enhancing the plugin's responsiveness to user interactions.
2025-09-29 18:31:39 +08:00
Harry d75f734b7d feat: add checkbox parameter type to provider configuration
- Introduced a new CHECKBOX type in CommonParameterType to enhance parameter options.
- Updated ToolParameter and TriggerParameter classes to include the new CHECKBOX type.
- Modified the GitHub trigger manifest version to 1.1.0 and changed parameter type from select to checkbox in issues.yaml.

These changes improve the flexibility of parameter types available in the plugin, allowing for more diverse user interactions.
2025-09-29 14:29:38 +08:00
Yeuoly 420b2b6db1 refactor: improve code readability and organization
- Adjusted import order in request.py for consistency.
- Enhanced the description formatting in trigger.py for better clarity.
- Streamlined exception handling and method signatures in github.py for improved readability.
- Simplified dictionary construction in message_delivered.py to enhance clarity.
- Consolidated return statements in test_trigger_factory.py for better organization.

These changes contribute to a cleaner and more maintainable codebase, improving overall readability and consistency across the project.
2025-09-26 23:23:38 +08:00
Yeuoly 1881a22494 refactor: streamline trigger factory and enhance plugin registration
- Consolidated logic in PluginRegistration for determining subscription constructor classes.
- Simplified method signatures in TriggerFactory for better readability.
- Updated import paths in providers.py to reflect the new module structure.
- Introduced comprehensive tests for the TriggerFactory to ensure robust functionality.

These changes improve code clarity and maintainability while enhancing the overall structure of the trigger management system.
2025-09-26 23:14:03 +08:00
Yeuoly 3254019ec6 Add documentation and tests for trigger factory (#212) 2025-09-26 23:08:29 +08:00
Chieh Wang e2f6d0452a feat: support ja (#195) 2025-09-26 22:51:43 +08:00
Yeuoly fac16a49d2 feat: enhance trigger subscription management and introduce new runtime classes
- Added TriggerSubscriptionConstructorRuntime for managing subscription credentials and session data.
- Refactored PluginExecutor to utilize the new trigger subscription constructor for improved event handling.
- Updated PluginRegistration to support the new trigger subscription constructor interface.
- Introduced example-lark-trigger dependency in pyproject.toml for enhanced functionality.
- Cleaned up and standardized trigger-related classes and interfaces for better maintainability.

These changes improve the overall structure and functionality of the trigger subscription system, ensuring a more robust and flexible event handling process.
2025-09-26 22:20:23 +08:00
Yeuoly 76d1820205 feat: introduce UnsubscribeError for improved error handling in GitHub provider
- Added UnsubscribeError class to handle errors during unsubscribe operations, providing detailed error messages and codes.
- Updated GithubProvider to raise UnsubscribeError in various failure scenarios, enhancing error reporting and debugging.
- Minor adjustments in the IssuesTrigger class to prepare for future enhancements.

These changes improve the robustness of the GitHub trigger integration by ensuring clearer error management during webhook unsubscription processes.
2025-09-26 20:15:04 +08:00
Yeuoly 3adbc5c291 refactor: rename Unsubscription class to UnsubscribeResult for clarity
- Updated the class name from Unsubscription to UnsubscribeResult to better reflect its purpose.
- Adjusted related type hints and return types in the TriggerProvider interface and example implementations to maintain consistency.

These changes enhance code readability and improve the understanding of the unsubscription process in the trigger system.
2025-09-26 20:08:29 +08:00
Harry d3708859c7 refactor: remove DatasourceProviderMapping class from plugin_registration.py
- Eliminated the DatasourceProviderMapping class to streamline the codebase.
- This change enhances maintainability by reducing complexity in the plugin registration module.
2025-09-26 14:37:46 +08:00
Harry 5976f6ec1f refactor: format PluginAccessAction for improved readability
- Reformatted the definition of PluginAccessAction to enhance code clarity.
- Removed an unnecessary blank line in the TriggerInvokeRequest class.

These changes contribute to better code organization and maintainability.
2025-09-26 14:31:49 +08:00
Harry 27fca1f2fe feat: add DatasourceActions to PluginAccessAction and clean up code
- Included DatasourceActions in the merged PluginAccessAction for enhanced access control.
- Added a blank line for improved readability in the TriggerInvokeRequest class.

These changes improve the structure and functionality of the plugin request handling.
2025-09-26 14:21:33 +08:00
Harry 26b1324c59 Merge remote-tracking branch 'origin/main' into feat/trigger
# Conflicts:
#	python/dify_plugin/core/entities/message.py
#	python/dify_plugin/core/entities/plugin/request.py
#	python/dify_plugin/core/entities/plugin/setup.py
#	python/dify_plugin/core/plugin_registration.py
#	python/dify_plugin/plugin.py
#	python/examples/github/tools/github_repositories.yaml
#	python/pyproject.toml
2025-09-26 14:18:06 +08:00
He Wang 5f69350b7c fix: use dict.get() to avoid KeyError when transforming llm response (#209) 2025-09-26 13:17:32 +08:00
Rick b96f493563 feat: add max_invocation_timeout parameter (#208)
* feat: add max_invocation_timeout parameter

* style: format MAX_INVOCATION_TIMEOUT description for better readability

---------

Co-authored-by: Bytechoreographer <bytechoreographer@gmail.com>
2025-09-26 13:14:02 +08:00
Harry ebe4c89bea feat(github_trigger): enhance GitHub trigger functionality and update configurations
- Updated type hints in `setup.py` and `__init__.py` for better clarity and compatibility with newer Python versions.
- Improved descriptions in `trigger.py` for better understanding of output variables.
- Added new dynamic options fetching for repositories in `github.py`, enhancing user experience.
- Updated `manifest.yaml` to reflect the new version 100.1.1 and included additional localization for Japanese.
- Cleaned up and standardized code in various files for improved readability and maintainability.

These changes enhance the overall functionality and usability of the GitHub trigger integration, ensuring a more robust event handling process.
2025-09-25 17:20:16 +08:00
Harry 64d1f8fdde refactor: update type hints and improve error handling in datasource examples 2025-09-24 14:48:36 +08:00
Maries 2a5d34cd8f Merge pull request #149 from langgenius/feat/datasource
feat[0.5.0]: datasource
2025-09-24 11:33:48 +08:00
Harry c67ef57f10 feat(trigger): introduce new error class and enhance event payload handling
- Added `TriggerIgnoreEventError` to handle cases where events should be ignored based on filter criteria.
- Updated various GitHub trigger files to return relevant payload fields directly, improving data accessibility for event handling.
- Enhanced the handling of event filtering in triggers to ensure only relevant events are processed.

These changes improve the robustness and clarity of the GitHub trigger integration, allowing for better error management and data handling.
2025-09-19 13:17:59 +08:00
ZalterCitty 9f4ec08d62 support invoke tool with app_id (#207) 2025-09-18 14:43:52 +08:00
Harry fe397eaa9f Merge remote-tracking branch 'origin/main' into feat/datasource 2025-09-18 13:06:53 +08:00
Harry d6f3ee7fae feat(provider): add 'multiple' field to ProviderConfig for enhanced configuration options
- Introduced a new boolean field 'multiple' in the ProviderConfig class to allow for more flexible configuration settings.

This addition improves the configurability of provider options within the plugin.
2025-09-17 22:24:09 +08:00
Harry b182fd2668 feat(trigger): enhance GitHub trigger event handling and update version
- Refactored `TriggerInvokeResponse` to use `Mapping[str, Any]` for event representation.
- Renamed `properties` to `variables` in the `Event` class for clarity and updated the description accordingly.
- Expanded the event options in the GitHub trigger configuration to allow selection of all events.
- Removed the deprecated `issue_comment` trigger implementation and its associated files.
- Bumped version in `manifest.yaml` to 0.0.9 to reflect these changes.

These updates improve the flexibility and clarity of the GitHub trigger integration, allowing for a broader range of event handling.
2025-09-17 13:46:04 +08:00
immortal-wm 2fc9753673 fix: corrected latency accuracy (#189)
* fix latency calc

* feat: add timing context management to AIModel for latency tracking

- Introduced a new TimingContextRaceConditionError to handle race conditions in multi-threaded environments.
- Implemented a timing_context method in AIModel to track request timing and prevent concurrent usage.
- Updated various model classes (LargeLanguageModel, ModerationModel, RerankModel, Speech2TextModel, TextEmbeddingModel, TTSModel) to utilize the new timing context for latency calculations.
- Added tests to validate timing context behavior under concurrent and sequential usage scenarios.

* feat: implement ModelFactory for dynamic model instance creation

- Added ModelFactory class to generate stateless model instances based on provider configurations and model classes.
- Updated PluginRegistration to utilize ModelFactory for managing model instances, enhancing code organization and maintainability.

* feat: add unit tests for model registry and mock model provider

- Introduced a new test file for validating model registry functionality.
- Implemented mock classes for model provider and LLM to facilitate testing.
- Added tests to ensure correct model instance retrieval from the registry.

* apply ruff

---------

Co-authored-by: Yeuoly <admin@srmxy.cn>
2025-09-16 16:15:20 +08:00
Yeuoly d53cea4093 Merge branch 'main' into feat/datasource 2025-09-09 16:50:29 +08:00
Harry a285c70f52 refactor: clean up imports and improve code readability
- Removed unused imports in `__init__.py` and `dynamic_options.py`.
- Consolidated import statements in `github.py` and `issue_comment.py` for better organization.
- Standardized string formatting in test cases for consistency.
- Enhanced overall code clarity and maintainability.

These changes contribute to a cleaner codebase and improved readability across the project.
2025-09-08 23:55:31 +08:00
Maries 4ba92c11f9 Merge branch 'main' into feat/trigger 2025-09-08 23:50:30 +08:00
Harry 22f156e9b2 feat(trigger): enhance GitHub trigger with multiple event selection and dynamic parameter options
- Updated `IssueCommentTrigger` and `GithubProvider` to support multiple event selections for GitHub triggers.
- Introduced a new `multiple` field in the trigger parameters to allow users to select multiple events.
- Implemented dynamic fetching of repository options based on OAuth credentials.
- Bumped version in `manifest.yaml` to 0.0.7 to reflect these enhancements.

This update improves the flexibility and usability of the GitHub trigger integration.
2025-09-08 23:42:33 +08:00
QuantumGhost 005d05bc36 feat(python): relaxing version verification (#202)
Relaxing the verification for `PluginConfiguration.version`
and `PluginConfiguration.Meta.minimum_dify_version`.

SDK part of langgenius/dify#25160
2025-09-08 15:25:00 +08:00
deniswen 6b1d99fb62 fix: resolve 100% CPU usage in stdio buffer by replacing O(n²) Byte concatenation with BytesIO (#201)
* fix: improve stream reading and buffering logic

* fix: Re-add accidentally deleted line

---------

Co-authored-by: deniswen <denis.wen@anker-in.com>
2025-09-08 15:23:41 +08:00