Skip to content

Commit dfb179f

Browse files
authored
Merge branch 'eth-sri:main' into inline_probabilities
2 parents 77e5e4f + ef703b8 commit dfb179f

File tree

380 files changed

+43039
-22110
lines changed

Some content is hidden

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

380 files changed

+43039
-22110
lines changed

.github/workflows/lmql-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
source env/bin/activate
3838
echo "VIRTUAL ENV:" $VIRTUAL_ENV
3939
- name: Install Dependencies
40-
run: source env/bin/activate && pip install -e '.[hf]' && pip install langchain
40+
run: source env/bin/activate && pip install -e '.[hf,tests]' && pip install langchain
4141
- name: Run Tests
4242
env:
4343
OPENAI_API_KEY: ${{ secrets.LMQL_CI_OPENAI_KEY }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test Release to test.pypi.org
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish'
8+
required: true
9+
10+
11+
jobs:
12+
release-test-wheel:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Setup Fresh Virtual Environment
17+
run: |
18+
pip install --upgrade pip
19+
python3.10 -m venv env
20+
export PATH=$PATH:/home/docker/.local/bin
21+
source env/bin/activate
22+
echo "VIRTUAL ENV:" $VIRTUAL_ENV
23+
- name: Install Packaging Dependencies
24+
run: pip install build twine
25+
- name: Package
26+
env:
27+
VERSION: ${{ github.event.inputs.version }}
28+
run: bash scripts/wheel.sh $(echo $VERSION | sed 's/^refs\/tags\/v//')
29+
- name: Publish
30+
env:
31+
TWINE_USERNAME: __token__
32+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
33+
VERSION: ${{ github.event.inputs.version }}
34+
run: bash scripts/pypi-release.sh lmql-$(echo $VERSION | sed 's/^refs\/tags\/v//')

.github/workflows/lmql-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
source env/bin/activate
3434
echo "VIRTUAL ENV:" $VIRTUAL_ENV
3535
- name: Install Dependencies
36-
run: source env/bin/activate && pip install -e '.[hf]' && pip install langchain
36+
run: source env/bin/activate && pip install -e '.[hf,tests]' && pip install langchain
3737
- name: Run Tests
3838
env:
3939
OPENAI_API_KEY: ${{ secrets.LMQL_CI_OPENAI_KEY }}

.github/workflows/lmql-web.yml

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Browser Build & Web Deploy
22

33
on:
44
push:
5-
branches: [ "main", "next"]
5+
branches: [ "main" ]
66

77
jobs:
88
build:
@@ -11,31 +11,24 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v3
14-
- name: Sphinx Build
15-
# You may pin to the exact commit or the version.
16-
# uses: ammaraskar/sphinx-action@8b4f60114d7fd1faeba1a712269168508d4750d2
17-
uses: ammaraskar/sphinx-action@0.4
18-
with:
19-
pre-build-command: "apt-get update -y && apt-get install -y pandoc"
20-
- name: Clean permissions
21-
# You may pin to the exact commit or the version.
22-
# uses: main-quest/actions.clean-permissions@c8603ac2fddde3426082da840e0baff43a6505af
23-
uses: main-quest/actions.clean-permissions@v1.0.4
24-
- uses: actions/upload-artifact@v1
25-
with:
26-
name: DocumentationHTML
27-
path: docs/build/html/
2814
- name: Prepare Node.js environment
2915
uses: actions/setup-node@v3
3016
with:
31-
node-version: 19.x
32-
- uses: actions/download-artifact@v3
33-
name: Restore docs/build/html
34-
with:
35-
name: DocumentationHTML
36-
path: docs/build/html/
37-
- name: Build web/ and In-Browser LMQL Distribution
38-
run: cd web && bash deploy.sh
17+
node-version: 20.x
18+
cache: 'npm'
19+
# cached dependencies for node
20+
- name: Cache node modules
21+
uses: actions/cache@v3
22+
with:
23+
path: |
24+
docs/node_modules
25+
scripts/browser-build/node_modules
26+
src/lmql/ui/live/node_modules
27+
src/lmql/ui/playground/node_modules
28+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
29+
30+
- name: Build website and In-Browser LMQL Distribution
31+
run: cd scripts && bash deploy-web.sh
3932
- uses: actions/upload-artifact@master
4033
with:
4134
name: lmql-web-payload
@@ -61,27 +54,3 @@ jobs:
6154
folder: web-deploy
6255
branch: web
6356
64-
deploy-next:
65-
name: Deploy Next Playground
66-
runs-on: ubuntu-latest
67-
needs: [build]
68-
if:
69-
contains('
70-
refs/heads/next
71-
', github.ref)
72-
steps:
73-
- uses: actions/checkout@master
74-
- uses: actions/download-artifact@master
75-
with:
76-
name: lmql-web-payload
77-
path: web-deploy
78-
- run: cp -r web-deploy/playground/* web-deploy/
79-
- name: Deploy to web branch
80-
uses: JamesIves/github-pages-deploy-action@v4
81-
with:
82-
repository-name: lmql-lang/lmql-next
83-
ssh-key: ${{ secrets.LMQL_LANG_NEXT_PUSH_KEY }}
84-
folder: web-deploy
85-
branch: web
86-
87-

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ web/index.html
1212
**/node_modules/*
1313
**/.DS_Store
1414

15+
# Nix build output
16+
result
1517

1618
# Created by https://www.toptal.com/developers/gitignore/api/python,jupyternotebooks
1719
# Edit at https://www.toptal.com/developers/gitignore?templates=python,jupyternotebooks
@@ -47,7 +49,6 @@ dist/
4749
downloads/
4850
eggs/
4951
.eggs/
50-
lib/
5152
lib64/
5253
parts/
5354
sdist/

CONTRIBUTING.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Contributing
2+
3+
Thank you so much for your interest in contributing to LMQL, we are very happy to have you here! We
4+
actively encourage any form of contribution, and are convinced that LMQL should be a community-driven
5+
project.
6+
7+
## Pull Request Process
8+
9+
1. **Reach Out** If you are planning to implement a new feature (not just a bugfix), please open an issue first or come and talk to the team in our [community Discord](https://discord.gg/7eJP4fcyNT) (#dev channel). In general we are very open to new and
10+
experimental ideas, but we want to make sure that the feature is in line with the overall goals of the project and that it is not already being worked on.
11+
2. **Test Well** Please make sure that your code is well-tested. For this also see the 'Testing' section below.
12+
3. **Import Defensively** Please make sure your code uses defensive imports, i.e. imports that do not fail if a dependency is not installed. For example, if you are using the `transformers` library, you should use `try/except` blocks to catch the `ModuleNotFoundError` that is raised if the library is not installed. This is important because we want to make sure that LMQL can be installed without all dependencies, and that the user is only required to install the dependencies that are actually needed for their use case.
13+
4. **Document Your Changes** If your contributions or feature requires new forms of configuration or syntax, please make sure to also provide a documentation chapter for it. You can find the MarkDown-based documentation in the `docs/` directory. A script for building and previewing the documentation is provided in `scripts/serve-all.py` (also serves the website and browser playground).
14+
15+
## Testing
16+
17+
**General Testing** For general testing, please make sure that your code is compatible with multiple backends, e.g. if possible try to test with `transformers` models, OpenAI models and `llama.cpp`. LMQL is designed as a vendor-agnostic language, which means all features should be available across all backends. If you do not have the hardware to test changes with multiple backends, please make sure to ask a team member to run the tests for you, before merging your pull request.
18+
19+
**Dependency Changes/Updates** After adding new dependencies, `scripts/flake.d/poetry.lock` needs to be updated. This can be done by running `(cd scripts/flake.d && exec poetry lock --no-update)` (if you run Nix, `nix develop .#minimal` will put you in a shell with the `poetry` command available, even if the `poetry.lock`, `pyproject.cfg`, and other related files are currently broken). If you are able, please also check that the Nix build works after making dependency changes; if you're not in a position to do this, please feel encouraged to request a hand on Discord.
20+
21+
**Running Test Suites** The repository contains a number of test suites in the `src/lmql/tests/` directory. To run all
22+
tests simply run `python src/lmql/tests/all.py`. Note that for some tests you need to configure an
23+
OpenAI API key according to the instructions in [documentation](https://lmql.ai/docs/models/openai.html).
24+
We are working to remove the external dependency on the OpenAI API, but for now it is still required
25+
for some tests. If you cannot get an API key, you can ask one of the core maintainers to run the
26+
tests for your, once your pull request is ready.
27+
28+
**Adding Tests** You are also invited to add new tests in the form of a new `test_*.py` file in the `src/lmql/tests/`
29+
directory. For an example of how to write tests, please see the e.g. `https://github.com/eth-sri/lmql/blob/main/src/lmql/tests/test_functions.py`.
30+
As demonstrated by this file, also try to implement your tests using `lmql.model("random", seed=<SEED>)` to make sure
31+
your test code can be run without actually using an LLM or external API, and that it can be re-run
32+
deterministically.
33+
34+
**[Optional] Web Build Testing:** If you are working on a feature that is available in the web playground of LMQL (e.g. also works with API-based (OpenAI) models only), you can also test the web build with `scripts/serve-all.py`, by typing `bb` for browser build into the script's prompt. This will build and serve the WebAssembly/Pyodide version of LMQL on `http://localhost:8081/playground/`. Please see `scripts/deploy-web.sh` for the build process and requirements of the web playground, which may require you to install additional dependencies.
35+
36+
## Licensing
37+
38+
By contributing to LMQL you agree to license your contributions under the terms of
39+
the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) as included in the [LICENSE](./LICENSE) file.
40+
41+
## Code of Conduct
42+
43+
### Our Pledge
44+
45+
In the interest of fostering an open and welcoming environment, we as
46+
contributors and maintainers pledge to making participation in our project and
47+
our community a harassment-free experience for everyone, regardless of age, body
48+
size, disability, ethnicity, gender identity and expression, level of experience,
49+
nationality, personal appearance, race, religion, or sexual identity and
50+
orientation.
51+
52+
### Our Standards
53+
54+
Examples of behavior that contributes to creating a positive environment
55+
include:
56+
57+
* Using welcoming and inclusive language
58+
* Being respectful of differing viewpoints and experiences
59+
* Gracefully accepting constructive criticism
60+
* Focusing on what is best for the community
61+
* Showing empathy towards other community members
62+
63+
Examples of unacceptable behavior by participants include:
64+
65+
* The use of sexualized language or imagery and unwelcome sexual attention or
66+
advances
67+
* Trolling, insulting/derogatory comments, and personal or political attacks
68+
* Public or private harassment
69+
* Publishing others' private information, such as a physical or electronic
70+
address, without explicit permission
71+
* Other conduct which could reasonably be considered inappropriate in a
72+
professional setting
73+
74+
### Our Responsibilities
75+
76+
Project maintainers are responsible for clarifying the standards of acceptable
77+
behavior and are expected to take appropriate and fair corrective action in
78+
response to any instances of unacceptable behavior.
79+
80+
Project maintainers have the right and responsibility to remove, edit, or
81+
reject comments, commits, code, wiki edits, issues, and other contributions
82+
that are not aligned to this Code of Conduct, or to ban temporarily or
83+
permanently any contributor for other behaviors that they deem inappropriate,
84+
threatening, offensive, or harmful.
85+
86+
### Scope
87+
88+
This Code of Conduct applies both within project spaces and in public spaces
89+
when an individual is representing the project or its community. Examples of
90+
representing a project or community include using an official project e-mail
91+
address, posting via an official social media account, or acting as an appointed
92+
representative at an online or offline event. Representation of a project may be
93+
further defined and clarified by project maintainers.
94+
95+
### Enforcement
96+
97+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
98+
reported by contacting the project team at [hello@lmql.ai](mailto:hello@lmql.ai). All
99+
complaints will be reviewed and investigated and will result in a response that
100+
is deemed necessary and appropriate to the circumstances. The project team is
101+
obligated to maintain confidentiality with regard to the reporter of an incident.
102+
Further details of specific enforcement policies may be posted separately.
103+
104+
Project maintainers who do not follow or enforce the Code of Conduct in good
105+
faith may face temporary or permanent repercussions as determined by other
106+
members of the project's leadership.
107+
108+
### Attribution
109+
110+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
111+
available at [http://contributor-covenant.org/version/1/4][version]
112+
113+
[homepage]: http://contributor-covenant.org
114+
[version]: http://contributor-covenant.org/version/1/4/

MANIFEST.in

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
include src/lmql/ui/*
2-
recursive-exclude src/lmql/ui/playground/node_modules/*
3-
recursive-exclude web *
4-
recursive-exclude src/lmql/ui/vscode/*
2+
recursive-include src/lmql/ui/playground/ *
3+
<<<<<<< HEAD
4+
=======
5+
recursive-exclude src/lmql/ui/playground/build/ *
6+
>>>>>>> a231d6cbbb15091ac273a309f36b8c9d5f5b6c89
7+
recursive-include src/lmql/lib/chat/assets/ *
8+
recursive-include src/lmql/ui/live/ *
9+
recursive-exclude src/lmql/ui/live/node_modules/ *
10+
recursive-exclude src/lmql/ui/live/ *.tokens
11+
recursive-exclude src/lmql/ui/playground/node_modules/ *
12+
recursive-exclude src/lmql/ui/vscode/ *

0 commit comments

Comments
 (0)