-
-
Notifications
You must be signed in to change notification settings - Fork 74
/
compat.py
55 lines (42 loc) 路 1.08 KB
/
compat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# mypy: ignore-errors
import sys
try:
import pytest
# Ignore pkg_resources DeprecationWarning that may be raised for MiniChain.
pytestmark = pytest.mark.filterwarnings("ignore:pkg_resources:DeprecationWarning")
except (ImportError, AttributeError):
pass
if sys.version_info[:2] >= (3, 8): # Python 3.8+
from typing import Protocol, runtime_checkable, Literal
else:
from typing_extensions import Protocol, runtime_checkable, Literal # noqa: F401
try:
import langchain
has_langchain = True
except (ImportError, AttributeError):
langchain = None
has_langchain = False
try:
import minichain
has_minichain = True
except (ImportError, AttributeError):
minichain = None
has_minichain = False
try:
import torch
has_torch = True
except ImportError:
torch = None
has_torch = False
try:
import transformers
has_transformers = True
except ImportError:
transformers = None
has_transformers = False
try:
import accelerate
has_accelerate = True
except ImportError:
accelerate = None
has_accelerate = False