hammad-python 0.0.14__py3-none-any.whl → 0.0.15__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 (101) hide show
  1. hammad_python-0.0.15.dist-info/METADATA +184 -0
  2. hammad_python-0.0.15.dist-info/RECORD +4 -0
  3. hammad/__init__.py +0 -1
  4. hammad/ai/__init__.py +0 -1
  5. hammad/ai/_utils.py +0 -142
  6. hammad/ai/completions/__init__.py +0 -45
  7. hammad/ai/completions/client.py +0 -684
  8. hammad/ai/completions/create.py +0 -710
  9. hammad/ai/completions/settings.py +0 -100
  10. hammad/ai/completions/types.py +0 -792
  11. hammad/ai/completions/utils.py +0 -486
  12. hammad/ai/embeddings/__init__.py +0 -35
  13. hammad/ai/embeddings/client/__init__.py +0 -1
  14. hammad/ai/embeddings/client/base_embeddings_client.py +0 -26
  15. hammad/ai/embeddings/client/fastembed_text_embeddings_client.py +0 -200
  16. hammad/ai/embeddings/client/litellm_embeddings_client.py +0 -288
  17. hammad/ai/embeddings/create.py +0 -159
  18. hammad/ai/embeddings/types.py +0 -69
  19. hammad/cache/__init__.py +0 -40
  20. hammad/cache/base_cache.py +0 -181
  21. hammad/cache/cache.py +0 -169
  22. hammad/cache/decorators.py +0 -261
  23. hammad/cache/file_cache.py +0 -80
  24. hammad/cache/ttl_cache.py +0 -74
  25. hammad/cli/__init__.py +0 -33
  26. hammad/cli/animations.py +0 -573
  27. hammad/cli/plugins.py +0 -781
  28. hammad/cli/styles/__init__.py +0 -55
  29. hammad/cli/styles/settings.py +0 -139
  30. hammad/cli/styles/types.py +0 -358
  31. hammad/cli/styles/utils.py +0 -480
  32. hammad/data/__init__.py +0 -56
  33. hammad/data/collections/__init__.py +0 -34
  34. hammad/data/collections/base_collection.py +0 -58
  35. hammad/data/collections/collection.py +0 -452
  36. hammad/data/collections/searchable_collection.py +0 -556
  37. hammad/data/collections/vector_collection.py +0 -596
  38. hammad/data/configurations/__init__.py +0 -35
  39. hammad/data/configurations/configuration.py +0 -564
  40. hammad/data/databases/__init__.py +0 -21
  41. hammad/data/databases/database.py +0 -902
  42. hammad/data/models/__init__.py +0 -44
  43. hammad/data/models/base/__init__.py +0 -35
  44. hammad/data/models/base/fields.py +0 -546
  45. hammad/data/models/base/model.py +0 -1078
  46. hammad/data/models/base/utils.py +0 -280
  47. hammad/data/models/pydantic/__init__.py +0 -55
  48. hammad/data/models/pydantic/converters.py +0 -632
  49. hammad/data/models/pydantic/models/__init__.py +0 -28
  50. hammad/data/models/pydantic/models/arbitrary_model.py +0 -46
  51. hammad/data/models/pydantic/models/cacheable_model.py +0 -79
  52. hammad/data/models/pydantic/models/fast_model.py +0 -318
  53. hammad/data/models/pydantic/models/function_model.py +0 -176
  54. hammad/data/models/pydantic/models/subscriptable_model.py +0 -63
  55. hammad/data/types/__init__.py +0 -41
  56. hammad/data/types/file.py +0 -358
  57. hammad/data/types/multimodal/__init__.py +0 -24
  58. hammad/data/types/multimodal/audio.py +0 -96
  59. hammad/data/types/multimodal/image.py +0 -80
  60. hammad/data/types/text.py +0 -1066
  61. hammad/formatting/__init__.py +0 -38
  62. hammad/formatting/json/__init__.py +0 -21
  63. hammad/formatting/json/converters.py +0 -152
  64. hammad/formatting/text/__init__.py +0 -63
  65. hammad/formatting/text/converters.py +0 -723
  66. hammad/formatting/text/markdown.py +0 -131
  67. hammad/formatting/yaml/__init__.py +0 -26
  68. hammad/formatting/yaml/converters.py +0 -5
  69. hammad/logging/__init__.py +0 -35
  70. hammad/logging/decorators.py +0 -834
  71. hammad/logging/logger.py +0 -954
  72. hammad/mcp/__init__.py +0 -50
  73. hammad/mcp/client/__init__.py +0 -1
  74. hammad/mcp/client/client.py +0 -523
  75. hammad/mcp/client/client_service.py +0 -393
  76. hammad/mcp/client/settings.py +0 -178
  77. hammad/mcp/servers/__init__.py +0 -1
  78. hammad/mcp/servers/launcher.py +0 -1161
  79. hammad/performance/__init__.py +0 -36
  80. hammad/performance/imports.py +0 -231
  81. hammad/performance/runtime/__init__.py +0 -32
  82. hammad/performance/runtime/decorators.py +0 -142
  83. hammad/performance/runtime/run.py +0 -299
  84. hammad/py.typed +0 -0
  85. hammad/service/__init__.py +0 -49
  86. hammad/service/create.py +0 -532
  87. hammad/service/decorators.py +0 -285
  88. hammad/typing/__init__.py +0 -407
  89. hammad/web/__init__.py +0 -43
  90. hammad/web/http/__init__.py +0 -1
  91. hammad/web/http/client.py +0 -944
  92. hammad/web/models.py +0 -245
  93. hammad/web/openapi/__init__.py +0 -1
  94. hammad/web/openapi/client.py +0 -740
  95. hammad/web/search/__init__.py +0 -1
  96. hammad/web/search/client.py +0 -988
  97. hammad/web/utils.py +0 -472
  98. hammad_python-0.0.14.dist-info/METADATA +0 -70
  99. hammad_python-0.0.14.dist-info/RECORD +0 -99
  100. {hammad_python-0.0.14.dist-info → hammad_python-0.0.15.dist-info}/WHEEL +0 -0
  101. {hammad_python-0.0.14.dist-info → hammad_python-0.0.15.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.4
2
+ Name: hammad-python
3
+ Version: 0.0.15
4
+ Author-email: Hammad Saeed <hammadaidev@gmail.com>
5
+ License: MIT License
6
+
7
+ Copyright (c) 2025 Hammad Saeed
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ License-File: LICENSE
27
+ Requires-Python: >=3.11
28
+ Requires-Dist: ddgs>=9.0.0
29
+ Requires-Dist: httpx>=0.28.1
30
+ Requires-Dist: msgspec>=0.19.0
31
+ Requires-Dist: pydantic>=2.11.7
32
+ Requires-Dist: rich>=14.0.0
33
+ Requires-Dist: selectolax>=0.3.31
34
+ Requires-Dist: sqlalchemy>=2.0.41
35
+ Requires-Dist: tantivy>=0.24.0
36
+ Requires-Dist: tenacity>=9.1.2
37
+ Requires-Dist: typing-inspect>=0.9.0
38
+ Provides-Extra: ai
39
+ Requires-Dist: instructor>=1.9.0; extra == 'ai'
40
+ Requires-Dist: litellm>=1.73.6; extra == 'ai'
41
+ Requires-Dist: qdrant-client>=1.14.3; extra == 'ai'
42
+ Provides-Extra: mcp
43
+ Requires-Dist: mcp>=1.10.1; extra == 'mcp'
44
+ Provides-Extra: serve
45
+ Requires-Dist: fastapi>=0.115.6; extra == 'serve'
46
+ Requires-Dist: uvicorn>=0.34.0; extra == 'serve'
47
+ Description-Content-Type: text/markdown
48
+
49
+ ## hammad-python
50
+
51
+ > __Happily Accelerated Micro-Modules (_for_) Application Development__
52
+
53
+ ## Introduction
54
+
55
+ The `hammad-python` library, is a mix of a love letter and collection of mixed resources for
56
+ developing Python applications. This library is meant to be used for rapid prototyping and
57
+ development, and is focused on providing styled placeholder tools for common patterns, tasks
58
+ and workflows.
59
+
60
+ The package is currently built into the following structures:
61
+
62
+ - `hammad-python` : Contains most core functionality and resources.
63
+ - `hammad-python[ai]` : Contains easy to use resources for Generative AI related tasks such as
64
+ generating completions with language models, or creating embeddings.
65
+ - `hammad-python[serve]` : Contains FastAPI / Uvicorn based resources for serving and running applications.
66
+
67
+ ## Installation
68
+
69
+ You can install the package using `pip` or `uv`:
70
+
71
+ ```bash
72
+ pip install hammad-python
73
+
74
+ # or install the `ai` extension
75
+ # pip install 'hammad-python[ai]'
76
+
77
+ # or install the `serve` extension
78
+ # pip install 'hammad-python[serve]'
79
+ ```
80
+
81
+ ```bash
82
+ uv pip install hammad-python
83
+
84
+ # or install the `ai` extension
85
+ # uv pip install 'hammad-python[ai]'
86
+
87
+ # or install the `serve` extension
88
+ # uv pip install 'hammad-python[serve]'
89
+ ```
90
+
91
+ ## Basic Usage
92
+
93
+ ### Data Structures, Databases and Other Data Related Resources
94
+
95
+ #### Collections
96
+
97
+ Using `hammad.data.collections` is a simple way to create searchable collections of
98
+ data using both `bm25` and `vector` based search.
99
+
100
+ ```python
101
+ from hammad.data.collections import create_collection
102
+
103
+ # Create either a `vector` or `searchable` collection
104
+ col = create_collection(type = "searchable")
105
+
106
+ # add anything to the collection
107
+ col.add("This is some text")
108
+ col.add(5)
109
+ col.add({'text' : "this is a dictionary"})
110
+
111
+ # search the collection
112
+ print(col.query("text"))
113
+ ```
114
+
115
+ #### Databases
116
+
117
+ Any collection can be either used as a standalone database, or can be added as one
118
+ of the collections within a database. Databases provide a unified interface for handling
119
+ both `Searchable` and `Vector` based collections.
120
+
121
+ ```python
122
+ from hammad.data.collections import create_collection
123
+ from hammad.data.databases import Database
124
+
125
+ # Create either a `vector` or `searchable` collection
126
+ col = create_collection(type = "searchable")
127
+
128
+ col.add("This is some text")
129
+
130
+ # Databases can either be created on memory or using a path
131
+ db = Database(location = "memory")
132
+
133
+ db.add_collection(col)
134
+
135
+ # search globally or within a single collection
136
+ print(db.query("text"))
137
+ ```
138
+
139
+ ### Styling / Introspection Resources
140
+
141
+ The `hammad-python` package contains a variety of components that can be used
142
+ to easily style, or run introspection (logging) on your code.
143
+
144
+ ```python
145
+ from hammad.cli import print, input, animate
146
+
147
+ # Use extended `rich` styling easily
148
+ print("Hello, World", bg_settings = {"title" : "This is a title"})
149
+
150
+ # Easily collect various forms of input in a single function
151
+ class User(BaseModel):
152
+ name : str
153
+ age : int
154
+
155
+ # TIP:
156
+ # you can style this the same way with `print`
157
+ user = input("Enter some information about yourself: ", schema = User)
158
+
159
+ # easily run a collection of prebuilt animations
160
+ animate("This is a rainbow!", type = "rainbow", duration = 2, refresh_rate = 20)
161
+ ```
162
+
163
+ Using the various `hammad.logging` resources, you can both create custom & styled
164
+ loggers, as well as easily inspect various aspects of your code during runtime.
165
+
166
+ ```python
167
+ from hammad.logging import Logger
168
+
169
+ # create standard / file based loggers easily
170
+ logger = Logger("hammad", level = "info", rich = Trues)
171
+
172
+ file_logger = Logger("hammad-file", level = "info", file = "hammad.log")
173
+
174
+ # log to the console
175
+ logger.info("This is an info message")
176
+
177
+ # Use the various `trace_` methods to run various introspection tasks
178
+ from hammad.logging import (
179
+ trace,
180
+ trace_cls,
181
+ trace_function,
182
+ trace_http
183
+ )
184
+ ```
@@ -0,0 +1,4 @@
1
+ hammad_python-0.0.15.dist-info/METADATA,sha256=76e_P5ZnWxhhfnyhA0B91cnlFtAxepwavtFancGsUuw,5907
2
+ hammad_python-0.0.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
+ hammad_python-0.0.15.dist-info/licenses/LICENSE,sha256=h74yFUWjbBaodcWG5wNmm30npjl8obVcxD-1nQfUp2I,1069
4
+ hammad_python-0.0.15.dist-info/RECORD,,
hammad/__init__.py DELETED
@@ -1 +0,0 @@
1
- """hammad-python"""
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__)