Coverage for src/app/ports/generate_answer_port.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.7.0, created at 2025-04-02 22:46 +0200

1from abc import ABC, abstractmethod 

2from models.context_model import ContextModel 

3from models.question_model import QuestionModel 

4from models.answer_model import AnswerModel 

5from models.prompt_template_model import PromptTemplateModel 

6 

7class GenerateAnswerPort(ABC): 

8 """ 

9 Interface for the generate answer port. 

10 """ 

11 @abstractmethod 

12 def generate_answer(self, question: QuestionModel, context: list[ContextModel], prompt_template: PromptTemplateModel) -> AnswerModel: 

13 """ 

14 Generates an answer based on the given question, context, and prompt template. 

15 

16 Args: 

17 question (QuestionModel): The question model containing the user ID and question text. 

18 context (list[ContextModel]): A list of context models containing the context content. 

19 prompt_template (PromptTemplateModel): The prompt template model containing the prompt template content. 

20 

21 Returns: 

22 AnswerModel: The generated answer model containing the answer text. 

23 """