Spaces:
Sleeping
Sleeping
Download app/controllers/chat_controller.py from Kareman/githubexplorer: direct link, hf CLI and curl.
- Browser
- Download file 767 Bytes
-
https://huggingface.co/spaces/Kareman/githubexplorer/resolve/17e2d86b59ef594faefdc85daab47bac164d1600/app/controllers/chat_controller.py
- Command line
-
hf download hf://spaces/Kareman/githubexplorer@17e2d86b59ef594faefdc85daab47bac164d1600/app/controllers/chat_controller.py
-
curl -L -o chat_controller.py https://huggingface.co/spaces/Kareman/githubexplorer/resolve/17e2d86b59ef594faefdc85daab47bac164d1600/app/controllers/chat_controller.py
767 Bytes
| 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, | |
| ) |