From 32c02662e4ecc24b605be0021d2c3b8c27cb6b15 Mon Sep 17 00:00:00 2001 From: Michele Pangrazzi Date: Fri, 24 Jan 2025 17:58:48 +0100 Subject: [PATCH] Fix run_api args ; Update docstrings --- .../server/utils/base_pipeline_wrapper.py | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/hayhooks/server/utils/base_pipeline_wrapper.py b/src/hayhooks/server/utils/base_pipeline_wrapper.py index 87a3b75..85d6525 100644 --- a/src/hayhooks/server/utils/base_pipeline_wrapper.py +++ b/src/hayhooks/server/utils/base_pipeline_wrapper.py @@ -9,38 +9,39 @@ def __init__(self): @abstractmethod def setup(self) -> None: """ - Setup the pipeline. + Initialize and configure the pipeline. - This method should be called before using the pipeline. + This method will be called before any pipeline operations. + It should initialize `self.pipeline` with the appropriate pipeline. + + Pipelines can be loaded from YAML or provided directly as code. """ pass @abstractmethod - def run_api(self, urls: List[str], question: str) -> dict: + def run_api(self): """ - Run the pipeline in API mode. + Execute the pipeline in API mode. - Args: - urls: List of URLs to fetch content from - question: Question to be answered + This method provides a generic interface for running the pipeline + with implementation-specific parameters. - Returns: - dict: Pipeline execution results + An API endpoint will call this method and will use dynamically created + pydantic models for request and response validation. """ pass @abstractmethod - def run_chat(self, user_message: str, model_id: str, messages: List[dict], body: dict) -> dict: + def run_chat(self, model_id: str, messages: List[dict], body: dict): """ - Run the pipeline in chat mode. + This method is called when a user sends an OpenAI-compatible chat completion request. - Args: - user_message: Message from the user - model_id: ID of the model to use - messages: List of previous messages - body: Additional request body parameters + This method handles conversational interactions with the pipeline, + maintaining context and processing chat-specific parameters. - Returns: - dict: Pipeline execution results + Args: + model_id: The model (Haystack pipeline) to run + messages: List of previous conversation messages for context + body: Additional parameters and configuration options """ pass