Skip to content

Commit 4ddb90e

Browse files
authored
Merge pull request #8 from alea-institute/v0.1.5
merge V0.1.5 onto master
2 parents 6bb7dd1 + 5256e24 commit 4ddb90e

File tree

10 files changed

+1001
-632
lines changed

10 files changed

+1001
-632
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 0.1.5 (2024-11-08)
2+
---------------------------
3+
* Adding support for LLM-backed (decoder) search, e.g., via OpenAI, Anthropic, VLLM, Together
4+
15
Version 0.1.4 (2024-09-04)
26
---------------------------
37
* Add prefix search for typeahead/search bars (with optional trie-based search)

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ SOLI is an open, CC-BY licensed standard designed to represent universal element
1818
- Access detailed information about each class, including labels, definitions, and examples
1919
- Convert classes to OWL XML or Markdown format
2020

21+
## Changelog
22+
The changelog can be found at [CHANGES.md](CHANGES.md).
23+
2124
## Installation
2225

2326
You can install the SOLI Python library using pip:
@@ -58,6 +61,26 @@ for area in areas_of_law:
5861
print(area.label)
5962
```
6063

64+
## Searching with an LLM
65+
66+
```python
67+
# Search with an LLM
68+
async def search_example():
69+
for result in await soli.parallel_search_by_llm(
70+
"redline lease agreement",
71+
search_sets=[
72+
soli.get_areas_of_law(max_depth=1),
73+
soli.get_player_actors(max_depth=2),
74+
],
75+
):
76+
print(result)
77+
78+
import asyncio
79+
asyncio.run(search_example())
80+
```
81+
82+
LLM search uses the `alea_llm_client` to provide abstraction across multiple APIs and providers.
83+
6184
## Documentation
6285

6386
For more detailed information about using the SOLI Python library, please refer to our [full documentation](https://soli-python.readthedocs.io/).

docker/ubuntu2204-install/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:22.04
22

33
# define package version
4-
ARG SOLI_VERSION=0.1.4
4+
ARG SOLI_VERSION=0.1.5
55

66
# Avoid prompts from apt
77
ENV DEBIAN_FRONTEND=noninteractive

docker/ubuntu2404-install/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:24.04
22

33
# define package version
4-
ARG SOLI_VERSION=0.1.4
4+
ARG SOLI_VERSION=0.1.5
55

66
# Avoid prompts from apt
77
ENV DEBIAN_FRONTEND=noninteractive

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
project = "soli-python"
2626
copyright = "2024, ALEA Institute"
2727
author = "ALEA Institute (https://aleainstitute.ai)"
28-
release = "0.1.4"
29-
version = "0.1.4"
28+
release = "0.1.5"
29+
version = "0.1.5"
3030
master_doc = "index"
3131
language = "en"
3232

examples/llm_search.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import asyncio
2+
import time
3+
from pathlib import Path
4+
from soli import SOLI
5+
from alea_llm_client import OpenAIModel, AnthropicModel
6+
7+
8+
async def main():
9+
# text to label/classify
10+
example_text = "review and revise license agreement"
11+
12+
# set at initialization
13+
g = SOLI(llm=OpenAIModel(model="gpt-4o"))
14+
15+
print("gpt-4o results:")
16+
for x in await g.parallel_search_by_llm(
17+
example_text,
18+
):
19+
print(x)
20+
21+
# use a small llama model for area of law
22+
TOGETHER_API_KEY = (Path.home() / ".alea" / "keys" / "together").read_text().strip()
23+
g.llm = OpenAIModel(
24+
endpoint="https://api.together.xyz",
25+
model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
26+
api_key=TOGETHER_API_KEY,
27+
)
28+
29+
print("\n\nmeta-llama/Llama-3.2-3B-Instruct-Turbo results:")
30+
for x in await g.search_by_llm(
31+
example_text,
32+
search_set=g.get_areas_of_law(max_depth=1),
33+
):
34+
print(x)
35+
36+
# override via property
37+
g.llm = AnthropicModel(model="claude-3-5-haiku-20241022")
38+
39+
# search specific branches
40+
print("\n\nclaude-3-5-haiku-20241022 results:")
41+
for x in await g.parallel_search_by_llm(
42+
example_text,
43+
search_sets=[
44+
g.get_areas_of_law(max_depth=2),
45+
g.get_document_artifacts(max_depth=2),
46+
g.get_player_actors(max_depth=3),
47+
],
48+
):
49+
print(x)
50+
51+
52+
if __name__ == "__main__":
53+
t0 = time.time()
54+
asyncio.run(main())
55+
print(time.time() - t0)

poetry.lock

Lines changed: 649 additions & 618 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "soli-python"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
description = "Python library for SOLI, the Standard for Open Legal Information"
55
authors = ["ALEA Institute <[email protected]>"]
66
license = "MIT"
@@ -39,9 +39,9 @@ python = ">=3.10,<4.0.0"
3939
pydantic = "^2.8.2"
4040
lxml = "^5.2.2"
4141
httpx = "^0.27.2"
42-
rapidfuzz = {version = "^3.9.7", optional = true}
42+
rapidfuzz = {version = "^3.10.0", optional = true}
4343
marisa-trie = {version = "^1.2.0", optional = true}
44-
44+
alea-llm-client = {version = "^0.1.1", optional = true}
4545

4646
[tool.poetry.group.dev.dependencies]
4747
types-lxml = "^2024.8.7"
@@ -62,10 +62,11 @@ sphinx-plausible = "^0.1.2"
6262
[tool.poetry.group.search.dependencies]
6363
rapidfuzz = "^3.9.7"
6464
marisa-trie = "^1.2.0"
65+
alea-llm-client = "^0.1.1"
6566

6667
# extras
6768
[tool.poetry.extras]
68-
search = ["rapidfuzz", "marisa-trie"]
69+
search = ["rapidfuzz", "marisa-trie", "alea-llm-client"]
6970

7071

7172
[build-system]

soli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# SPDX-License-Identifier: MIT
66
# (c) 2024 ALEA Institute.
77

8-
__version__ = "0.1.4"
8+
__version__ = "0.1.5"
99
__author__ = "ALEA Institute"
1010
__license__ = "MIT"
1111
__description__ = "Python library for SOLI, the Standard for Open Legal Information"

0 commit comments

Comments
 (0)