feat: rename online driver to online drive and update related classes and methods :)

feat/r2
Harry 11 months ago
parent eee72101f4
commit 1449ed86c4

@ -26,7 +26,7 @@ class DatasourceProviderType(enum.StrEnum):
ONLINE_DOCUMENT = "online_document" ONLINE_DOCUMENT = "online_document"
LOCAL_FILE = "local_file" LOCAL_FILE = "local_file"
WEBSITE_CRAWL = "website_crawl" WEBSITE_CRAWL = "website_crawl"
ONLINE_DRIVER = "online_driver" ONLINE_DRIVE = "online_drive"
@classmethod @classmethod
def value_of(cls, value: str) -> "DatasourceProviderType": def value_of(cls, value: str) -> "DatasourceProviderType":
@ -311,7 +311,7 @@ class DatasourceMessage(ToolInvokeMessage):
######################### #########################
class OnlineDriverFile(BaseModel): class OnlineDriveFile(BaseModel):
""" """
Online driver file Online driver file
""" """
@ -320,17 +320,17 @@ class OnlineDriverFile(BaseModel):
size: int = Field(..., description="The size of the file") size: int = Field(..., description="The size of the file")
class OnlineDriverFileBucket(BaseModel): class OnlineDriveFileBucket(BaseModel):
""" """
Online driver file bucket Online driver file bucket
""" """
bucket: Optional[str] = Field(None, description="The bucket of the file") 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") is_truncated: bool = Field(False, description="Whether the bucket has more files")
class OnlineDriverBrowseFilesRequest(BaseModel): class OnlineDriveBrowseFilesRequest(BaseModel):
""" """
Get online driver file list request 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 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 Get online driver file
""" """

@ -6,14 +6,14 @@ from core.datasource.entities.datasource_entities import (
DatasourceEntity, DatasourceEntity,
DatasourceMessage, DatasourceMessage,
DatasourceProviderType, DatasourceProviderType,
OnlineDriverBrowseFilesRequest, OnlineDriveBrowseFilesRequest,
OnlineDriverBrowseFilesResponse, OnlineDriveBrowseFilesResponse,
OnlineDriverDownloadFileRequest, OnlineDriveDownloadFileRequest,
) )
from core.plugin.impl.datasource import PluginDatasourceManager from core.plugin.impl.datasource import PluginDatasourceManager
class OnlineDriverDatasourcePlugin(DatasourcePlugin): class OnlineDriveDatasourcePlugin(DatasourcePlugin):
tenant_id: str tenant_id: str
icon: str icon: str
plugin_unique_identifier: str plugin_unique_identifier: str
@ -33,15 +33,15 @@ class OnlineDriverDatasourcePlugin(DatasourcePlugin):
self.icon = icon self.icon = icon
self.plugin_unique_identifier = plugin_unique_identifier self.plugin_unique_identifier = plugin_unique_identifier
def online_driver_browse_files( def online_drive_browse_files(
self, self,
user_id: str, user_id: str,
request: OnlineDriverBrowseFilesRequest, request: OnlineDriveBrowseFilesRequest,
provider_type: str, provider_type: str,
) -> Generator[OnlineDriverBrowseFilesResponse, None, None]: ) -> Generator[OnlineDriveBrowseFilesResponse, None, None]:
manager = PluginDatasourceManager() manager = PluginDatasourceManager()
return manager.online_driver_browse_files( return manager.online_drive_browse_files(
tenant_id=self.tenant_id, tenant_id=self.tenant_id,
user_id=user_id, user_id=user_id,
datasource_provider=self.entity.identity.provider, datasource_provider=self.entity.identity.provider,
@ -51,15 +51,15 @@ class OnlineDriverDatasourcePlugin(DatasourcePlugin):
provider_type=provider_type, provider_type=provider_type,
) )
def online_driver_download_file( def online_drive_download_file(
self, self,
user_id: str, user_id: str,
request: OnlineDriverDownloadFileRequest, request: OnlineDriveDownloadFileRequest,
provider_type: str, provider_type: str,
) -> Generator[DatasourceMessage, None, None]: ) -> Generator[DatasourceMessage, None, None]:
manager = PluginDatasourceManager() manager = PluginDatasourceManager()
return manager.online_driver_download_file( return manager.online_drive_download_file(
tenant_id=self.tenant_id, tenant_id=self.tenant_id,
user_id=user_id, user_id=user_id,
datasource_provider=self.entity.identity.provider, datasource_provider=self.entity.identity.provider,
@ -70,4 +70,4 @@ class OnlineDriverDatasourcePlugin(DatasourcePlugin):
) )
def datasource_provider_type(self) -> str: def datasource_provider_type(self) -> str:
return DatasourceProviderType.ONLINE_DRIVER return DatasourceProviderType.ONLINE_DRIVE

