Fix Lark import error (#4421)

Any import that touches langchain.retrievers currently requires Lark.
Here's one attempt to fix. Not very pretty, very open to other ideas.
Alternatives I thought of are 1) make Lark requirement, 2) put
everything in parser.py in the try/except. Neither sounds much better

Related to #4316, #4275
This commit is contained in:
Davis Chase 2023-05-10 01:07:34 -07:00 committed by GitHub
parent f0cfed636f
commit f6c97e6af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,12 @@ try:
)
from lark import Lark, Transformer, v_args
except ImportError:
pass
def v_args(*args: Any, **kwargs: Any) -> Any: # type: ignore
return lambda _: None
Transformer = object # type: ignore
Lark = object # type: ignore
from langchain.chains.query_constructor.ir import (
Comparator,