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
@@ -1,452 +0,0 @@
1
- """hammad.data.collections.collection"""
2
-
3
- from typing import (
4
- TYPE_CHECKING,
5
- Literal,
6
- Optional,
7
- overload,
8
- Any,
9
- List,
10
- Callable,
11
- Union,
12
- )
13
- from typing_extensions import TypedDict
14
-
15
- if TYPE_CHECKING:
16
- from .base_collection import BaseCollection
17
- from .searchable_collection import SearchableCollection
18
- from .vector_collection import VectorCollection
19
-
20
-
21
- Distance = Literal[
22
- "cosine",
23
- "euclidean",
24
- "manhattan",
25
- "hamming",
26
- "dot",
27
- "l2",
28
- "l1",
29
- "l2_squared",
30
- "l1_squared",
31
- "cosine_sim",
32
- "euclidean_sim",
33
- "manhattan_sim",
34
- "hamming_sim",
35
- "dot_sim",
36
- ]
37
-
38
-
39
- class SearchableCollectionSettings(TypedDict, total=False):
40
- """Configuration settings for SearchableCollection using tantivy."""
41
-
42
- heap_size: int
43
- num_threads: Optional[int]
44
- index_path: Optional[str]
45
- schema_builder: Optional[Any]
46
- writer_memory: Optional[int]
47
- reload_policy: Optional[str]
48
-
49
-
50
- class VectorCollectionSettings(TypedDict, total=False):
51
- """Configuration settings for VectorCollection using Qdrant."""
52
-
53
- path: Optional[str]
54
- host: Optional[str]
55
- port: Optional[int]
56
- grpc_port: Optional[int]
57
- prefer_grpc: Optional[bool]
58
- api_key: Optional[str]
59
- timeout: Optional[float]
60
-
61
-
62
- class Collection:
63
- """
64
- A unified collection factory that creates the appropriate collection type
65
- based on the provided parameters.
66
-
67
- This class acts as a factory and doesn't contain its own logic - it simply
68
- returns instances of SearchableCollection or VectorCollection based on the
69
- type parameter.
70
- """
71
-
72
- @overload
73
- def __new__(
74
- cls,
75
- type: Literal["searchable"],
76
- name: str,
77
- *,
78
- schema: Optional[Any] = None,
79
- default_ttl: Optional[int] = None,
80
- storage_backend: Optional[Any] = None,
81
- heap_size: Optional[int] = None,
82
- num_threads: Optional[int] = None,
83
- index_path: Optional[str] = None,
84
- schema_builder: Optional[Any] = None,
85
- writer_memory: Optional[int] = None,
86
- reload_policy: Optional[str] = None,
87
- ) -> "SearchableCollection": ...
88
-
89
- @overload
90
- def __new__(
91
- cls,
92
- type: Literal["vector"],
93
- name: str,
94
- vector_size: int,
95
- *,
96
- schema: Optional[Any] = None,
97
- default_ttl: Optional[int] = None,
98
- storage_backend: Optional[Any] = None,
99
- distance_metric: Optional[Any] = None,
100
- embedding_function: Optional[Callable[[Any], List[float]]] = None,
101
- model: Optional[str] = None,
102
- # Common embedding parameters
103
- format: bool = False,
104
- # LiteLLM parameters
105
- dimensions: Optional[int] = None,
106
- encoding_format: Optional[str] = None,
107
- timeout: Optional[int] = None,
108
- api_base: Optional[str] = None,
109
- api_version: Optional[str] = None,
110
- api_key: Optional[str] = None,
111
- api_type: Optional[str] = None,
112
- caching: bool = False,
113
- user: Optional[str] = None,
114
- # FastEmbed parameters
115
- parallel: Optional[int] = None,
116
- batch_size: Optional[int] = None,
117
- # Qdrant parameters
118
- path: Optional[str] = None,
119
- host: Optional[str] = None,
120
- port: Optional[int] = None,
121
- grpc_port: Optional[int] = None,
122
- prefer_grpc: Optional[bool] = None,
123
- qdrant_timeout: Optional[float] = None,
124
- ) -> "VectorCollection": ...
125
-
126
- def __new__(
127
- cls,
128
- type: Literal["searchable", "vector"],
129
- name: str,
130
- vector_size: Optional[int] = None,
131
- *,
132
- schema: Optional[Any] = None,
133
- default_ttl: Optional[int] = None,
134
- storage_backend: Optional[Any] = None,
135
- distance_metric: Optional[Any] = None,
136
- embedding_function: Optional[Callable[[Any], List[float]]] = None,
137
- model: Optional[str] = None,
138
- # Common embedding parameters
139
- format: bool = False,
140
- # LiteLLM parameters
141
- dimensions: Optional[int] = None,
142
- encoding_format: Optional[str] = None,
143
- timeout: Optional[int] = None,
144
- api_base: Optional[str] = None,
145
- api_version: Optional[str] = None,
146
- api_key: Optional[str] = None,
147
- api_type: Optional[str] = None,
148
- caching: bool = False,
149
- user: Optional[str] = None,
150
- # FastEmbed parameters
151
- parallel: Optional[int] = None,
152
- batch_size: Optional[int] = None,
153
- # Tantivy parameters (searchable collections only)
154
- heap_size: Optional[int] = None,
155
- num_threads: Optional[int] = None,
156
- index_path: Optional[str] = None,
157
- schema_builder: Optional[Any] = None,
158
- writer_memory: Optional[int] = None,
159
- reload_policy: Optional[str] = None,
160
- # Qdrant parameters (vector collections only)
161
- path: Optional[str] = None,
162
- host: Optional[str] = None,
163
- port: Optional[int] = None,
164
- grpc_port: Optional[int] = None,
165
- prefer_grpc: Optional[bool] = None,
166
- qdrant_timeout: Optional[float] = None,
167
- ) -> "BaseCollection":
168
- """
169
- Create a collection of the specified type.
170
-
171
- Args:
172
- type: Type of collection to create ("searchable" or "vector")
173
- name: Name of the collection
174
- vector_size: Size of vectors (required for vector collections)
175
- schema: Optional schema for type validation
176
- default_ttl: Default TTL for items in seconds
177
- storage_backend: Optional storage backend
178
- distance_metric: Distance metric for similarity search (vector collections only)
179
- embedding_function: Function to convert objects to vectors (vector collections only)
180
-
181
- Tantivy parameters (searchable collections only):
182
- heap_size: Memory allocation for tantivy heap
183
- num_threads: Number of threads for tantivy operations
184
- index_path: Path to store tantivy index files
185
- schema_builder: Custom schema builder for tantivy
186
- writer_memory: Memory allocation for tantivy writer
187
- reload_policy: Policy for reloading tantivy index
188
-
189
- Qdrant parameters (vector collections only):
190
- path: Path for local Qdrant storage
191
- host: Qdrant server host
192
- port: Qdrant server port
193
- grpc_port: Qdrant gRPC port
194
- prefer_grpc: Whether to prefer gRPC over HTTP
195
- api_key: API key for Qdrant authentication
196
- timeout: Request timeout for Qdrant operations
197
-
198
- Returns:
199
- A SearchableCollection or VectorCollection instance
200
- """
201
- if type == "searchable":
202
- from .searchable_collection import SearchableCollection
203
-
204
- # Build tantivy config from individual parameters
205
- tantivy_config = {}
206
- if heap_size is not None:
207
- tantivy_config["heap_size"] = heap_size
208
- if num_threads is not None:
209
- tantivy_config["num_threads"] = num_threads
210
- if index_path is not None:
211
- tantivy_config["index_path"] = index_path
212
- if schema_builder is not None:
213
- tantivy_config["schema_builder"] = schema_builder
214
- if writer_memory is not None:
215
- tantivy_config["writer_memory"] = writer_memory
216
- if reload_policy is not None:
217
- tantivy_config["reload_policy"] = reload_policy
218
-
219
- return SearchableCollection(
220
- name=name,
221
- schema=schema,
222
- default_ttl=default_ttl,
223
- storage_backend=storage_backend,
224
- tantivy_config=tantivy_config if tantivy_config else None,
225
- )
226
- elif type == "vector":
227
- if vector_size is None:
228
- raise ValueError("vector_size is required for vector collections")
229
-
230
- try:
231
- from .vector_collection import VectorCollection, Distance
232
- except ImportError:
233
- raise ImportError(
234
- "qdrant-client is required for vector collections. "
235
- "Please install it with 'pip install qdrant-client'."
236
- )
237
-
238
- # Set default distance metric if not provided and Distance is available
239
- if distance_metric is None and Distance is not None:
240
- distance_metric = Distance.DOT
241
-
242
- # Build qdrant config from individual parameters
243
- qdrant_config = {}
244
- if path is not None:
245
- qdrant_config["path"] = path
246
- if host is not None:
247
- qdrant_config["host"] = host
248
- if port is not None:
249
- qdrant_config["port"] = port
250
- if grpc_port is not None:
251
- qdrant_config["grpc_port"] = grpc_port
252
- if prefer_grpc is not None:
253
- qdrant_config["prefer_grpc"] = prefer_grpc
254
- if qdrant_timeout is not None:
255
- qdrant_config["timeout"] = qdrant_timeout
256
-
257
- return VectorCollection(
258
- name=name,
259
- vector_size=vector_size,
260
- schema=schema,
261
- default_ttl=default_ttl,
262
- storage_backend=storage_backend,
263
- distance_metric=distance_metric,
264
- qdrant_config=qdrant_config if qdrant_config else None,
265
- embedding_function=embedding_function,
266
- model=model,
267
- # Common embedding parameters
268
- format=format,
269
- # LiteLLM parameters
270
- dimensions=dimensions,
271
- encoding_format=encoding_format,
272
- timeout=timeout,
273
- api_base=api_base,
274
- api_version=api_version,
275
- api_key=api_key,
276
- api_type=api_type,
277
- caching=caching,
278
- user=user,
279
- # FastEmbed parameters
280
- parallel=parallel,
281
- batch_size=batch_size,
282
- )
283
- else:
284
- raise ValueError(f"Unsupported collection type: {type}")
285
-
286
-
287
- @overload
288
- def create_collection(
289
- type: Literal["searchable"],
290
- name: str,
291
- *,
292
- schema: Optional[Any] = None,
293
- default_ttl: Optional[int] = None,
294
- storage_backend: Optional[Any] = None,
295
- heap_size: Optional[int] = None,
296
- num_threads: Optional[int] = None,
297
- index_path: Optional[str] = None,
298
- schema_builder: Optional[Any] = None,
299
- writer_memory: Optional[int] = None,
300
- reload_policy: Optional[str] = None,
301
- ) -> "SearchableCollection": ...
302
-
303
-
304
- @overload
305
- def create_collection(
306
- type: Literal["vector"],
307
- name: str,
308
- vector_size: int,
309
- *,
310
- schema: Optional[Any] = None,
311
- default_ttl: Optional[int] = None,
312
- storage_backend: Optional[Any] = None,
313
- distance_metric: Optional[Any] = None,
314
- embedding_function: Optional[Callable[[Any], List[float]]] = None,
315
- model: Optional[str] = None,
316
- # Common embedding parameters
317
- format: bool = False,
318
- # LiteLLM parameters
319
- dimensions: Optional[int] = None,
320
- encoding_format: Optional[str] = None,
321
- timeout: Optional[int] = None,
322
- api_base: Optional[str] = None,
323
- api_version: Optional[str] = None,
324
- api_key: Optional[str] = None,
325
- api_type: Optional[str] = None,
326
- caching: bool = False,
327
- user: Optional[str] = None,
328
- # FastEmbed parameters
329
- parallel: Optional[int] = None,
330
- batch_size: Optional[int] = None,
331
- # Qdrant parameters
332
- path: Optional[str] = None,
333
- host: Optional[str] = None,
334
- port: Optional[int] = None,
335
- grpc_port: Optional[int] = None,
336
- prefer_grpc: Optional[bool] = None,
337
- qdrant_timeout: Optional[float] = None,
338
- ) -> "VectorCollection": ...
339
-
340
-
341
- def create_collection(
342
- type: Literal["searchable", "vector"],
343
- name: str,
344
- vector_size: Optional[int] = None,
345
- *,
346
- schema: Optional[Any] = None,
347
- default_ttl: Optional[int] = None,
348
- storage_backend: Optional[Any] = None,
349
- distance_metric: Optional[Any] = None,
350
- embedding_function: Optional[Callable[[Any], List[float]]] = None,
351
- model: Optional[str] = None,
352
- # Common embedding parameters
353
- format: bool = False,
354
- # LiteLLM parameters
355
- dimensions: Optional[int] = None,
356
- encoding_format: Optional[str] = None,
357
- timeout: Optional[int] = None,
358
- api_base: Optional[str] = None,
359
- api_version: Optional[str] = None,
360
- api_key: Optional[str] = None,
361
- api_type: Optional[str] = None,
362
- caching: bool = False,
363
- user: Optional[str] = None,
364
- # FastEmbed parameters
365
- parallel: Optional[int] = None,
366
- batch_size: Optional[int] = None,
367
- # Tantivy parameters (searchable collections only)
368
- heap_size: Optional[int] = None,
369
- num_threads: Optional[int] = None,
370
- index_path: Optional[str] = None,
371
- schema_builder: Optional[Any] = None,
372
- writer_memory: Optional[int] = None,
373
- reload_policy: Optional[str] = None,
374
- # Qdrant parameters (vector collections only)
375
- path: Optional[str] = None,
376
- host: Optional[str] = None,
377
- port: Optional[int] = None,
378
- grpc_port: Optional[int] = None,
379
- prefer_grpc: Optional[bool] = None,
380
- qdrant_timeout: Optional[float] = None,
381
- ) -> "BaseCollection":
382
- """
383
- Create a collection of the specified type.
384
-
385
- This function provides a factory pattern for creating collections.
386
- Use the Collection class for a more object-oriented approach.
387
-
388
- Args:
389
- type: Type of collection to create ("searchable" or "vector")
390
- name: Name of the collection
391
- vector_size: Size of vectors (required for vector collections)
392
- schema: Optional schema for type validation
393
- default_ttl: Default TTL for items in seconds
394
- storage_backend: Optional storage backend
395
- distance_metric: Distance metric for similarity search (vector collections only)
396
- embedding_function: Function to convert objects to vectors (vector collections only)
397
-
398
- Tantivy parameters (searchable collections only):
399
- heap_size: Memory allocation for tantivy heap
400
- num_threads: Number of threads for tantivy operations
401
- index_path: Path to store tantivy index files
402
- schema_builder: Custom schema builder for tantivy
403
- writer_memory: Memory allocation for tantivy writer
404
- reload_policy: Policy for reloading tantivy index
405
-
406
- Qdrant parameters (vector collections only):
407
- path: Path for local Qdrant storage
408
- host: Qdrant server host
409
- port: Qdrant server port
410
- grpc_port: Qdrant gRPC port
411
- prefer_grpc: Whether to prefer gRPC over HTTP
412
- api_key: API key for Qdrant authentication
413
- timeout: Request timeout for Qdrant operations
414
-
415
- Returns:
416
- A SearchableCollection or VectorCollection instance
417
- """
418
- return Collection(
419
- type=type,
420
- name=name,
421
- vector_size=vector_size,
422
- schema=schema,
423
- default_ttl=default_ttl,
424
- storage_backend=storage_backend,
425
- distance_metric=distance_metric,
426
- embedding_function=embedding_function,
427
- model=model,
428
- format=format,
429
- dimensions=dimensions,
430
- encoding_format=encoding_format,
431
- timeout=timeout,
432
- api_base=api_base,
433
- api_version=api_version,
434
- api_key=api_key,
435
- api_type=api_type,
436
- caching=caching,
437
- user=user,
438
- parallel=parallel,
439
- batch_size=batch_size,
440
- heap_size=heap_size,
441
- num_threads=num_threads,
442
- index_path=index_path,
443
- schema_builder=schema_builder,
444
- writer_memory=writer_memory,
445
- reload_policy=reload_policy,
446
- path=path,
447
- host=host,
448
- port=port,
449
- grpc_port=grpc_port,
450
- prefer_grpc=prefer_grpc,
451
- qdrant_timeout=qdrant_timeout,
452
- )