Skip to content

Commit a776606

Browse files
Generic LLM Interface (#13)
* new generic llm interface * ollama refactor * minor fixes * fix ollama num_ctx * fix invalid parameters in openai * remove redundant and unused code * update poetry and build dependencies * update depracated poetry
1 parent 02f08ba commit a776606

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4283
-7564
lines changed

.github/_typos.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[default.extend-identifiers]
2-
arange = "arange" # np.arange
2+
arange = "arange" # np.arange
3+
4+
[files]
5+
extend-exclude = ["*.ipynb"]

.github/workflows/pages.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ on:
88
branches: [main]
99

1010
env:
11-
POETRY_VERSION: "1.8.3"
12-
PYTHON_VERSION: "3.11"
11+
POETRY_VERSION: "2.0.1"
12+
PYTHON_VERSION: "3.12"
1313

1414
jobs:
1515
deploy:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
- name: Install poetry
2020
run: pipx install poetry==${POETRY_VERSION}
21-
- uses: actions/setup-python@v4
21+
- uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ env.PYTHON_VERSION }}
2424
cache: poetry
2525
- name: Install Nox and doc dependencies
26-
run: poetry install --only nox,docs
26+
run: poetry sync --only nox,docs
2727
- name: Publish Docs
2828
run: poetry run nox -s docs_github_pages

.github/workflows/python.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@ on:
88
branches: ["main"]
99

1010
env:
11-
POETRY_VERSION: "1.8.3"
11+
POETRY_VERSION: "2.0.1"
1212
PYTHON_VERSION: "3.12"
1313

1414
jobs:
1515
test:
16-
runs-on: ubuntu-22.04
16+
runs-on: ubuntu-24.04
1717
strategy:
1818
matrix:
1919
python-version: ["3.11", "3.12" ]
2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
- name: Install poetry
2323
run: pipx install poetry==${POETRY_VERSION}
2424
- name: Install poetry-plugin-export
2525
run: pipx inject poetry poetry-plugin-export
2626
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
cache: poetry
3131
- name: Install Nox
32-
run: poetry install --only nox
32+
run: poetry sync --only nox
3333
- name: Test with Nox
3434
env:
3535
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
3636
OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }}
37-
SKIP_TESTS_NAAI: "tests/llm tests/local_llm tests/data"
37+
SKIP_TESTS_NAAI: "tests/llm tests/data"
3838
run: poetry run nox -s test-${{ matrix.python-version }}
3939
quality:
40-
runs-on: ubuntu-22.04
40+
runs-on: ubuntu-24.04
4141
strategy:
4242
matrix:
4343
job:
@@ -46,27 +46,27 @@ jobs:
4646
- { nox-session: type_check, poetry-groups: "type_check,main,test" }
4747
- { nox-session: docs, poetry-groups: "docs" }
4848
steps:
49-
- uses: actions/checkout@v3
49+
- uses: actions/checkout@v4
5050
- name: Install poetry
5151
run: pipx install poetry==${POETRY_VERSION}
5252
- name: Set up Python
53-
uses: actions/setup-python@v4
53+
uses: actions/setup-python@v5
5454
with:
5555
python-version: ${{ env.PYTHON_VERSION }}
5656
cache: poetry
5757
- name: Install Nox and group dependencies
58-
run: poetry install --all-extras
58+
run: poetry sync --all-extras
5959
- name: Test with Nox
6060
run: poetry run nox -s ${{ matrix.job.nox-session }}
6161
poetry-check:
62-
runs-on: ubuntu-22.04
62+
runs-on: ubuntu-24.04
6363
steps:
64-
- uses: actions/checkout@v3
64+
- uses: actions/checkout@v4
6565
- name: Install poetry
6666
run: pipx install poetry==${POETRY_VERSION}
6767
- name: Set up Python
68-
uses: actions/setup-python@v4
68+
uses: actions/setup-python@v5
6969
with:
7070
python-version: ${{ env.PYTHON_VERSION }}
7171
- name: Validate Poetry Configuration
72-
run: poetry check --lock
72+
run: poetry check --lock --strict

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
},
1818
"python.testing.unittestEnabled": false,
1919
"python.testing.pytestEnabled": true,
20-
"python.testing.pytestArgs": [],
20+
"python.testing.pytestArgs": ["-s"],
2121
"markdown.extension.orderedList.marker": "one",
2222
}

