cognee/cognee/infrastructure/context/BaseContextProvider.py
Daniel Molnar b5ebed1f7d
Docstring infrastructure. (#880)
<!-- .github/pull_request_template.md -->

## Description
<!-- Provide a clear description of the changes in this PR -->

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.
2025-05-28 17:47:31 +02:00

33 lines
1.2 KiB
Python

from abc import ABC, abstractmethod
from typing import List
from cognee.infrastructure.engine import DataPoint
class BaseContextProvider(ABC):
"""
Base class for context retrieval strategies.
This class serves as a blueprint for creating different strategies that retrieve context
based on specified entities and a query. Any subclass must implement the `get_context`
method to define how context is retrieved.
"""
@abstractmethod
async def get_context(self, entities: List[DataPoint], query: str) -> str:
"""
Get relevant context based on extracted entities and original query.
This method must be implemented by subclasses to define the logic for retrieving context
relevant to the provided `entities` and `query`. It is an asynchronous method that will
return a string representing the context.
Parameters:
-----------
- entities (List[DataPoint]): A list of data points representing extracted entities
relevant to the query.
- query (str): The original query string used to extract the entities and retrieve
context.
"""
pass