hammad-python 0.0.14__py3-none-any.whl → 0.0.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. hammad/__init__.py +177 -0
  2. hammad/{performance/imports.py → _internal.py} +7 -1
  3. hammad/cache/__init__.py +1 -1
  4. hammad/cli/__init__.py +3 -1
  5. hammad/cli/_runner.py +265 -0
  6. hammad/cli/animations.py +1 -1
  7. hammad/cli/plugins.py +133 -78
  8. hammad/cli/styles/__init__.py +1 -1
  9. hammad/cli/styles/utils.py +149 -3
  10. hammad/data/__init__.py +56 -29
  11. hammad/data/collections/__init__.py +27 -17
  12. hammad/data/collections/collection.py +205 -383
  13. hammad/data/collections/indexes/__init__.py +37 -0
  14. hammad/data/collections/indexes/qdrant/__init__.py +1 -0
  15. hammad/data/collections/indexes/qdrant/index.py +735 -0
  16. hammad/data/collections/indexes/qdrant/settings.py +94 -0
  17. hammad/data/collections/indexes/qdrant/utils.py +220 -0
  18. hammad/data/collections/indexes/tantivy/__init__.py +1 -0
  19. hammad/data/collections/indexes/tantivy/index.py +428 -0
  20. hammad/data/collections/indexes/tantivy/settings.py +51 -0
  21. hammad/data/collections/indexes/tantivy/utils.py +200 -0
  22. hammad/data/configurations/__init__.py +2 -2
  23. hammad/data/configurations/configuration.py +2 -2
  24. hammad/data/models/__init__.py +20 -9
  25. hammad/data/models/extensions/__init__.py +4 -0
  26. hammad/data/models/{pydantic → extensions/pydantic}/__init__.py +6 -19
  27. hammad/data/models/{pydantic → extensions/pydantic}/converters.py +143 -16
  28. hammad/data/models/{base/fields.py → fields.py} +1 -1
  29. hammad/data/models/{base/model.py → model.py} +1 -1
  30. hammad/data/models/{base/utils.py → utils.py} +1 -1
  31. hammad/data/sql/__init__.py +23 -0
  32. hammad/data/sql/database.py +578 -0
  33. hammad/data/sql/types.py +141 -0
  34. hammad/data/types/__init__.py +1 -3
  35. hammad/data/types/file.py +3 -3
  36. hammad/data/types/multimodal/__init__.py +2 -2
  37. hammad/data/types/multimodal/audio.py +2 -2
  38. hammad/data/types/multimodal/image.py +2 -2
  39. hammad/formatting/__init__.py +9 -27
  40. hammad/formatting/json/__init__.py +8 -2
  41. hammad/formatting/json/converters.py +7 -1
  42. hammad/formatting/text/__init__.py +1 -1
  43. hammad/formatting/yaml/__init__.py +1 -1
  44. hammad/genai/__init__.py +78 -0
  45. hammad/genai/agents/__init__.py +1 -0
  46. hammad/genai/agents/types/__init__.py +35 -0
  47. hammad/genai/agents/types/history.py +277 -0
  48. hammad/genai/agents/types/tool.py +490 -0
  49. hammad/genai/embedding_models/__init__.py +41 -0
  50. hammad/{ai/embeddings/client/litellm_embeddings_client.py → genai/embedding_models/embedding_model.py} +47 -142
  51. hammad/genai/embedding_models/embedding_model_name.py +77 -0
  52. hammad/genai/embedding_models/embedding_model_request.py +65 -0
  53. hammad/{ai/embeddings/types.py → genai/embedding_models/embedding_model_response.py} +3 -3
  54. hammad/genai/embedding_models/run.py +161 -0
  55. hammad/genai/language_models/__init__.py +35 -0
  56. hammad/genai/language_models/_streaming.py +622 -0
  57. hammad/genai/language_models/_types.py +276 -0
  58. hammad/genai/language_models/_utils/__init__.py +31 -0
  59. hammad/genai/language_models/_utils/_completions.py +131 -0
  60. hammad/genai/language_models/_utils/_messages.py +89 -0
  61. hammad/genai/language_models/_utils/_requests.py +202 -0
  62. hammad/genai/language_models/_utils/_structured_outputs.py +124 -0
  63. hammad/genai/language_models/language_model.py +734 -0
  64. hammad/genai/language_models/language_model_request.py +135 -0
  65. hammad/genai/language_models/language_model_response.py +219 -0
  66. hammad/genai/language_models/language_model_response_chunk.py +53 -0
  67. hammad/genai/language_models/run.py +530 -0
  68. hammad/genai/multimodal_models.py +48 -0
  69. hammad/genai/rerank_models.py +26 -0
  70. hammad/logging/__init__.py +1 -1
  71. hammad/logging/decorators.py +1 -1
  72. hammad/logging/logger.py +2 -2
  73. hammad/mcp/__init__.py +1 -1
  74. hammad/mcp/client/__init__.py +35 -0
  75. hammad/mcp/client/client.py +105 -4
  76. hammad/mcp/client/client_service.py +10 -3
  77. hammad/mcp/servers/__init__.py +24 -0
  78. hammad/{performance/runtime → runtime}/__init__.py +2 -2
  79. hammad/{performance/runtime → runtime}/decorators.py +1 -1
  80. hammad/{performance/runtime → runtime}/run.py +1 -1
  81. hammad/service/__init__.py +1 -1
  82. hammad/service/create.py +3 -8
  83. hammad/service/decorators.py +8 -8
  84. hammad/typing/__init__.py +28 -0
  85. hammad/web/__init__.py +3 -3
  86. hammad/web/http/client.py +1 -1
  87. hammad/web/models.py +53 -21
  88. hammad/web/search/client.py +99 -52
  89. hammad/web/utils.py +13 -13
  90. hammad_python-0.0.16.dist-info/METADATA +191 -0
  91. hammad_python-0.0.16.dist-info/RECORD +110 -0
  92. hammad/ai/__init__.py +0 -1
  93. hammad/ai/_utils.py +0 -142
  94. hammad/ai/completions/__init__.py +0 -45
  95. hammad/ai/completions/client.py +0 -684
  96. hammad/ai/completions/create.py +0 -710
  97. hammad/ai/completions/settings.py +0 -100
  98. hammad/ai/completions/types.py +0 -792
  99. hammad/ai/completions/utils.py +0 -486
  100. hammad/ai/embeddings/__init__.py +0 -35
  101. hammad/ai/embeddings/client/__init__.py +0 -1
  102. hammad/ai/embeddings/client/base_embeddings_client.py +0 -26
  103. hammad/ai/embeddings/client/fastembed_text_embeddings_client.py +0 -200
  104. hammad/ai/embeddings/create.py +0 -159
  105. hammad/data/collections/base_collection.py +0 -58
  106. hammad/data/collections/searchable_collection.py +0 -556
  107. hammad/data/collections/vector_collection.py +0 -596
  108. hammad/data/databases/__init__.py +0 -21
  109. hammad/data/databases/database.py +0 -902
  110. hammad/data/models/base/__init__.py +0 -35
  111. hammad/data/models/pydantic/models/__init__.py +0 -28
  112. hammad/data/models/pydantic/models/arbitrary_model.py +0 -46
  113. hammad/data/models/pydantic/models/cacheable_model.py +0 -79
  114. hammad/data/models/pydantic/models/fast_model.py +0 -318
  115. hammad/data/models/pydantic/models/function_model.py +0 -176
  116. hammad/data/models/pydantic/models/subscriptable_model.py +0 -63
  117. hammad/performance/__init__.py +0 -36
  118. hammad/py.typed +0 -0
  119. hammad_python-0.0.14.dist-info/METADATA +0 -70
  120. hammad_python-0.0.14.dist-info/RECORD +0 -99
  121. {hammad_python-0.0.14.dist-info → hammad_python-0.0.16.dist-info}/WHEEL +0 -0
  122. {hammad_python-0.0.14.dist-info → hammad_python-0.0.16.dist-info}/licenses/LICENSE +0 -0