README.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ Requires: Python 3.11, or 3.12
2424
Install the entire package from [PyPI](https://pypi.org/project/not-again-ai/) with:
2525

2626
```bash
27-
$ pip install not_again_ai[llm,local_llm,statistics,viz]
27+
$ pip install not_again_ai[data,llm,statistics,viz]
2828
```
2929

30-
Note that local LLM requires separate installations and will not work out of the box due to how hardware dependent it is. Be sure to check the [notebooks](notebooks/local_llm/) for more details.
31-
3230
The package is split into subpackages, so you can install only the parts you need.
3331

3432
### Base
@@ -49,16 +47,7 @@ The package is split into subpackages, so you can install only the parts you nee
4947
1. Using AOAI requires using Entra ID authentication. See https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/managed-identity for how to set this up for your AOAI deployment.
5048
* Requires the correct role assigned to your user account and being signed into the Azure CLI.
5149
1. (Optional) Set the `AZURE_OPENAI_ENDPOINT` environment variable.
52-
1. Setup GitHub Models
53-
1. Get a Personal Access Token from https://github.com/settings/tokens and set the `GITHUB_TOKEN` environment variable. The token does not need any permissions.
54-
1. Check the [Github Marketplace](https://github.com/marketplace/models) to see which models are available.
55-
56-
57-
### Local LLM
58-
1. `pip install not_again_ai[llm,local_llm]`
59-
1. Some HuggingFace transformers tokenizers are gated behind access requests. If you wish to use these, you will need to request access from HuggingFace on the model card.
60-
* Then set the `HF_TOKEN` environment variable to your HuggingFace API token which can be found here: https://huggingface.co/settings/tokens
61-
1. If you wish to use Ollama:
50+
1. If you wish to use Ollama:
6251
1. Follow the instructions at https://github.com/ollama/ollama to install Ollama for your system.
6352
1. (Optional) [Add Ollama as a startup service (recommended)](https://github.com/ollama/ollama/blob/main/docs/linux.md#adding-ollama-as-a-startup-service-recommended)
6453
1. (Optional) To make the Ollama service accessible on your local network from a Linux server, add the following to the `/etc/systemd/system/ollama.service` file which will make Ollama available at `http://<local_address>:11434`:
@@ -68,7 +57,6 @@ The package is split into subpackages, so you can install only the parts you nee
6857
Environment="OLLAMA_HOST=0.0.0.0"
6958
```
7059
1. It is recommended to always have the latest version of Ollama. To update Ollama check the [docs](https://github.com/ollama/ollama/blob/main/docs/). The command for Linux is: `curl -fsSL https://ollama.com/install.sh | sh`
71-
1. HuggingFace transformers and other requirements are hardware dependent so for providers other than Ollama, this only installs some generic dependencies. Check the [notebooks](notebooks/local_llm/) for more details on what is available and how to install it.
7260

7361

7462
### Statistics
@@ -112,10 +100,8 @@ $ poetry update
112100

113101
To install all dependencies (with all extra dependencies) into an isolated virtual environment:
114102

115-
> Append `--sync` to uninstall dependencies that are no longer in use from the virtual environment.
116-
117103
```bash
118-
$ poetry install --all-extras
104+
$ poetry sync --all-extras
119105
```
120106

121107
To [activate](https://python-poetry.org/docs/basic-usage#activating-the-virtual-environment) the
@@ -171,7 +157,7 @@ Automated code quality checks are performed using
171157
environments and run commands based on [`noxfile.py`](./noxfile.py) for unit testing, PEP 8 style
172158
guide checking, type checking and documentation generation.
173159

174-
> Note: `nox` is installed into the virtual environment automatically by the `poetry install`
160+
> Note: `nox` is installed into the virtual environment automatically by the `poetry sync`
175161
> command above. Run `poetry shell` to activate the virtual environment.
176162

177163
To run all default sessions:

0 commit comments

Comments
 (0)