@ -1,10 +1,10 @@
from core.datasource.__base.datasource_provider import DatasourcePluginProviderController from core.datasource.__base.datasource_provider import DatasourcePluginProviderController
from core.datasource.__base.datasource_runtime import DatasourceRuntime from core.datasource.__base.datasource_runtime import DatasourceRuntime
from core.datasource.entities.datasource_entities import DatasourceProviderEntityWithPlugin, DatasourceProviderType 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 entity: DatasourceProviderEntityWithPlugin
plugin_id: str plugin_id: str
plugin_unique_identifier: str plugin_unique_identifier: str
@ -21,9 +21,9 @@ class OnlineDriverDatasourcePluginProviderController(DatasourcePluginProviderCon
""" """
returns the type of the provider 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 return datasource with given name
""" """
@ -39,7 +39,7 @@ class OnlineDriverDatasourcePluginProviderController(DatasourcePluginProviderCon
if not datasource_entity: if not datasource_entity:
raise ValueError(f"Datasource with name {datasource_name} not found") raise ValueError(f"Datasource with name {datasource_name} not found")
return OnlineDriverDatasourcePlugin( return OnlineDriveDatasourcePlugin(
entity=datasource_entity, entity=datasource_entity,
runtime=DatasourceRuntime(tenant_id=self.tenant_id), runtime=DatasourceRuntime(tenant_id=self.tenant_id),
tenant_id=self.tenant_id, tenant_id=self.tenant_id,

@ -5,9 +5,9 @@ from core.datasource.entities.datasource_entities import (
DatasourceMessage, DatasourceMessage,
GetOnlineDocumentPageContentRequest, GetOnlineDocumentPageContentRequest,
OnlineDocumentPagesMessage, OnlineDocumentPagesMessage,
OnlineDriverBrowseFilesRequest, OnlineDriveBrowseFilesRequest,
OnlineDriverBrowseFilesResponse, OnlineDriveBrowseFilesResponse,
OnlineDriverDownloadFileRequest, OnlineDriveDownloadFileRequest,
WebsiteCrawlMessage, WebsiteCrawlMessage,
) )
from core.plugin.entities.plugin import GenericProviderID, ToolProviderID from core.plugin.entities.plugin import GenericProviderID, ToolProviderID
@ -194,16 +194,16 @@ class PluginDatasourceManager(BasePluginClient):
) )
yield from response yield from response
def online_driver_browse_files( def online_drive_browse_files(
self, self,
tenant_id: str, tenant_id: str,
user_id: str, user_id: str,
datasource_provider: str, datasource_provider: str,
datasource_name: str, datasource_name: str,
credentials: dict[str, Any], credentials: dict[str, Any],
request: OnlineDriverBrowseFilesRequest, request: OnlineDriveBrowseFilesRequest,
provider_type: str, 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. 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( response = self._request_with_plugin_daemon_response_stream(
"POST", "POST",
f"plugin/{tenant_id}/dispatch/datasource/online_driver_browse_files", f"plugin/{tenant_id}/dispatch/datasource/online_drive_browse_files",
OnlineDriverBrowseFilesResponse, OnlineDriveBrowseFilesResponse,
data={ data={
"user_id": user_id, "user_id": user_id,
"data": { "data": {
@ -230,14 +230,14 @@ class PluginDatasourceManager(BasePluginClient):
) )
yield from response yield from response
def online_driver_download_file( def online_drive_download_file(
self, self,
tenant_id: str, tenant_id: str,
user_id: str, user_id: str,
datasource_provider: str, datasource_provider: str,
datasource_name: str, datasource_name: str,
credentials: dict[str, Any], credentials: dict[str, Any],
request: OnlineDriverDownloadFileRequest, request: OnlineDriveDownloadFileRequest,
provider_type: str, provider_type: str,
) -> Generator[DatasourceMessage, None, None]: ) -> Generator[DatasourceMessage, None, None]:
""" """
@ -248,7 +248,7 @@ class PluginDatasourceManager(BasePluginClient):
response = self._request_with_plugin_daemon_response_stream( response = self._request_with_plugin_daemon_response_stream(
"POST", "POST",
f"plugin/{tenant_id}/dispatch/datasource/online_driver_download_file", f"plugin/{tenant_id}/dispatch/datasource/online_drive_download_file",
DatasourceMessage, DatasourceMessage,
data={ data={
"user_id": user_id, "user_id": user_id,

Loading…
Cancel
Save