Skip to content

Commit 6ce8141

Browse files
authored
Add support to outlines 1.x (#66)
1 parent 285f3ef commit 6ce8141

38 files changed

Lines changed: 2992 additions & 2854 deletions

.github/workflows/test.yml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ concurrency:
1313
env:
1414
PYTHONUNBUFFERED: "1"
1515
FORCE_COLOR: "1"
16-
UV_SYSTEM_PYTHON: "true"
1716

1817
jobs:
19-
run:
20-
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
18+
unit-tests:
19+
name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }}
2120
runs-on: ${{ matrix.os }}
2221
strategy:
2322
fail-fast: false
@@ -42,10 +41,43 @@ jobs:
4241
with:
4342
version: "latest"
4443

45-
# - name: Run mypy types checking
46-
# run: uv run --python "${{ matrix.python-version }}" task typing
47-
# shell: bash
44+
- name: Install dependencies
45+
run: |
46+
uv sync --group core --group testing --python ${{ matrix.python-version }}
4847
4948
- name: Run unit tests
50-
run: uv run --python "${{ matrix.python-version }}" poe test-cov
49+
run: uv run coverage run -m pytest
50+
shell: bash
51+
52+
min-haystack-version:
53+
name: Test Min Haystack ${{ matrix.min-haystack-version }} - Python ${{ matrix.python-version }} on ${{ matrix.os }}
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
os: [ubuntu-latest, macos-latest]
59+
python-version: ["3.12"]
60+
min-haystack-version: ["2.15.0"]
61+
62+
steps:
63+
- uses: actions/checkout@v5
64+
65+
- name: Set up Python ${{ matrix.python-version }}
66+
uses: actions/setup-python@v6
67+
with:
68+
python-version: ${{ matrix.python-version }}
69+
70+
- name: Install uv
71+
uses: astral-sh/setup-uv@v7
72+
with:
73+
version: "latest"
74+
75+
- name: Install with minimum Haystack version
76+
run: |
77+
uv sync --group core --group testing --python ${{ matrix.python-version }}
78+
uv add "haystack-ai==${{ matrix.min-haystack-version }}"
79+
shell: bash
80+
81+
- name: Run unit tests with minimum Haystack version
82+
run: uv run pytest
5183
shell: bash

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ cython_debug/
157157
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
#.idea/
160+
.idea/
161161

162162
# VSCode
163163
.vscode/

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ This library currently supports the following generators:
5454
### JSON Generation
5555

5656
```python
57-
>>> from enum import Enum
5857
>>> from pydantic import BaseModel
5958
>>> from outlines_haystack.generators.transformers import TransformersJSONGenerator
6059

@@ -66,11 +65,10 @@ This library currently supports the following generators:
6665
... model_name="microsoft/Phi-3-mini-4k-instruct",
6766
... schema_object=User,
6867
... device="cuda",
69-
... sampling_algorithm_kwargs={"temperature": 0.5},
7068
... )
7169
>>> generator.warm_up()
7270
>>> generator.run(prompt="Create a user profile with the fields name, last_name")
73-
{'structured_replies': [{'name': 'John', 'last_name': 'Doe'}]}
71+
{'structured_replies': ['{"name": "John", "last_name": "Doe"}']}
7472
```
7573

7674
### Choice Generation
@@ -82,7 +80,6 @@ This library currently supports the following generators:
8280
... model_name="microsoft/Phi-3-mini-4k-instruct",
8381
... choices=["Positive", "Negative"],
8482
... device="cuda",
85-
... sampling_algorithm_kwargs={"temperature": 0.5},
8683
... )
8784
>>> generator.warm_up()
8885
>>> generator.run(prompt="Classify the following statement: 'I love pizza'")
@@ -101,11 +98,10 @@ This library currently supports the following generators:
10198
>>> generator = TransformersTextGenerator(
10299
... model_name="microsoft/Phi-3-mini-4k-instruct",
103100
... device="cuda",
104-
... sampling_algorithm_kwargs={"temperature": 0.5},
105101
... )
106102
>>> generator.warm_up()
107103
>>> generator.run(prompt="What is the capital of Italy?")
108-
{'replies': ['\n\n# Answer\nThe capital of Italy is Rome.']}
104+
{'replies': ['The capital of Italy is Rome.']}
109105
```
110106

111107
## License

0 commit comments

Comments
 (0)