mirror of
https://github.com/Ladebeze66/llm_ticket3.git
synced 2025-12-13 10:46:51 +01:00
33 lines
911 B
Python
33 lines
911 B
Python
import abc
|
|
from typing import Dict, Any, Optional, List, Tuple
|
|
|
|
class BaseRagflow(abc.ABC):
|
|
"""
|
|
Classe de base pour toute interaction avec une API Ragflow-compatible.
|
|
"""
|
|
def __init__(self, base_url: str, collection: str):
|
|
self.base_url = base_url.rstrip("/")
|
|
self.collection = collection
|
|
|
|
@abc.abstractmethod
|
|
def indexer(self, contenu: str, metadata: Dict[str, Any]) -> Dict[str, Any]:
|
|
"""
|
|
Indexe un contenu dans la collection spécifiée.
|
|
"""
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def rechercher(self, question: str, top_k: int = 5) -> List[Dict[str, Any]]:
|
|
"""
|
|
Recherche des documents similaires à la question spécifiée.
|
|
"""
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def supprimer_collection(self) -> bool:
|
|
"""
|
|
Supprime la collection spécifiée.
|
|
"""
|
|
pass
|
|
|
|
|