Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for latest ollama support #1092

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")