hammad-python 0.0.13__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 (87) 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 -180
  4. hammad/_core/__init__.py +0 -1
  5. hammad/_core/_utils/__init__.py +0 -4
  6. hammad/_core/_utils/_import_utils.py +0 -182
  7. hammad/ai/__init__.py +0 -59
  8. hammad/ai/_utils.py +0 -142
  9. hammad/ai/completions/__init__.py +0 -44
  10. hammad/ai/completions/client.py +0 -729
  11. hammad/ai/completions/create.py +0 -686
  12. hammad/ai/completions/types.py +0 -711
  13. hammad/ai/completions/utils.py +0 -374
  14. hammad/ai/embeddings/__init__.py +0 -35
  15. hammad/ai/embeddings/client/__init__.py +0 -1
  16. hammad/ai/embeddings/client/base_embeddings_client.py +0 -26
  17. hammad/ai/embeddings/client/fastembed_text_embeddings_client.py +0 -200
  18. hammad/ai/embeddings/client/litellm_embeddings_client.py +0 -288
  19. hammad/ai/embeddings/create.py +0 -159
  20. hammad/ai/embeddings/types.py +0 -69
  21. hammad/base/__init__.py +0 -35
  22. hammad/base/fields.py +0 -546
  23. hammad/base/model.py +0 -1078
  24. hammad/base/utils.py +0 -280
  25. hammad/cache/__init__.py +0 -48
  26. hammad/cache/base_cache.py +0 -181
  27. hammad/cache/cache.py +0 -169
  28. hammad/cache/decorators.py +0 -261
  29. hammad/cache/file_cache.py +0 -80
  30. hammad/cache/ttl_cache.py +0 -74
  31. hammad/cli/__init__.py +0 -33
  32. hammad/cli/animations.py +0 -604
  33. hammad/cli/plugins.py +0 -781
  34. hammad/cli/styles/__init__.py +0 -55
  35. hammad/cli/styles/settings.py +0 -139
  36. hammad/cli/styles/types.py +0 -358
  37. hammad/cli/styles/utils.py +0 -480
  38. hammad/configuration/__init__.py +0 -35
  39. hammad/configuration/configuration.py +0 -564
  40. hammad/data/__init__.py +0 -39
  41. hammad/data/collections/__init__.py +0 -34
  42. hammad/data/collections/base_collection.py +0 -58
  43. hammad/data/collections/collection.py +0 -452
  44. hammad/data/collections/searchable_collection.py +0 -556
  45. hammad/data/collections/vector_collection.py +0 -603
  46. hammad/data/databases/__init__.py +0 -21
  47. hammad/data/databases/database.py +0 -902
  48. hammad/json/__init__.py +0 -21
  49. hammad/json/converters.py +0 -152
  50. hammad/logging/__init__.py +0 -35
  51. hammad/logging/decorators.py +0 -834
  52. hammad/logging/logger.py +0 -954
  53. hammad/multimodal/__init__.py +0 -24
  54. hammad/multimodal/audio.py +0 -96
  55. hammad/multimodal/image.py +0 -80
  56. hammad/multithreading/__init__.py +0 -304
  57. hammad/py.typed +0 -0
  58. hammad/pydantic/__init__.py +0 -43
  59. hammad/pydantic/converters.py +0 -623
  60. hammad/pydantic/models/__init__.py +0 -28
  61. hammad/pydantic/models/arbitrary_model.py +0 -46
  62. hammad/pydantic/models/cacheable_model.py +0 -79
  63. hammad/pydantic/models/fast_model.py +0 -318
  64. hammad/pydantic/models/function_model.py +0 -176
  65. hammad/pydantic/models/subscriptable_model.py +0 -63
  66. hammad/text/__init__.py +0 -82
  67. hammad/text/converters.py +0 -723
  68. hammad/text/markdown.py +0 -131
  69. hammad/text/text.py +0 -1066
  70. hammad/types/__init__.py +0 -11
  71. hammad/types/file.py +0 -358
  72. hammad/typing/__init__.py +0 -407
  73. hammad/web/__init__.py +0 -43
  74. hammad/web/http/__init__.py +0 -1
  75. hammad/web/http/client.py +0 -944
  76. hammad/web/models.py +0 -245
  77. hammad/web/openapi/__init__.py +0 -0
  78. hammad/web/openapi/client.py +0 -740
  79. hammad/web/search/__init__.py +0 -1
  80. hammad/web/search/client.py +0 -988
  81. hammad/web/utils.py +0 -472
  82. hammad/yaml/__init__.py +0 -30
  83. hammad/yaml/converters.py +0 -19
  84. hammad_python-0.0.13.dist-info/METADATA +0 -38
  85. hammad_python-0.0.13.dist-info/RECORD +0 -85
  86. {hammad_python-0.0.13.dist-info → hammad_python-0.0.15.dist-info}/WHEEL +0 -0
  87. {hammad_python-0.0.13.dist-info → hammad_python-0.0.15.dist-info}/licenses/LICENSE +0 -0