hammad/ai/__init__.py DELETED
@@ -1 +0,0 @@
1
- """hammad.ai"""
hammad/ai/_utils.py DELETED
@@ -1,142 +0,0 @@
1
- """hammad.ai._utils
2
-
3
- Shared internal utilities for the `hammad.ai` extension."""
4
-
5
- from typing import Any, Optional, Sequence
6
-
7
- __all__ = (
8
- "get_instructor",
9
- "get_litellm",
10
- "get_fastembed",
11
- "get_fastembed_text_embedding_model",
12
- )
13
-
14
-
15
- # ------------------------------------------------------------
16
- # INSTRUCTOR
17
- # ------------------------------------------------------------
18
-
19
-
20
- INSTRUCTOR_MODULE = None
21
- """Library level singleton for the `instructor` module."""
22
-
23
-
24
- def get_instructor():
25
- """Get the instructor module."""
26
- global INSTRUCTOR_MODULE
27
-
28
- if INSTRUCTOR_MODULE is None:
29
- try:
30
- import instructor
31
-
32
- INSTRUCTOR_MODULE = instructor
33
- except ImportError:
34
- raise ImportError(
35
- "instructor is not installed. Please install it with `pip install hammad-python[ai]`"
36
- )
37
-
38
- return INSTRUCTOR_MODULE
39
-
40
-
41
- # ------------------------------------------------------------
42
- # LITELLM
43
- # ------------------------------------------------------------
44
-
45
-
46
- LITELLM_MODULE = None
47
- """Library level singleton for the `litellm` module."""
48
-
49
-
50
- def get_litellm():
51
- """Get the litellm module."""
52
- global LITELLM_MODULE
53
- if LITELLM_MODULE is None:
54
- try:
55
- import litellm
56
-
57
- litellm.drop_params = True
58
- litellm.modify_params = True
59
- LITELLM_MODULE = litellm
60
- except ImportError:
61
- raise ImportError(
62
- "litellm is not installed. Please install it with `pip install hammad-python[ai]`"
63
- )
64
-
65
- return LITELLM_MODULE
66
-
67
-
68
- # ------------------------------------------------------------
69
- # FASTEMBED
70
- # ------------------------------------------------------------
71
-
72
-
73
- FASTEMBED_MODULE = None
74
- """Library level singleton for the `fastembed` module."""
75
-
76
-
77
- def get_fastembed():
78
- """Get the fastembed module."""
79
- global FASTEMBED_MODULE
80
- if FASTEMBED_MODULE is None:
81
- try:
82
- import fastembed
83
-
84
- FASTEMBED_MODULE = fastembed
85
- except ImportError:
86
- raise ImportError(
87
- "fastembed is not installed. Please install it with `pip install hammad-python[ai]`"
88
- )
89
-
90
- return FASTEMBED_MODULE
91
-
92
-
93
- FASTEMBED_LOADED_TEXT_EMBEDDING_MODELS: dict = {}
94
-
95
-
96
- def get_fastembed_text_embedding_model(
97
- model: str,
98
- cache_dir: Optional[str] = None,
99
- threads: Optional[int] = None,
100
- providers: Optional[Sequence[Any]] = None,
101
- cuda: bool = False,
102
- device_ids: Optional[list[int]] = None,
103
- lazy_load: bool = False,
104
- ):
105
- """Initializes a fastembed model instance for a given
106
- model name using a global library level singleton.
107
-
108
- NOTE: Custom models are not supported yet.
109
-
110
- Args:
111
- model (str) : The model name to load.
112
- cache_dir (Optional[str]) : The directory to cache the model in.
113
- threads (Optional[int]) : The number of threads to use for the model.
114
- providers (Optional[Sequence[Any]]) : The ONNX providers to use for the model.
115
- cuda (bool) : Whether to use CUDA for the model.
116
- device_ids (Optional[list[int]]) : The device IDs to use for the model.
117
- lazy_load (bool) : Whether to lazy load the model.
118
-
119
- Returns:
120
- fastembed.TextEmbedding : The loaded fastembed model instance.
121
- """
122
- global FASTEMBED_LOADED_TEXT_EMBEDDING_MODELS
123
-
124
- if model not in FASTEMBED_LOADED_TEXT_EMBEDDING_MODELS:
125
- fastembed_module = get_fastembed()
126
-
127
- try:
128
- embedding_model = fastembed_module.TextEmbedding(
129
- model_name=model,
130
- cache_dir=cache_dir,
131
- threads=threads,
132
- providers=providers,
133
- cuda=cuda,
134
- device_ids=device_ids,
135
- lazy_load=lazy_load,
136
- )
137
- except Exception as e:
138
- raise e
139
-
140
- FASTEMBED_LOADED_TEXT_EMBEDDING_MODELS[model] = embedding_model
141
-
142
- return FASTEMBED_LOADED_TEXT_EMBEDDING_MODELS[model]
@@ -1,45 +0,0 @@
1
- """hammad.ai.completions
2
-
3
- Contains types and model like objects for working with language model
4
- completions."""
5
-
6
- from typing import TYPE_CHECKING
7
- from ...performance.imports import create_getattr_importer
8
-
9
- if TYPE_CHECKING:
10
- from .client import CompletionsClient
11
- from .types import (
12
- Completion,
13
- CompletionChunk,
14
- CompletionStream,
15
- AsyncCompletionStream,
16
- CompletionsInputParam,
17
- CompletionsModelName,
18
- CompletionsOutputType,
19
- )
20
- from .settings import CompletionsSettings, CompletionsModelSettings
21
- from .create import create_completion, async_create_completion
22
-
23
-
24
- __all__ = (
25
- # hammad.ai.completions.client
26
- "CompletionsClient",
27
- # hammad.ai.completions.types
28
- "Completion",
29
- "CompletionChunk",
30
- "CompletionStream",
31
- "AsyncCompletionStream",
32
- "CompletionsInputParam",
33
- "CompletionsModelName",
34
- "CompletionsOutputType",
35
- # hammad.ai.completions.create
36
- "create_completion",
37
- "async_create_completion",
38
- )
39
-
40
-
41
- __getattr__ = create_getattr_importer(__all__)
42
-
43
-
44
- def __dir__() -> list[str]:
45
- return list(__all__)