mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-05-16 10:18:12 +00:00
* feat: add Microsoft Entra ID integration - Updated .env-template and settings.py for Microsoft Entra ID configuration. - Enhanced ConnectorsCallback to support SharePoint authentication. - Introduced SharePointAuth and SharePointLoader classes. - Added required dependencies in requirements.txt. * feat: agent templates and seeding premade agents (#1910) * feat: agent templates and seeding premade agents * fix: ensure ObjectId is used for source reference in agent configuration * fix: improve source handling in DatabaseSeeder and update tool config processing * feat: add prompt handling in DatabaseSeeder for agent configuration * Docs premade agents * link to prescraped docs * feat: add template agent retrieval and adopt agent functionality * feat: simplify agent descriptions in premade_agents.yaml added docs --------- Co-authored-by: Pavel <pabin@yandex.ru> Co-authored-by: Alex <a@tushynski.me> * feat: add GitHub access token support and fix file content fetching logic (#2032) * feat: add init for Share Point connector module * chore(deps): bump mermaid from 11.6.0 to 11.12.0 in /frontend Bumps [mermaid](https://github.com/mermaid-js/mermaid) from 11.6.0 to 11.12.0. - [Release notes](https://github.com/mermaid-js/mermaid/releases) - [Commits](https://github.com/mermaid-js/mermaid/compare/mermaid@11.6.0...mermaid@11.12.0) --- updated-dependencies: - dependency-name: mermaid dependency-version: 11.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Feat: Notification section (#2033) * Feature/Notification-section * fix notification ui and add local storage variable to save the state * add notification component to app.tsx * refactor: remove MICROSOFT_REDIRECT_URI and update SharePointAuth to use CONNECTOR_REDIRECT_BASE_URI * feat: Add button to cancel LLM response (#1978) * feat: Add button to cancel LLM response - Replace text area with cancel button when loading. - Add useEffect to change elipsis in cancel button text. - Add new SVG icon for cancel response. - Button colors match Figma designs. * fix: Cancel button UI matches new design - Delete cancel-response svg. - Change previous cancel button to match the new Figma design. - Remove console log in handleCancel function. * fix: Adjust cancel button rounding * feat: Update UI for send button - Add SendArrowIcon component, enables dynamic svg color changes - Replace original icon - Update colors and hover effects * (fix:send-button) minor blink in transition --------- Co-authored-by: Manish Madan <manishmadan321@gmail.com> * feat: add SharePoint integration with session validation and UI components * (feat:oneDrive) file loading for ingestion * feat(oneDrive): shared user files * (feat:oneDrive) rm shared file support, as sharedWithMe is degraded * (feat:sharepoint) shared files for work msa * (feat:sharepoint) retry on auth failure, decorator * (fix) tests/ruff * test: fix sharepoint loader expecting client id --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Abhishek Malviya <abfeb8@gmail.com> Co-authored-by: Siddhant Rai <47355538+siiddhantt@users.noreply.github.com> Co-authored-by: Pavel <pabin@yandex.ru> Co-authored-by: Alex <a@tushynski.me> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mariam Saeed <69825646+Mariam-Saeed@users.noreply.github.com> Co-authored-by: Rahul <rahulgithub96@gmail.com>
141 lines
4.2 KiB
Python
141 lines
4.2 KiB
Python
"""
|
|
Base classes for external knowledge base connectors.
|
|
|
|
This module provides minimal abstract base classes that define the essential
|
|
interface for external knowledge base connectors.
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from application.parser.schema.base import Document
|
|
|
|
|
|
class BaseConnectorAuth(ABC):
|
|
"""
|
|
Abstract base class for connector authentication.
|
|
|
|
Defines the minimal interface that all connector authentication
|
|
implementations must follow.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def get_authorization_url(self, state: Optional[str] = None) -> str:
|
|
"""
|
|
Generate authorization URL for OAuth flows.
|
|
|
|
Args:
|
|
state: Optional state parameter for CSRF protection
|
|
|
|
Returns:
|
|
Authorization URL
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def exchange_code_for_tokens(self, authorization_code: str) -> Dict[str, Any]:
|
|
"""
|
|
Exchange authorization code for access tokens.
|
|
|
|
Args:
|
|
authorization_code: Authorization code from OAuth callback
|
|
|
|
Returns:
|
|
Dictionary containing token information
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def refresh_access_token(self, refresh_token: str) -> Dict[str, Any]:
|
|
"""
|
|
Refresh an expired access token.
|
|
|
|
Args:
|
|
refresh_token: Refresh token
|
|
|
|
Returns:
|
|
Dictionary containing refreshed token information
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def is_token_expired(self, token_info: Dict[str, Any]) -> bool:
|
|
"""
|
|
Check if a token is expired.
|
|
|
|
Args:
|
|
token_info: Token information dictionary
|
|
|
|
Returns:
|
|
True if token is expired, False otherwise
|
|
"""
|
|
pass
|
|
|
|
def sanitize_token_info(self, token_info: Dict[str, Any], **extra_fields) -> Dict[str, Any]:
|
|
"""Extract the fields safe to persist in the session store.
|
|
"""
|
|
return {
|
|
"access_token": token_info.get("access_token"),
|
|
"refresh_token": token_info.get("refresh_token"),
|
|
"token_uri": token_info.get("token_uri"),
|
|
"expiry": token_info.get("expiry"),
|
|
**extra_fields,
|
|
}
|
|
|
|
|
|
class BaseConnectorLoader(ABC):
|
|
"""
|
|
Abstract base class for connector loaders.
|
|
|
|
Defines the minimal interface that all connector loader
|
|
implementations must follow.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def __init__(self, session_token: str):
|
|
"""
|
|
Initialize the connector loader.
|
|
|
|
Args:
|
|
session_token: Authentication session token
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def load_data(self, inputs: Dict[str, Any]) -> List[Document]:
|
|
"""
|
|
Load documents from the external knowledge base.
|
|
|
|
Args:
|
|
inputs: Configuration dictionary containing:
|
|
- file_ids: Optional list of specific file IDs to load
|
|
- folder_ids: Optional list of folder IDs to browse/download
|
|
- limit: Maximum number of items to return
|
|
- list_only: If True, return metadata without content
|
|
- recursive: Whether to recursively process folders
|
|
|
|
Returns:
|
|
List of Document objects
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def download_to_directory(self, local_dir: str, source_config: Dict[str, Any] = None) -> Dict[str, Any]:
|
|
"""
|
|
Download files/folders to a local directory.
|
|
|
|
Args:
|
|
local_dir: Local directory path to download files to
|
|
source_config: Configuration for what to download
|
|
|
|
Returns:
|
|
Dictionary containing download results:
|
|
- files_downloaded: Number of files downloaded
|
|
- directory_path: Path where files were downloaded
|
|
- empty_result: Whether no files were downloaded
|
|
- source_type: Type of connector
|
|
- config_used: Configuration that was used
|
|
- error: Error message if download failed (optional)
|
|
"""
|
|
pass
|