Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2ce2399
docs(pypi): Improve README display and badge reliability
aksg87 Jul 22, 2025
4fe7580
feat: add trusted publishing workflow and prepare v1.0.0 release
aksg87 Jul 22, 2025
e696a48
Fix: Resolve libmagic ImportError (#6)
aksg87 Aug 1, 2025
5447637
docs: clarify output_dir behavior in medication_examples.md
kleeena Aug 1, 2025
9c47b34
Merge pull request #11 from google/fix/libmagic-dependency-issue
aksg87 Aug 1, 2025
175e075
Removed inline comment in medication example
kleeena Aug 2, 2025
9472099
Merge pull request #15 from kleeena/docs/update-medication_examples.md
aksg87 Aug 2, 2025
e6c3dcd
docs: add output_dir="." to all save_annotated_documents examples
aksg87 Aug 2, 2025
1fb1f1d
Merge pull request #17 from google/fix/output-dir-consistency
aksg87 Aug 2, 2025
13fbd2c
build: add formatting & linting pipeline with pre-commit integration
aksg87 Aug 3, 2025
c8d2027
style: apply pyink, isort, and pre-commit formatting
aksg87 Aug 3, 2025
146a095
ci: enable format and lint checks in tox
aksg87 Aug 3, 2025
aa6da18
Merge pull request #24 from google/feat/code-formatting-pipeline
aksg87 Aug 3, 2025
ed65bca
Add LangExtractError base exception for centralized error handling
aksg87 Aug 3, 2025
6c4508b
Merge pull request #26 from google/feat/exception-hierarchy
aksg87 Aug 3, 2025
8b85225
fix: Remove LangFun and pylibmagic dependencies (v1.0.2)
aksg87 Aug 3, 2025
88520cc
Merge pull request #28 from google/fix/remove-breaking-dep-langfun
aksg87 Aug 3, 2025
75a6f12
Fix save_annotated_documents to handle string paths
aksg87 Aug 3, 2025
a415b94
Merge pull request #29 from google/fix-save-annotated-documents-mkdir
aksg87 Aug 3, 2025
8289b3a
feat: Add OpenAI language model support
aksg87 Aug 3, 2025
c8ef723
Merge pull request #31 from google/feature/add-oai-inference
aksg87 Aug 3, 2025
dfe8188
fix(ui): prevent current highlight border from being obscured. Chan…
tonebeta Aug 4, 2025
87c511e
feat: Add live API integration tests (#39)
aksg87 Aug 4, 2025
dc61372
Add PR template validation workflow (#45)
aksg87 Aug 4, 2025
da771e6
fix: Change OllamaLanguageModel parameter from 'model' to 'model_id' …
aksg87 Aug 5, 2025
e83d5cf
feat: Add CITATION.cff file for proper software citation
aksg87 Aug 5, 2025
337beee
feat: Add Ollama integration with Docker examples and CI tests (#62)
aksg87 Aug 5, 2025
a7ef0bd
chore: Bump version to 1.0.4 for release
aksg87 Aug 5, 2025
87beb4f
build(deps): bump tj-actions/changed-files (#66)
dependabot[bot] Aug 5, 2025
db140d1
Add PR validation workflows and update contribution guidelines (#74)
aksg87 Aug 5, 2025
ed97f73
Fix custom comment in linked issue check (#77)
aksg87 Aug 5, 2025
ad1f27b
Add infrastructure file protection workflow (#76)
aksg87 Aug 5, 2025
41bc9ed
Allow maintainers to bypass community support requirement
aksg87 Aug 5, 2025
54e57db
Add manual trigger capability to validation workflows (#75)
aksg87 Aug 5, 2025
25ebc17
Fix fork PR labeling by using pull_request_target
aksg87 Aug 5, 2025
b0d7ebb
Add Gemini Vertex AI integration with thinking budget support
NewcomerAI Aug 6, 2025
8069650
Fix code formatting and linting issues
NewcomerAI Aug 6, 2025
1290d63
Add workflow_dispatch trigger to CI workflow
aksg87 Aug 6, 2025
dd1654c
Merge branch 'main' into feature/vertex-ai-integration
NewcomerAI Aug 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add LangExtractError base exception for centralized error handling
Introduces a common base exception class that all library-specific exceptions inherit from, enabling users to catch all LangExtract errors with a single except clause.
  • Loading branch information
aksg87 committed Aug 3, 2025
commit ed65bcaa4bd123f84e61b927f2e74407c4e600b3
30 changes: 30 additions & 0 deletions exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2025 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Base exceptions for LangExtract.

This module defines the base exception class that all LangExtract exceptions
inherit from. Individual modules define their own specific exceptions.
"""

__all__ = ["LangExtractError"]


class LangExtractError(Exception):
"""Base exception for all LangExtract errors.

All exceptions raised by LangExtract should inherit from this class.
This allows users to catch all LangExtract-specific errors with a single
except clause.
"""
15 changes: 15 additions & 0 deletions langextract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,28 @@

from langextract import annotation
from langextract import data
from langextract import exceptions
from langextract import inference
from langextract import io
from langextract import prompting
from langextract import resolver
from langextract import schema
from langextract import visualization

__all__ = [
"extract",
"visualize",
"annotation",
"data",
"exceptions",
"inference",
"io",
"prompting",
"resolver",
"schema",
"visualization",
]

LanguageModelT = TypeVar("LanguageModelT", bound=inference.BaseLanguageModel)

# Set up visualization helper at the top level (lx.visualize).
Expand Down
3 changes: 2 additions & 1 deletion langextract/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from langextract import chunking
from langextract import data
from langextract import exceptions
from langextract import inference
from langextract import progress
from langextract import prompting
Expand All @@ -39,7 +40,7 @@
ATTRIBUTE_SUFFIX = "_attributes"


class DocumentRepeatError(Exception):
class DocumentRepeatError(exceptions.LangExtractError):
"""Exception raised when identical document ids are present."""


Expand Down
3 changes: 2 additions & 1 deletion langextract/chunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
import more_itertools

from langextract import data
from langextract import exceptions
from langextract import tokenizer


class TokenUtilError(Exception):
class TokenUtilError(exceptions.LangExtractError):
"""Error raised when token_util returns unexpected values."""


Expand Down
26 changes: 26 additions & 0 deletions langextract/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2025 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Base exceptions for LangExtract."""

__all__ = ["LangExtractError"]


class LangExtractError(Exception):
"""Base exception for all LangExtract errors.

All exceptions raised by LangExtract should inherit from this class.
This allows users to catch all LangExtract-specific errors with a single
except clause.
"""
3 changes: 2 additions & 1 deletion langextract/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import yaml

from langextract import data
from langextract import exceptions
from langextract import schema

_OLLAMA_DEFAULT_MODEL_URL = 'http://localhost:11434'
Expand All @@ -49,7 +50,7 @@ def __str__(self) -> str:
return f'Score: {self.score:.2f}\nOutput:\n{formatted_lines}'


class InferenceOutputError(Exception):
class InferenceOutputError(exceptions.LangExtractError):
"""Exception raised when no scored outputs are available from the language model."""

def __init__(self, message: str):
Expand Down
3 changes: 2 additions & 1 deletion langextract/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

from langextract import data
from langextract import data_lib
from langextract import exceptions
from langextract import progress

DEFAULT_TIMEOUT_SECONDS = 30


class InvalidDatasetError(Exception):
class InvalidDatasetError(exceptions.LangExtractError):
"""Error raised when Dataset is empty or invalid."""


Expand Down
3 changes: 2 additions & 1 deletion langextract/prompting.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
import yaml

from langextract import data
from langextract import exceptions
from langextract import schema


class PromptBuilderError(Exception):
class PromptBuilderError(exceptions.LangExtractError):
"""Failure to build prompt."""


Expand Down
3 changes: 2 additions & 1 deletion langextract/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import yaml

from langextract import data
from langextract import exceptions
from langextract import schema
from langextract import tokenizer

Expand Down Expand Up @@ -151,7 +152,7 @@ def align(
ExtractionValueType = str | int | float | dict | list | None


class ResolverParsingError(Exception):
class ResolverParsingError(exceptions.LangExtractError):
"""Error raised when content cannot be parsed as the given format."""


Expand Down
4 changes: 3 additions & 1 deletion langextract/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@

from absl import logging

from langextract import exceptions

class BaseTokenizerError(Exception):

class BaseTokenizerError(exceptions.LangExtractError):
"""Base class for all tokenizer-related errors."""


Expand Down