quivr/backend/modules/knowledge/service/knowledge_service.py
Stan Girard 3c2d83b22f
feat: Update dependencies and remove unnecessary logging statements (#2232)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2024-02-20 16:59:58 -08:00

44 lines
1.3 KiB
Python

from uuid import UUID
from logger import get_logger
from modules.knowledge.dto.inputs import CreateKnowledgeProperties
from modules.knowledge.entity.knowledge import Knowledge
from modules.knowledge.repository.knowledge_interface import KnowledgeInterface
from modules.knowledge.repository.knowledges import Knowledges
logger = get_logger(__name__)
class KnowledgeService:
repository: KnowledgeInterface
def __init__(self):
self.repository = Knowledges()
def add_knowledge(self, knowledge_to_add: CreateKnowledgeProperties):
knowledge = self.repository.insert_knowledge(knowledge_to_add)
return knowledge
def get_all_knowledge(self, brain_id: UUID):
knowledges = self.repository.get_all_knowledge_in_brain(brain_id)
return knowledges
def get_knowledge(self, knowledge_id: UUID) -> Knowledge:
knowledge = self.repository.get_knowledge_by_id(knowledge_id)
return knowledge
def remove_brain_all_knowledge(self, brain_id: UUID) -> None:
self.repository.remove_brain_all_knowledge(brain_id)
logger.info(
f"All knowledge in brain {brain_id} removed successfully from table"
)
def remove_knowledge(self, knowledge_id: UUID):
message = self.repository.remove_knowledge_by_id(knowledge_id)
return message