fed8b2eed7
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Backend release / release (push) Has been cancelled
Bandit Security Scan / bandit_scan (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / manifest (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / manifest (push) Has been cancelled
Python linting / ruff (push) Has been cancelled
Run python tests with pytest / Run tests and count coverage (3.12) (push) Has been cancelled
React Widget Build / build (push) Has been cancelled
90 lines
2.8 KiB
Python
90 lines
2.8 KiB
Python
from application.parser.connectors.confluence.auth import ConfluenceAuth
|
|
from application.parser.connectors.confluence.loader import ConfluenceLoader
|
|
from application.parser.connectors.google_drive.auth import GoogleDriveAuth
|
|
from application.parser.connectors.google_drive.loader import GoogleDriveLoader
|
|
from application.parser.connectors.share_point.auth import SharePointAuth
|
|
from application.parser.connectors.share_point.loader import SharePointLoader
|
|
|
|
|
|
class ConnectorCreator:
|
|
"""
|
|
Factory class for creating external knowledge base connectors and auth providers.
|
|
|
|
These are different from remote loaders as they typically require
|
|
authentication and connect to external document storage systems.
|
|
"""
|
|
|
|
connectors = {
|
|
"confluence": ConfluenceLoader,
|
|
"google_drive": GoogleDriveLoader,
|
|
"share_point": SharePointLoader,
|
|
}
|
|
|
|
auth_providers = {
|
|
"confluence": ConfluenceAuth,
|
|
"google_drive": GoogleDriveAuth,
|
|
"share_point": SharePointAuth,
|
|
}
|
|
|
|
@classmethod
|
|
def create_connector(cls, connector_type, *args, **kwargs):
|
|
"""
|
|
Create a connector instance for the specified type.
|
|
|
|
Args:
|
|
connector_type: Type of connector to create (e.g., 'google_drive')
|
|
*args, **kwargs: Arguments to pass to the connector constructor
|
|
|
|
Returns:
|
|
Connector instance
|
|
|
|
Raises:
|
|
ValueError: If connector type is not supported
|
|
"""
|
|
connector_class = cls.connectors.get(connector_type.lower())
|
|
if not connector_class:
|
|
raise ValueError(f"No connector class found for type {connector_type}")
|
|
return connector_class(*args, **kwargs)
|
|
|
|
@classmethod
|
|
def create_auth(cls, connector_type):
|
|
"""
|
|
Create an auth provider instance for the specified connector type.
|
|
|
|
Args:
|
|
connector_type: Type of connector auth to create (e.g., 'google_drive')
|
|
|
|
Returns:
|
|
Auth provider instance
|
|
|
|
Raises:
|
|
ValueError: If connector type is not supported for auth
|
|
"""
|
|
auth_class = cls.auth_providers.get(connector_type.lower())
|
|
if not auth_class:
|
|
raise ValueError(f"No auth class found for type {connector_type}")
|
|
return auth_class()
|
|
|
|
@classmethod
|
|
def get_supported_connectors(cls):
|
|
"""
|
|
Get list of supported connector types.
|
|
|
|
Returns:
|
|
List of supported connector type strings
|
|
"""
|
|
return list(cls.connectors.keys())
|
|
|
|
@classmethod
|
|
def is_supported(cls, connector_type):
|
|
"""
|
|
Check if a connector type is supported.
|
|
|
|
Args:
|
|
connector_type: Type of connector to check
|
|
|
|
Returns:
|
|
True if supported, False otherwise
|
|
"""
|
|
return connector_type.lower() in cls.connectors
|