Skip to main content

RAGTask

GenerativeTask
DashAI.back.tasks.RAGTask

Class for RAG Task.

Here you can change the methods provided by class Task.

Methods

prepare_for_task(self, input: List[DashAI.back.dependencies.database.models.ProcessData], history: Optional[List[Tuple[str, str]]] = None) -> list[dict[str, str]]

Defined on RAGTask

Prepare the input by including the history.

Parameters

input : str
The current input to be processed. E.g.: ["Tell me a joke."]
history : Optional[List[Tuple[str, str]]], optional
The history of previous inputs and outputs, by default None. E.g.: [("Hello!", "Hello! How can I assist you today?")]

Returns

str
The input prepared with the history to be used by the model. E.g.: [{"role": "user", "content": "Hello!"}, {"role": "assistant", "content": "Hello! How can I assist you today?"}, {"role": "user", "content": "Tell me a joke."}]

prepare_input_for_database(self, input: List[str], **kwargs: Any) -> List[Tuple[str, str]]

Defined on RAGTask

Prepare the input for the database.

Parameters

input : str
The input to be prepared.

Returns

List[Tuple[str, str]]
Input with the new types as a list of tuples containing the data and its type

process_input_from_database(self, input: List[DashAI.back.dependencies.database.models.ProcessData], **kwargs: Any) -> List[DashAI.back.dependencies.database.models.ProcessData]

Defined on RAGTask

Process the input from the database.

Parameters

input : list[str]
The input data to be processed.

Returns

list[str]
The processed input data.

process_output(self, output: DashAI.back.models.RAG.RAG_pipeline.RAGGenerationOutput, **kwargs: Any) -> List[Tuple[str, str]]

Defined on RAGTask

Process the output of a generative model.

process_output_from_database(self, output: List[DashAI.back.dependencies.database.models.ProcessData], **kwargs: Any) -> List[DashAI.back.dependencies.database.models.ProcessData]

Defined on RAGTask

Process the output from the database.

Parameters

output : list[str]
The output data to be processed.

Returns

list[str]
The processed output data.

get_metadata(cls) -> Dict[str, Any]

Defined on BaseGenerativeTask

Return serialisable metadata for the current generative task.

Returns

Dict[str, Any]
Dictionary with keys "inputs" and "outputs".