DAMHelper / repository /repository.py
enricorampazzo's picture
removing unnecessary dependencies when running in hf, using conditionals to avoid loading npu libraries in hf
2720b8d
raw
history blame
2.05 kB
from pathlib import Path
from utils.env_utils import in_hf
if not in_hf():
from repository.intel_npu import IntelNpuRepository
from repository.ollama import OllamaRepository
from repository.ondemand import OndemandRepository
from repository.repository_abc import Model
from repository.testing_repo import TestingRepository
def get_repository(implementation: str, model: Model, system_msg: str = None, log_to_file: Path = None):
known_implementations = ["ollama", "intel_npu", "testing", "ondemand"]
if not implementation or implementation.lower() not in known_implementations:
raise ValueError(f"Unknown implementation {implementation}. Known implementations: {known_implementations}")
if "ollama" == implementation:
return OllamaRepository(model, system_msg)
if not in_hf():
if "intel_npu" == implementation:
return IntelNpuRepository(model, system_msg, log_to_file)
if "ondemand" == implementation:
return OndemandRepository(model, system_msg, log_to_file)
if "testing" == implementation:
return TestingRepository(prompts_answers=[
{
"role": "assistant",
"content": "OK"
},
{
"role": "assistant",
"content": "What is my full name?\n\nnull\n\nWhat is the nature of the work I need to do?\n\nPest control\n\nIn which community is the work taking place?\n\nJBR\n\nIn which building?\n\nnull\n\nIn which unit/apartment number?\n\nnull\n\nAm I the owner or the tenant?\n\nTenant\n\nIn which date is the work taking place?\n\n12/09/2024\n\nIn which date will the work finish?\n\n12/09/2024\n\nWhat is my contact number?\n\nnull\n\nWhat is the name of the contracting company?\n\nnull\n\nWhat is the contact number of the contracting company?\n\nnull\n\nWhat is the email of the contracting company?\n\nnull\n\nWhat is my email?\n\nnull"
},
{
"role":"assistant",
"content":"pest_control"
}
])