hammad/typing/__init__.py DELETED
@@ -1,407 +0,0 @@
1
- """hammad.typing
2
-
3
- 'Namespace' package extension for various **CORE** typing resources and
4
- types. This is not a collection of built types, rather resources from the
5
- core `typing` module, `typing_extensions`, `typing_inspect` and other
6
- resources."""
7
-
8
- from typing import Any, TYPE_CHECKING
9
- import typing_inspect as inspection
10
-
11
- try:
12
- from typing_extensions import *
13
- except ImportError:
14
- from typing import *
15
-
16
- from typing_inspect import (
17
- is_callable_type,
18
- is_classvar,
19
- is_final_type,
20
- is_forward_ref,
21
- is_generic_type,
22
- is_literal_type,
23
- is_new_type,
24
- is_optional_type,
25
- is_union_type,
26
- is_typevar,
27
- is_tuple_type,
28
- get_origin,
29
- get_args,
30
- get_last_args,
31
- get_last_origin,
32
- get_generic_bases,
33
- typed_dict_keys as get_typed_dict_keys,
34
- )
35
- from typing_inspection.introspection import (
36
- is_union_origin,
37
- inspect_annotation,
38
- get_literal_values,
39
- )
40
- from dataclasses import is_dataclass
41
-
42
- __all__ = (
43
- # Super-special typing primitives.
44
- "Any",
45
- "ClassVar",
46
- "Concatenate",
47
- "Final",
48
- "LiteralString",
49
- "ParamSpec",
50
- "ParamSpecArgs",
51
- "ParamSpecKwargs",
52
- "Self",
53
- "Type",
54
- "TypeVar",
55
- "TypeVarTuple",
56
- "Unpack",
57
- # ABCs (from collections.abc).
58
- "Awaitable",
59
- "AsyncIterator",
60
- "AsyncIterable",
61
- "Coroutine",
62
- "AsyncGenerator",
63
- "AsyncContextManager",
64
- "Buffer",
65
- "ChainMap",
66
- # Concrete collection types.
67
- "ContextManager",
68
- "Counter",
69
- "Deque",
70
- "DefaultDict",
71
- "NamedTuple",
72
- "OrderedDict",
73
- "TypedDict",
74
- # Structural checks, a.k.a. protocols.
75
- "SupportsAbs",
76
- "SupportsBytes",
77
- "SupportsComplex",
78
- "SupportsFloat",
79
- "SupportsIndex",
80
- "SupportsInt",
81
- "SupportsRound",
82
- "Reader",
83
- "Writer",
84
- # One-off things.
85
- "Annotated",
86
- "assert_never",
87
- "assert_type",
88
- "clear_overloads",
89
- "dataclass_transform",
90
- "deprecated",
91
- "Doc",
92
- "evaluate_forward_ref",
93
- "get_overloads",
94
- "final",
95
- "Format",
96
- "get_annotations",
97
- "get_args",
98
- "get_origin",
99
- "get_original_bases",
100
- "get_protocol_members",
101
- "get_type_hints",
102
- "IntVar",
103
- "is_protocol",
104
- "is_typeddict",
105
- "Literal",
106
- "NewType",
107
- "overload",
108
- "override",
109
- "Protocol",
110
- "Sentinel",
111
- "reveal_type",
112
- "runtime",
113
- "runtime_checkable",
114
- "Text",
115
- "TypeAlias",
116
- "TypeAliasType",
117
- "TypeForm",
118
- "TypeGuard",
119
- "TypeIs",
120
- "TYPE_CHECKING",
121
- "Never",
122
- "NoReturn",
123
- "ReadOnly",
124
- "Required",
125
- "NotRequired",
126
- "NoDefault",
127
- "NoExtraItems",
128
- # Pure aliases, have always been in typing
129
- "AbstractSet",
130
- "AnyStr",
131
- "BinaryIO",
132
- "Callable",
133
- "Collection",
134
- "Container",
135
- "Dict",
136
- "ForwardRef",
137
- "FrozenSet",
138
- "Generator",
139
- "Generic",
140
- "Hashable",
141
- "IO",
142
- "ItemsView",
143
- "Iterable",
144
- "Iterator",
145
- "KeysView",
146
- "List",
147
- "Mapping",
148
- "MappingView",
149
- "Match",
150
- "MutableMapping",
151
- "MutableSequence",
152
- "MutableSet",
153
- "Optional",
154
- "Pattern",
155
- "Reversible",
156
- "Sequence",
157
- "Set",
158
- "Sized",
159
- "TextIO",
160
- "Tuple",
161
- "Union",
162
- "ValuesView",
163
- "cast",
164
- "no_type_check",
165
- "no_type_check_decorator",
166
- "TypingError",
167
- "get_type_description",
168
- "inspection",
169
- "is_pydantic_basemodel",
170
- "is_pydantic_basemodel_instance",
171
- "is_msgspec_struct",
172
- "is_dataclass",
173
- "is_callable_type",
174
- "is_classvar",
175
- "is_final_type",
176
- "is_forward_ref",
177
- "is_generic_type",
178
- "is_literal_type",
179
- "is_new_type",
180
- "is_optional_type",
181
- "is_union_type",
182
- "is_typevar",
183
- "is_tuple_type",
184
- "get_origin",
185
- "get_args",
186
- "is_union_origin",
187
- "inspect_annotation",
188
- "get_literal_values",
189
- "get_last_args",
190
- "get_last_origin",
191
- "get_generic_bases",
192
- "get_typed_dict_keys",
193
- )
194
-
195
-
196
- class TypingError(Exception):
197
- """An exception raised when a type utility raises an error."""
198
-
199
-
200
- # ------------------------------------------------------------------------
201
- # Inspection Extensions
202
- # ------------------------------------------------------------------------
203
-
204
-
205
- def is_pydantic_basemodel(t: "Any") -> bool:
206
- """Check if an object is a Pydantic BaseModel class or instance using duck typing.
207
-
208
- This function uses duck typing to identify Pydantic BaseModel objects by checking
209
- for the presence of characteristic attributes (`model_fields` and `model_dump`)
210
- without requiring direct imports of Pydantic.
211
-
212
- Args:
213
- t: The object to check. Can be a class, instance, or any other type.
214
-
215
- Returns:
216
- True if the object appears to be a Pydantic BaseModel (class or instance),
217
- False otherwise.
218
-
219
- Example:
220
- >>> from pydantic import BaseModel
221
- >>> class User(BaseModel):
222
- ... name: str
223
- >>> is_pydantic_basemodel(User)
224
- True
225
- >>> is_pydantic_basemodel(User(name="John"))
226
- True
227
- >>> is_pydantic_basemodel(dict)
228
- False
229
- """
230
- # Check if it's a class first
231
- if isinstance(t, type):
232
- return (
233
- hasattr(t, "model_fields")
234
- and hasattr(t, "model_dump")
235
- and callable(getattr(t, "model_dump", None))
236
- )
237
-
238
- # For instances, check the class instead of the instance to avoid deprecation warning
239
- return (
240
- hasattr(t.__class__, "model_fields")
241
- and hasattr(t, "model_dump")
242
- and callable(getattr(t, "model_dump", None))
243
- )
244
-
245
-
246
- def is_pydantic_basemodel_instance(t: "Any") -> bool:
247
- """Check if an object is an instance (not class) of a Pydantic BaseModel using duck typing.
248
-
249
- This function specifically identifies Pydantic BaseModel instances by ensuring
250
- the object is not a type/class itself and has the characteristic Pydantic attributes.
251
-
252
- Args:
253
- t: The object to check.
254
-
255
- Returns:
256
- True if the object is a Pydantic BaseModel instance (not the class itself),
257
- False otherwise.
258
-
259
- Example:
260
- >>> from pydantic import BaseModel
261
- >>> class User(BaseModel):
262
- ... name: str
263
- >>> user = User(name="John")
264
- >>> is_pydantic_basemodel_instance(user)
265
- True
266
- >>> is_pydantic_basemodel_instance(User) # Class, not instance
267
- False
268
- """
269
- return (
270
- not isinstance(t, type)
271
- and hasattr(t.__class__, "model_fields")
272
- and hasattr(t, "model_dump")
273
- and callable(getattr(t, "model_dump", None))
274
- )
275
-
276
-
277
- def is_msgspec_struct(t: "Any") -> bool:
278
- """Check if an object is a msgspec Struct class or instance using duck typing.
279
-
280
- This function uses duck typing to identify msgspec Struct objects by checking
281
- for the presence of characteristic attributes (`__struct_fields__` and
282
- `__struct_config__`) without requiring direct imports of msgspec.
283
-
284
- Args:
285
- t: The object to check. Can be a class, instance, or any other type.
286
-
287
- Returns:
288
- True if the object appears to be a msgspec Struct (class or instance),
289
- False otherwise.
290
-
291
- Example:
292
- >>> import msgspec
293
- >>> class User(msgspec.Struct):
294
- ... name: str
295
- >>> is_msgspec_struct(User)
296
- True
297
- >>> is_msgspec_struct(User(name="John"))
298
- True
299
- >>> is_msgspec_struct(dict)
300
- False
301
- """
302
- return hasattr(t, "__struct_fields__") and hasattr(t, "__struct_config__")
303
-
304
-
305
- def get_type_description(t: "Any") -> str:
306
- """Creates a human-readable description of a type hint.
307
-
308
- Args:
309
- t : The type hint to create a description for.
310
-
311
- Returns:
312
- A human-readable description of the type hint.
313
- """
314
- origin = inspection.get_origin(t)
315
- args = inspection.get_args(t)
316
-
317
- if origin is None:
318
- # Handle basic types that should have special names
319
- if t is list:
320
- return "array"
321
- elif t is dict:
322
- return "object"
323
- elif t is tuple:
324
- return "tuple"
325
- elif hasattr(t, "__name__"):
326
- return t.__name__
327
- return str(t)
328
-
329
- if origin is list:
330
- if args:
331
- return f"array of {get_type_description(args[0])}"
332
- return "array"
333
-
334
- if origin is dict:
335
- if len(args) == 2:
336
- return f"object with {get_type_description(args[0])} keys and {get_type_description(args[1])} values"
337
- return "object"
338
-
339
- if origin is tuple:
340
- if args:
341
- arg_descriptions = [get_type_description(arg) for arg in args]
342
- return f"tuple of ({', '.join(arg_descriptions)})"
343
- return "tuple"
344
-
345
- if inspection.is_literal_type(t):
346
- if args:
347
- values = [repr(arg) for arg in args]
348
- return f"one of: {', '.join(values)}"
349
- return "literal"
350
-
351
- # Handle Union types (including Optional)
352
- if inspection.is_union_type(t):
353
- if inspection.is_optional_type(t):
354
- # This is Optional[T]
355
- non_none_args = [arg for arg in args if arg is not type(None)]
356
- if non_none_args:
357
- return f"optional {get_type_description(non_none_args[0])}"
358
- else:
359
- # This is Union[T1, T2, ...]
360
- arg_descriptions = [get_type_description(arg) for arg in args]
361
- return f"one of: {', '.join(arg_descriptions)}"
362
-
363
- # Handle callable types
364
- if inspection.is_callable_type(t):
365
- if args and len(args) >= 2:
366
- param_types_arg = args[0] # First arg is the parameter types
367
- return_type = args[1] # Second arg is the return type
368
-
369
- # param_types_arg is either a list of types or ... (Ellipsis)
370
- if param_types_arg is ...:
371
- return f"function(...) -> {get_type_description(return_type)}"
372
- elif isinstance(param_types_arg, (list, tuple)):
373
- if param_types_arg:
374
- param_descriptions = [
375
- get_type_description(param) for param in param_types_arg
376
- ]
377
- return f"function({', '.join(param_descriptions)}) -> {get_type_description(return_type)}"
378
- else:
379
- return f"function() -> {get_type_description(return_type)}"
380
- return "function"
381
-
382
- # Handle generic types
383
- if inspection.is_generic_type(t):
384
- if args:
385
- arg_descriptions = [get_type_description(arg) for arg in args]
386
- return f"{origin.__name__}[{', '.join(arg_descriptions)}]"
387
- return str(origin)
388
-
389
- # Handle final types
390
- if inspection.is_final_type(t):
391
- if args:
392
- return f"final {get_type_description(args[0])}"
393
- return "final"
394
-
395
- # Handle forward references
396
- if inspection.is_forward_ref(t):
397
- return f"forward_ref({t.__forward_arg__})"
398
-
399
- # Handle new types
400
- if inspection.is_new_type(t):
401
- return f"new_type({t.__name__})"
402
-
403
- # Handle type variables
404
- if inspection.is_typevar(t):
405
- return f"typevar({t.__name__})"
406
-
407
- return str(t)
hammad/web/__init__.py DELETED
@@ -1,43 +0,0 @@
1
- """hammad.web"""
2
-
3
- from typing import TYPE_CHECKING
4
- from .._core._utils._import_utils import _auto_create_getattr_loader
5
-
6
- if TYPE_CHECKING:
7
- from .utils import (
8
- run_web_request,
9
- read_web_page,
10
- read_web_pages,
11
- search_web,
12
- search_news,
13
- extract_page_links,
14
- )
15
- from .http.client import AsyncHttpClient, HttpClient, create_http_client
16
- from .openapi.client import AsyncOpenAPIClient, OpenAPIClient, create_openapi_client
17
- from .search.client import AsyncSearchClient, SearchClient, create_search_client
18
-
19
- __all__ = (
20
- "run_web_request",
21
- "read_web_page",
22
- "read_web_pages",
23
- "search_web",
24
- "search_news",
25
- "extract_page_links",
26
- "AsyncHttpClient",
27
- "HttpClient",
28
- "create_http_client",
29
- "AsyncOpenAPIClient",
30
- "OpenAPIClient",
31
- "create_openapi_client",
32
- "AsyncSearchClient",
33
- "SearchClient",
34
- "create_search_client",
35
- )
36
-
37
-
38
- __getattr__ = _auto_create_getattr_loader(__all__)
39
-
40
-
41
- def __dir__() -> list[str]:
42
- """Get the attributes of the web module."""
43
- return list(__all__)
@@ -1 +0,0 @@
1
- """hammad.web.http"""