__init__.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright 2024 Cohere and The HuggingFace Inc. team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. from ...utils import (
  16. OptionalDependencyNotAvailable,
  17. _LazyModule,
  18. is_sentencepiece_available,
  19. is_tokenizers_available,
  20. is_torch_available,
  21. )
  22. _import_structure = {
  23. "configuration_cohere": ["CohereConfig"],
  24. }
  25. try:
  26. if not is_tokenizers_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["tokenization_cohere_fast"] = ["CohereTokenizerFast"]
  32. try:
  33. if not is_torch_available():
  34. raise OptionalDependencyNotAvailable()
  35. except OptionalDependencyNotAvailable:
  36. pass
  37. else:
  38. _import_structure["modeling_cohere"] = [
  39. "CohereForCausalLM",
  40. "CohereModel",
  41. "CoherePreTrainedModel",
  42. ]
  43. if TYPE_CHECKING:
  44. from .configuration_cohere import CohereConfig
  45. try:
  46. if not is_tokenizers_available():
  47. raise OptionalDependencyNotAvailable()
  48. except OptionalDependencyNotAvailable:
  49. pass
  50. else:
  51. from .tokenization_cohere_fast import CohereTokenizerFast
  52. try:
  53. if not is_torch_available():
  54. raise OptionalDependencyNotAvailable()
  55. except OptionalDependencyNotAvailable:
  56. pass
  57. else:
  58. from .modeling_cohere import (
  59. CohereForCausalLM,
  60. CohereModel,
  61. CoherePreTrainedModel,
  62. )
  63. else:
  64. import sys
  65. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)