Skip to content

Commit

Permalink
Update for latest ollama support (#1092)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin-tech committed Jan 30, 2025
2 parents 81aca1e + cfe125a commit 9ce6716
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 5 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Nightly Testing

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
linux:
name: Nightly Linux
if: github.repository_owner == 'NVIDIA'
uses: ./.github/workflows/test_linux.yml
windows:
name: Nightly Windows
if: github.repository_owner == 'NVIDIA'
uses: ./.github/workflows/test_windows.yml
macos:
name: Nightly MacOS
if: github.repository_owner == 'NVIDIA'
uses: ./.github/workflows/test_macos.yml
package_test:
name: Nightly Packaging
if: github.repository_owner == 'NVIDIA'
uses: ./.github/workflows/remote_package_install.yml
1 change: 1 addition & 0 deletions .github/workflows/remote_package_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 'main'
pull_request:
workflow_dispatch:
workflow_call:

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 'main'
pull_request:
workflow_dispatch:
workflow_call:

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 'main'
pull_request:
workflow_dispatch:
workflow_call:

jobs:
build_macos:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 'main'
pull_request:
workflow_dispatch:
workflow_call:

jobs:
build_windows:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ dependencies = [
"lorem==0.1.1",
"xdg-base-dirs>=6.0.1",
"wn==0.9.5",
"ollama>=0.1.7",
"ollama>=0.4.7",
"tiktoken>=0.7.0"
]

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ python-magic>=0.4.21; sys_platform != "win32"
lorem==0.1.1
xdg-base-dirs>=6.0.1
wn==0.9.5
ollama>=0.1.7
ollama>=0.4.7
tiktoken>=0.7.0
# tests
pytest>=8.0
Expand Down
5 changes: 2 additions & 3 deletions tests/generators/test_ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import ollama
import respx
import httpx
from httpx import ConnectError
from garak.generators.ollama import OllamaGeneratorChat, OllamaGenerator

PINGED_OLLAMA_SERVER = False # Avoid calling the server multiple times if it is not running
Expand All @@ -17,7 +16,7 @@ def ollama_is_running():
try:
ollama.list() # Gets a list of all pulled models. Used as a ping
OLLAMA_SERVER_UP = True
except ConnectError:
except ConnectionError:
OLLAMA_SERVER_UP = False
finally:
PINGED_OLLAMA_SERVER = True
Expand Down Expand Up @@ -141,4 +140,4 @@ def test_error_on_nonexistant_model_chat_mocked(respx_mock):
model_name = "non-existant-model"
gen = OllamaGeneratorChat(model_name)
with pytest.raises(ollama.ResponseError):
gen.generate("This shouldnt work")
gen.generate("This shouldnt work")

0 comments on commit 9ce6716

Please sign in to comment.