From 1449ed86c4ab0a264ea49410b62071ed6d2f28c9 Mon Sep 17 00:00:00 2001 From: Harry Date: Fri, 27 Jun 2025 20:11:28 +0800 Subject: [PATCH] feat: rename online driver to online drive and update related classes and methods :) --- .../entities/datasource_entities.py | 16 ++++++------- .../online_drive_plugin.py} | 24 +++++++++---------- .../online_drive_provider.py} | 10 ++++---- api/core/plugin/impl/datasource.py | 22 ++++++++--------- 4 files changed, 36 insertions(+), 36 deletions(-) rename api/core/datasource/{online_driver/online_driver_plugin.py => online_drive/online_drive_plugin.py} (76%) rename api/core/datasource/{online_driver/online_driver_provider.py => online_drive/online_drive_provider.py} (83%) diff --git a/api/core/datasource/entities/datasource_entities.py b/api/core/datasource/entities/datasource_entities.py index a345b0e18f..41be2dcc3d 100644 --- a/api/core/datasource/entities/datasource_entities.py +++ b/api/core/datasource/entities/datasource_entities.py @@ -26,7 +26,7 @@ class DatasourceProviderType(enum.StrEnum): ONLINE_DOCUMENT = "online_document" LOCAL_FILE = "local_file" WEBSITE_CRAWL = "website_crawl" - ONLINE_DRIVER = "online_driver" + ONLINE_DRIVE = "online_drive" @classmethod def value_of(cls, value: str) -> "DatasourceProviderType": @@ -311,7 +311,7 @@ class DatasourceMessage(ToolInvokeMessage): ######################### -class OnlineDriverFile(BaseModel): +class OnlineDriveFile(BaseModel): """ Online driver file """ @@ -320,17 +320,17 @@ class OnlineDriverFile(BaseModel): size: int = Field(..., description="The size of the file") -class OnlineDriverFileBucket(BaseModel): +class OnlineDriveFileBucket(BaseModel): """ Online driver file bucket """ bucket: Optional[str] = Field(None, description="The bucket of the file") - files: list[OnlineDriverFile] = Field(..., description="The files of the bucket") + files: list[OnlineDriveFile] = Field(..., description="The files of the bucket") is_truncated: bool = Field(False, description="Whether the bucket has more files") -class OnlineDriverBrowseFilesRequest(BaseModel): +class OnlineDriveBrowseFilesRequest(BaseModel): """ Get online driver file list request """ @@ -343,15 +343,15 @@ class OnlineDriverBrowseFilesRequest(BaseModel): ) -class OnlineDriverBrowseFilesResponse(BaseModel): +class OnlineDriveBrowseFilesResponse(BaseModel): """ Get online driver file list response """ - result: list[OnlineDriverFileBucket] = Field(..., description="The bucket of the files") + result: list[OnlineDriveFileBucket] = Field(..., description="The bucket of the files") -class OnlineDriverDownloadFileRequest(BaseModel): +class OnlineDriveDownloadFileRequest(BaseModel): """ Get online driver file """ diff --git a/api/core/datasource/online_driver/online_driver_plugin.py b/api/core/datasource/online_drive/online_drive_plugin.py similarity index 76% rename from api/core/datasource/online_driver/online_driver_plugin.py rename to api/core/datasource/online_drive/online_drive_plugin.py index 60322457ac..f0e3cb38f9 100644 --- a/api/core/datasource/online_driver/online_driver_plugin.py +++ b/api/core/datasource/online_drive/online_drive_plugin.py @@ -6,14 +6,14 @@ from core.datasource.entities.datasource_entities import ( DatasourceEntity, DatasourceMessage, DatasourceProviderType, - OnlineDriverBrowseFilesRequest, - OnlineDriverBrowseFilesResponse, - OnlineDriverDownloadFileRequest, + OnlineDriveBrowseFilesRequest, + OnlineDriveBrowseFilesResponse, + OnlineDriveDownloadFileRequest, ) from core.plugin.impl.datasource import PluginDatasourceManager -class OnlineDriverDatasourcePlugin(DatasourcePlugin): +class OnlineDriveDatasourcePlugin(DatasourcePlugin): tenant_id: str icon: str plugin_unique_identifier: str @@ -33,15 +33,15 @@ class OnlineDriverDatasourcePlugin(DatasourcePlugin): self.icon = icon self.plugin_unique_identifier = plugin_unique_identifier - def online_driver_browse_files( + def online_drive_browse_files( self, user_id: str, - request: OnlineDriverBrowseFilesRequest, + request: OnlineDriveBrowseFilesRequest, provider_type: str, - ) -> Generator[OnlineDriverBrowseFilesResponse, None, None]: + ) -> Generator[OnlineDriveBrowseFilesResponse, None, None]: manager = PluginDatasourceManager() - return manager.online_driver_browse_files( + return manager.online_drive_browse_files( tenant_id=self.tenant_id, user_id=user_id, datasource_provider=self.entity.identity.provider, @@ -51,15 +51,15 @@ class OnlineDriverDatasourcePlugin(DatasourcePlugin): provider_type=provider_type, ) - def online_driver_download_file( + def online_drive_download_file( self, user_id: str, - request: OnlineDriverDownloadFileRequest, + request: OnlineDriveDownloadFileRequest, provider_type: str, ) -> Generator[DatasourceMessage, None, None]: manager = PluginDatasourceManager() - return manager.online_driver_download_file( + return manager.online_drive_download_file( tenant_id=self.tenant_id, user_id=user_id, datasource_provider=self.entity.identity.provider, @@ -70,4 +70,4 @@ class OnlineDriverDatasourcePlugin(DatasourcePlugin): ) def datasource_provider_type(self) -> str: - return DatasourceProviderType.ONLINE_DRIVER + return DatasourceProviderType.ONLINE_DRIVE diff --git a/api/core/datasource/online_driver/online_driver_provider.py b/api/core/datasource/online_drive/online_drive_provider.py similarity index 83% rename from api/core/datasource/online_driver/online_driver_provider.py rename to api/core/datasource/online_drive/online_drive_provider.py index edceeecd00..d0923ed807 100644 --- a/api/core/datasource/online_driver/online_driver_provider.py +++ b/api/core/datasource/online_drive/online_drive_provider.py @@ -1,10 +1,10 @@ from core.datasource.__base.datasource_provider import DatasourcePluginProviderController from core.datasource.__base.datasource_runtime import DatasourceRuntime from core.datasource.entities.datasource_entities import DatasourceProviderEntityWithPlugin, DatasourceProviderType -from core.datasource.online_driver.online_driver_plugin import OnlineDriverDatasourcePlugin +from core.datasource.online_drive.online_drive_plugin import OnlineDriveDatasourcePlugin -class OnlineDriverDatasourcePluginProviderController(DatasourcePluginProviderController): +class OnlineDriveDatasourcePluginProviderController(DatasourcePluginProviderController): entity: DatasourceProviderEntityWithPlugin plugin_id: str plugin_unique_identifier: str @@ -21,9 +21,9 @@ class OnlineDriverDatasourcePluginProviderController(DatasourcePluginProviderCon """ returns the type of the provider """ - return DatasourceProviderType.ONLINE_DRIVER + return DatasourceProviderType.ONLINE_DRIVE - def get_datasource(self, datasource_name: str) -> OnlineDriverDatasourcePlugin: # type: ignore + def get_datasource(self, datasource_name: str) -> OnlineDriveDatasourcePlugin: # type: ignore """ return datasource with given name """ @@ -39,7 +39,7 @@ class OnlineDriverDatasourcePluginProviderController(DatasourcePluginProviderCon if not datasource_entity: raise ValueError(f"Datasource with name {datasource_name} not found") - return OnlineDriverDatasourcePlugin( + return OnlineDriveDatasourcePlugin( entity=datasource_entity, runtime=DatasourceRuntime(tenant_id=self.tenant_id), tenant_id=self.tenant_id, diff --git a/api/core/plugin/impl/datasource.py b/api/core/plugin/impl/datasource.py index f38ea0555f..4d90685d24 100644 --- a/api/core/plugin/impl/datasource.py +++ b/api/core/plugin/impl/datasource.py @@ -5,9 +5,9 @@ from core.datasource.entities.datasource_entities import ( DatasourceMessage, GetOnlineDocumentPageContentRequest, OnlineDocumentPagesMessage, - OnlineDriverBrowseFilesRequest, - OnlineDriverBrowseFilesResponse, - OnlineDriverDownloadFileRequest, + OnlineDriveBrowseFilesRequest, + OnlineDriveBrowseFilesResponse, + OnlineDriveDownloadFileRequest, WebsiteCrawlMessage, ) from core.plugin.entities.plugin import GenericProviderID, ToolProviderID @@ -194,16 +194,16 @@ class PluginDatasourceManager(BasePluginClient): ) yield from response - def online_driver_browse_files( + def online_drive_browse_files( self, tenant_id: str, user_id: str, datasource_provider: str, datasource_name: str, credentials: dict[str, Any], - request: OnlineDriverBrowseFilesRequest, + request: OnlineDriveBrowseFilesRequest, provider_type: str, - ) -> Generator[OnlineDriverBrowseFilesResponse, None, None]: + ) -> Generator[OnlineDriveBrowseFilesResponse, None, None]: """ Invoke the datasource with the given tenant, user, plugin, provider, name, credentials and parameters. """ @@ -212,8 +212,8 @@ class PluginDatasourceManager(BasePluginClient): response = self._request_with_plugin_daemon_response_stream( "POST", - f"plugin/{tenant_id}/dispatch/datasource/online_driver_browse_files", - OnlineDriverBrowseFilesResponse, + f"plugin/{tenant_id}/dispatch/datasource/online_drive_browse_files", + OnlineDriveBrowseFilesResponse, data={ "user_id": user_id, "data": { @@ -230,14 +230,14 @@ class PluginDatasourceManager(BasePluginClient): ) yield from response - def online_driver_download_file( + def online_drive_download_file( self, tenant_id: str, user_id: str, datasource_provider: str, datasource_name: str, credentials: dict[str, Any], - request: OnlineDriverDownloadFileRequest, + request: OnlineDriveDownloadFileRequest, provider_type: str, ) -> Generator[DatasourceMessage, None, None]: """ @@ -248,7 +248,7 @@ class PluginDatasourceManager(BasePluginClient): response = self._request_with_plugin_daemon_response_stream( "POST", - f"plugin/{tenant_id}/dispatch/datasource/online_driver_download_file", + f"plugin/{tenant_id}/dispatch/datasource/online_drive_download_file", DatasourceMessage, data={ "user_id": user_id,