legalysis extracts parties, issues, outcomes, and lessons from case texts into a consistent, structured format for quick legal insight.
Project description
legalysis
legalysis is a lightweight Python package designed to transform unstructured legal case summaries or dispute narratives into structured insights.
It extracts key elements such as parties, core legal issues, outcomes, and lessons learned, returning the information in a consistent, easy‑to‑parse format.
The package uses pattern matching to guarantee that the LLM output matches a predefined regex, ensuring reliable, reproducible results across different cases.
Features
- Zero‑configuration LLM usage – defaults to the free tier of ChatLLM7 from
langchain_llm7. - Pattern‑matched output – guarantees that extracted data follows a standard format.
- Optional custom LLM – seamlessly switch to OpenAI, Anthropic, Google Gemini, or any other Langchain-compatible model.
- Simple API – just one function call:
legalysis(user_input, llm=..., api_key=...).
Installation
pip install legalysis
Quickstart
from legalysis import legalysis
# Simple usage with default ChatLLM7
user_input = """
In Smith v. Jones, the plaintiff alleged that the defendant breached a contract
by failing to deliver goods within the agreed timeframe. The court ruled in favor
of the plaintiff, awarding damages and injunction. Key lesson: always include
a clear delivery clause in contracts.
"""
response = legalysis(user_input)
print(response)
Parameters
legalysis(user_input: str,
api_key: Optional[str] = None,
llm: Optional[BaseChatModel] = None) -> List[str]
| Parameter | Type | Description |
|---|---|---|
user_input |
str |
Raw legal narrative text to analyze. |
llm |
Optional[BaseChatModel] |
Langchain LLM instance. If omitted, the package will instantiate the default ChatLLM7. |
api_key |
Optional[str] |
API key for LLM7. If omitted, the package looks for the environment variable LLM7_API_KEY; if still unavailable, it falls back to the free‑tier default key. |
Using Your Own LLM
legalysis accepts any Langchain-compatible model. For example:
OpenAI
from langchain_openai import ChatOpenAI
from legalysis import legalysis
llm = ChatOpenAI(temperature=0)
response = legalysis(user_input, llm=llm)
Anthropic
from langchain_anthropic import ChatAnthropic
from legalysis import legalysis
llm = ChatAnthropic(temperature=0.5)
response = legalysis(user_input, llm=llm)
Google Gemini
from langchain_google_genai import ChatGoogleGenerativeAI
from legalysis import legalysis
llm = ChatGoogleGenerativeAI(temperature=0.2)
response = legalysis(user_input, llm=llm)
Rate Limits & API Keys
- The ChatLLM7 free tier is sufficient for most developers’ needs.
- To increase limits, start a paid plan on LLM7 and supply your key via the environment variable
LLM7_API_KEYor directly in the function call:
response = legalysis(user_input, api_key="YOUR_API_KEY")
You can obtain a free key by registering at https://token.llm7.io/.
Issues & Support
If you find bugs or have feature requests, please open an issue here: https://github.com/chigwell/legalysis/issues
Author
- Eugene Evstafev
- Email: hi@euegne.plus
- GitHub: https://github.com/chigwell
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file legalysis-2025.12.21190910.tar.gz.
File metadata
- Download URL: legalysis-2025.12.21190910.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa822b5b80e273e468da3a653217179f6e40cda408c78d56dba406a21d38f530
|
|
| MD5 |
d625c0310acb156132282a93176a6a7d
|
|
| BLAKE2b-256 |
37ebd82366aed172ed6edf4a8e1cfc52d24aea2f4c5921d38996ec082254dd27
|
File details
Details for the file legalysis-2025.12.21190910-py3-none-any.whl.
File metadata
- Download URL: legalysis-2025.12.21190910-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84edb78cf1d857b3429a7e22c63e1ffdd52887d8ab24d693bf4d79413e9a7872
|
|
| MD5 |
15033b8727dabb88712b8e591b19393f
|
|
| BLAKE2b-256 |
27d8670900c084f03a351f106c05326804151275bfac1f37e3c8472e8c398bde
|