mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-05 12:13:55 +00:00
The backend import package is now docsgpt, the name it will carry on PyPI; application was far too generic to install into anyone's site-packages. git mv plus a mechanical rewrite of every import, dotted string and path reference: 734 Python files, the compose files, Dockerfile, workflows, docs, setup scripts, devcontainer, k8s manifests, vscode config, pytest and coverage config, .gitignore. Behaviour is unchanged. Kept for one release: - A top-level application package whose meta-path finder resolves application.x.y to the already-imported docsgpt.x.y object, so old imports and entry points (celery -A application.app.celery, uvicorn application.asgi:asgi_app) keep working with a FutureWarning. - Celery registers every application.* task name as an alias of its docsgpt.* task on start-up, so messages queued by the previous release still run. The redbeat key prefix moves to redbeat:docsgpt:v2: so schedule entries the previous release wrote are left unread instead of firing twice. The backend image builds from the repository root (docker build -f docsgpt/Dockerfile .) so it can ship the alias package; a root .dockerignore allow-lists docsgpt/ and application/ and keeps caches, local data, .env files, the sample index files and the Dockerfile out. Compose and the image workflows point at the new context.
90 lines
2.8 KiB
Python
90 lines
2.8 KiB
Python
from docsgpt.parser.connectors.confluence.auth import ConfluenceAuth
|
|
from docsgpt.parser.connectors.confluence.loader import ConfluenceLoader
|
|
from docsgpt.parser.connectors.google_drive.auth import GoogleDriveAuth
|
|
from docsgpt.parser.connectors.google_drive.loader import GoogleDriveLoader
|
|
from docsgpt.parser.connectors.share_point.auth import SharePointAuth
|
|
from docsgpt.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
|