Skip to content

Commit 1a67b54

Browse files
authored
update models for rescuebox , fix chromadb location, fix uninstall (#44)
* move facematch chromadb to appdata automate ollama install for text_summary * update uninstall to remove pre reqs
1 parent 2f45d66 commit 1a67b54

File tree

10 files changed

+35
-25
lines changed

10 files changed

+35
-25
lines changed

RescueBox-Desktop/build/installer.nsh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,20 @@ Function .onInstSuccess
2424
Strcpy "$INSTDIR_DAT" "$INSTDIR\resources\assets\rb_server"
2525
ExpandEnvStrings $0 %COMSPEC%
2626
ExecWait '"$0" /C "msiexec /i $INSTDIR_DAT\winfsp-2.0.23075.msi INSTALLLEVEL=1000 /passive"'
27+
Var /GLOBAL O_LOG
28+
Strcpy "$O_LOG" "$AppData\RescueBox-Desktop\logs\o.log"
29+
ExecWait '"$0" /C "start /min $INSTDIR_DAT\OllamaSetup.exe /verysilent /SP /SUPPRESSMSGBOXES /log=$O_LOG"'
30+
2731
FunctionEnd
2832

2933

3034
Section "Uninstall"
3135
Var /GLOBAL INSTDIR_LOG
3236
Strcpy "$INSTDIR_LOG" "$AppData\RescueBox-Desktop\logs"
33-
37+
MessageBox MB_OK "Uninstall Prereqs"
38+
ExpandEnvStrings $0 %COMSPEC%
39+
ExecWait '"$0" /C "winget uninstall --nowarn --disable-interactivity WinFsp.WinFsp"'
40+
ExecWait '"$0" /C "winget uninstall --nowarn --disable-interactivity ollama.ollama"'
3441
FindWindow $0 "RescueBox-Desktop"
3542
SendMessage $0 ${WM_CLOSE} 0 0
3643
ExecWait '"$0" /k "del/f /q $INSTDIR_LOG\*.log"'

src/face-detection-recognition/face_detection_recognition/database_functions.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import json
66
from dotenv import load_dotenv
77
import os
8+
import platform
9+
from pathlib import Path
810

911
from face_detection_recognition.utils.resource_path import get_config_path
1012

@@ -38,17 +40,15 @@ def __init__(self):
3840
settings = Settings(
3941
anonymized_telemetry=False,
4042
)
43+
db_path = Path.home() / ".rescueBox-desktop" / "facematch"
44+
if platform.system() == "Windows":
45+
appdata = os.environ.get("APPDATA")
46+
db_path = Path(appdata) / "RescueBox-Desktop" / "facematch"
47+
if not db_path.exists():
48+
db_path.mkdir(parents=True, exist_ok=True)
4149
self.client = chromadb.PersistentClient(
4250
settings=settings,
43-
path=os.path.abspath(
44-
os.path.join(
45-
os.getcwd(),
46-
"src",
47-
"face-detection-recognition",
48-
"resources",
49-
"data",
50-
)
51-
),
51+
path=str(db_path),
5252
)
5353

5454
def create_full_collection_name(self, base_name, detector, model, isEnsemble):

src/text-summary/output/story_1.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/text-summary/output/story_2.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/text-summary/output/story_3.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/text-summary/test_output/story_1.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/text-summary/test_output/story_2.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/text-summary/test_output/story_3.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/text-summary/tests/test_model.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
summarize,
77
)
88
from text_summary.summary_prompt import PROMPT
9+
from ollama._types import ListResponse
910

1011

1112
def test_extract_response_after_think():
@@ -18,10 +19,15 @@ def test_extract_response_after_think():
1819
assert extract_response_after_think(text_without_tag) == text_without_tag.strip()
1920

2021

21-
@patch("text_summary.model.ollama.pull")
22-
def test_ensure_model_exists(mock_pull):
22+
@patch("ollama.list")
23+
@patch("ollama.pull")
24+
# @patch.object(ollama.Client, '__init__', return_value=None)
25+
def test_ensure_model_exists(mock_pull, mock_list):
2326
# Test case where model is supported and pull is successful
27+
2428
mock_pull.return_value = MagicMock(status="success")
29+
30+
mock_list.return_value = {"models": [ListResponse.Model(model="gemma3:1b")]}
2531
ensure_model_exists("gemma3:1b") # Should not raise any exception
2632

2733
# Test case where model is not supported
@@ -30,8 +36,8 @@ def test_ensure_model_exists(mock_pull):
3036

3137
# Test case where pull fails
3238
mock_pull.return_value = MagicMock(status="failure")
33-
with pytest.raises(ValueError, match="Failed to pull model 'gemma3:1b':"):
34-
ensure_model_exists("gemma3:1b")
39+
with pytest.raises(ValueError, match="Failed to pull model 'llama3.2:3b'"):
40+
ensure_model_exists("llama3.2:3b")
3541

3642

3743
@patch("text_summary.model.ollama.generate")

src/text-summary/text_summary/model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ def ensure_model_exists(model: str) -> None:
2525
f"Model '{model}' is not supported. Supported models are: {SUPPORTED_MODELS}"
2626
)
2727
try:
28-
response = ollama.pull(model)
29-
except ollama.ResponseError as e:
30-
raise ValueError(e.error)
31-
if response.status != "success":
32-
raise ValueError(f"Failed to pull model '{model}': {response}")
28+
resp = ollama.list()
29+
models = [m.model for m in resp["models"]]
30+
if model not in models:
31+
response = ollama.pull(model)
32+
if response.status != "success":
33+
raise ValueError(f"Failed to pull model '{model}': {response}")
34+
except ValueError as e:
35+
raise ValueError(e)
3336

3437

3538
def summarize(model: str, text: str) -> str:

0 commit comments

Comments
 (0)