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

This commit is contained in:
Harry 2025-06-27 20:11:28 +08:00
parent eee72101f4
commit 1449ed86c4
4 changed files with 36 additions and 36 deletions

View File

@ -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
"""

View File

@ -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

View File

@ -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,

View File

@ -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,