Spaces:
Sleeping
Sleeping
| from app.services.context_formatter import ( | |
| ContextFormatter, | |
| ) | |
| from app.services.llm_service import ( | |
| LLMService, | |
| ) | |
| from app.services.retrieval_service import ( | |
| RetrievalService, | |
| ) | |
| class ChatController: | |
| def __init__(self): | |
| self.retrieval = RetrievalService() | |
| self.formatter = ContextFormatter() | |
| self.llm = LLMService() | |
| def ask( | |
| self, | |
| repository_id: str, | |
| question: str, | |
| ): | |
| context = self.retrieval.search( | |
| repository_id=repository_id, | |
| query=question, | |
| ) | |
| formatted_context = self.formatter.format( | |
| context, | |
| ) | |
| return self.llm.chat( | |
| question=question, | |
| context=formatted_context, | |
| ) |