Spaces:
Sleeping
Sleeping
enricorampazzo
commited on
Commit
•
e18155f
1
Parent(s):
bd68cde
excluded ollama imports when running in hf
Browse files- repository/intel_npu.py +1 -0
- repository/repository.py +3 -3
repository/intel_npu.py
CHANGED
@@ -43,6 +43,7 @@ class IntelNpuRepository(Repository):
|
|
43 |
input_ids = (self.tokenizer.apply_chat_template(self.get_message_history(), add_generation_prompt=True,
|
44 |
return_tensors="pt")
|
45 |
.to(self.model.device))
|
|
|
46 |
outputs = self.model.generate(input_ids, eos_token_id=self.terminators, do_sample=True, max_new_tokens=2000, cache_position=None)
|
47 |
generated_token_array = outputs[0][len(input_ids[0]):]
|
48 |
generated_tokens = "".join(self.tokenizer.batch_decode(generated_token_array, skip_special_tokens=True))
|
|
|
43 |
input_ids = (self.tokenizer.apply_chat_template(self.get_message_history(), add_generation_prompt=True,
|
44 |
return_tensors="pt")
|
45 |
.to(self.model.device))
|
46 |
+
|
47 |
outputs = self.model.generate(input_ids, eos_token_id=self.terminators, do_sample=True, max_new_tokens=2000, cache_position=None)
|
48 |
generated_token_array = outputs[0][len(input_ids[0]):]
|
49 |
generated_tokens = "".join(self.tokenizer.batch_decode(generated_token_array, skip_special_tokens=True))
|
repository/repository.py
CHANGED
@@ -3,7 +3,7 @@ from utils.env_utils import in_hf
|
|
3 |
|
4 |
if not in_hf():
|
5 |
from repository.intel_npu import IntelNpuRepository
|
6 |
-
from repository.ollama import OllamaRepository
|
7 |
from repository.ondemand import OndemandRepository
|
8 |
from repository.repository_abc import Model
|
9 |
from repository.testing_repo import TestingRepository
|
@@ -13,11 +13,11 @@ def get_repository(implementation: str, model: Model, system_msg: str = None, lo
|
|
13 |
known_implementations = ["ollama", "intel_npu", "testing", "ondemand"]
|
14 |
if not implementation or implementation.lower() not in known_implementations:
|
15 |
raise ValueError(f"Unknown implementation {implementation}. Known implementations: {known_implementations}")
|
16 |
-
if "ollama" == implementation:
|
17 |
-
return OllamaRepository(model, system_msg)
|
18 |
if not in_hf():
|
19 |
if "intel_npu" == implementation:
|
20 |
return IntelNpuRepository(model, system_msg, log_to_file)
|
|
|
|
|
21 |
if "ondemand" == implementation:
|
22 |
return OndemandRepository(model, system_msg, log_to_file)
|
23 |
if "testing" == implementation:
|
|
|
3 |
|
4 |
if not in_hf():
|
5 |
from repository.intel_npu import IntelNpuRepository
|
6 |
+
from repository.ollama import OllamaRepository
|
7 |
from repository.ondemand import OndemandRepository
|
8 |
from repository.repository_abc import Model
|
9 |
from repository.testing_repo import TestingRepository
|
|
|
13 |
known_implementations = ["ollama", "intel_npu", "testing", "ondemand"]
|
14 |
if not implementation or implementation.lower() not in known_implementations:
|
15 |
raise ValueError(f"Unknown implementation {implementation}. Known implementations: {known_implementations}")
|
|
|
|
|
16 |
if not in_hf():
|
17 |
if "intel_npu" == implementation:
|
18 |
return IntelNpuRepository(model, system_msg, log_to_file)
|
19 |
+
if "ollama" == implementation:
|
20 |
+
return OllamaRepository(model, system_msg)
|
21 |
if "ondemand" == implementation:
|
22 |
return OndemandRepository(model, system_msg, log_to_file)
|
23 |
if "testing" == implementation:
|