File size: 2,047 Bytes
d005419
2720b8d
062179e
2720b8d
 
d005419
224e4de
d005419
224e4de
062179e
 
d005419
2720b8d
 
d005419
 
 
2720b8d
 
 
224e4de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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"
            }
        ])