hammad-python 0.0.18__py3-none-any.whl → 0.0.20__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 (83) hide show
  1. hammad/__init__.py +7 -137
  2. hammad/_internal.py +1 -0
  3. hammad/cli/_runner.py +8 -8
  4. hammad/cli/plugins.py +55 -26
  5. hammad/cli/styles/utils.py +16 -8
  6. hammad/data/__init__.py +1 -5
  7. hammad/data/collections/__init__.py +2 -3
  8. hammad/data/collections/collection.py +41 -22
  9. hammad/data/collections/indexes/__init__.py +1 -1
  10. hammad/data/collections/indexes/qdrant/__init__.py +1 -1
  11. hammad/data/collections/indexes/qdrant/index.py +106 -118
  12. hammad/data/collections/indexes/qdrant/settings.py +14 -14
  13. hammad/data/collections/indexes/qdrant/utils.py +28 -38
  14. hammad/data/collections/indexes/tantivy/__init__.py +1 -1
  15. hammad/data/collections/indexes/tantivy/index.py +57 -59
  16. hammad/data/collections/indexes/tantivy/settings.py +8 -19
  17. hammad/data/collections/indexes/tantivy/utils.py +28 -52
  18. hammad/data/models/__init__.py +2 -7
  19. hammad/data/sql/__init__.py +1 -1
  20. hammad/data/sql/database.py +71 -73
  21. hammad/data/sql/types.py +37 -51
  22. hammad/formatting/__init__.py +2 -1
  23. hammad/formatting/json/converters.py +2 -2
  24. hammad/genai/__init__.py +96 -36
  25. hammad/genai/agents/__init__.py +47 -1
  26. hammad/genai/agents/agent.py +1022 -0
  27. hammad/genai/agents/run.py +615 -0
  28. hammad/genai/agents/types/__init__.py +29 -22
  29. hammad/genai/agents/types/agent_context.py +13 -0
  30. hammad/genai/agents/types/agent_event.py +128 -0
  31. hammad/genai/agents/types/agent_hooks.py +220 -0
  32. hammad/genai/agents/types/agent_messages.py +31 -0
  33. hammad/genai/agents/types/agent_response.py +90 -0
  34. hammad/genai/agents/types/agent_stream.py +242 -0
  35. hammad/genai/models/__init__.py +1 -0
  36. hammad/genai/models/embeddings/__init__.py +39 -0
  37. hammad/genai/{embedding_models/embedding_model.py → models/embeddings/model.py} +45 -41
  38. hammad/genai/{embedding_models → models/embeddings}/run.py +10 -8
  39. hammad/genai/models/embeddings/types/__init__.py +37 -0
  40. hammad/genai/{embedding_models → models/embeddings/types}/embedding_model_name.py +2 -4
  41. hammad/genai/{embedding_models → models/embeddings/types}/embedding_model_response.py +11 -4
  42. hammad/genai/{embedding_models/embedding_model_request.py → models/embeddings/types/embedding_model_run_params.py} +4 -3
  43. hammad/genai/models/embeddings/types/embedding_model_settings.py +47 -0
  44. hammad/genai/models/language/__init__.py +48 -0
  45. hammad/genai/{language_models/language_model.py → models/language/model.py} +481 -204
  46. hammad/genai/{language_models → models/language}/run.py +80 -57
  47. hammad/genai/models/language/types/__init__.py +40 -0
  48. hammad/genai/models/language/types/language_model_instructor_mode.py +47 -0
  49. hammad/genai/models/language/types/language_model_messages.py +28 -0
  50. hammad/genai/{language_models/_types.py → models/language/types/language_model_name.py} +3 -40
  51. hammad/genai/{language_models → models/language/types}/language_model_request.py +17 -25
  52. hammad/genai/{language_models → models/language/types}/language_model_response.py +61 -68
  53. hammad/genai/{language_models → models/language/types}/language_model_response_chunk.py +8 -5
  54. hammad/genai/models/language/types/language_model_settings.py +89 -0
  55. hammad/genai/{language_models/_streaming.py → models/language/types/language_model_stream.py} +221 -243
  56. hammad/genai/{language_models/_utils → models/language/utils}/__init__.py +8 -11
  57. hammad/genai/models/language/utils/requests.py +421 -0
  58. hammad/genai/{language_models/_utils/_structured_outputs.py → models/language/utils/structured_outputs.py} +31 -20
  59. hammad/genai/models/model_provider.py +4 -0
  60. hammad/genai/{multimodal_models.py → models/multimodal.py} +4 -5
  61. hammad/genai/models/reranking.py +26 -0
  62. hammad/genai/types/__init__.py +1 -0
  63. hammad/genai/types/base.py +215 -0
  64. hammad/genai/{agents/types → types}/history.py +101 -88
  65. hammad/genai/{agents/types/tool.py → types/tools.py} +156 -141
  66. hammad/logging/logger.py +2 -1
  67. hammad/mcp/client/__init__.py +2 -3
  68. hammad/mcp/client/client.py +10 -10
  69. hammad/mcp/servers/__init__.py +2 -1
  70. hammad/service/decorators.py +1 -3
  71. hammad/web/models.py +1 -3
  72. hammad/web/search/client.py +10 -22
  73. {hammad_python-0.0.18.dist-info → hammad_python-0.0.20.dist-info}/METADATA +10 -2
  74. hammad_python-0.0.20.dist-info/RECORD +127 -0
  75. hammad/genai/embedding_models/__init__.py +0 -41
  76. hammad/genai/language_models/__init__.py +0 -35
  77. hammad/genai/language_models/_utils/_completions.py +0 -131
  78. hammad/genai/language_models/_utils/_messages.py +0 -89
  79. hammad/genai/language_models/_utils/_requests.py +0 -202
  80. hammad/genai/rerank_models.py +0 -26
  81. hammad_python-0.0.18.dist-info/RECORD +0 -111
  82. {hammad_python-0.0.18.dist-info → hammad_python-0.0.20.dist-info}/WHEEL +0 -0
  83. {hammad_python-0.0.18.dist-info → hammad_python-0.0.20.dist-info}/licenses/LICENSE +0 -0
@@ -28,7 +28,7 @@ if TYPE_CHECKING:
28
28
  DistanceMetric,
29
29
  )
30
30
  from ..sql.types import DatabaseItemType
31
- from ...genai.embedding_models.embedding_model_name import EmbeddingModelName
31
+ from ...genai.models.embeddings.types import EmbeddingModelName
32
32
  else:
33
33
  from .indexes.tantivy.index import TantivyCollectionIndex
34
34
  from .indexes.qdrant.index import QdrantCollectionIndex, VectorSearchResult
@@ -44,11 +44,11 @@ class Collection:
44
44
  """
45
45
  A unified collection factory that creates the appropriate collection index type
46
46
  based on the provided parameters.
47
-
47
+
48
48
  This class acts as a factory and doesn't contain its own logic - it simply
49
49
  returns instances of TantivyCollectionIndex or QdrantCollectionIndex based on the
50
50
  vector parameter.
51
-
51
+
52
52
  The main difference from the old approach is that now collections are 'unified'
53
53
  - there's no separate collections interface. Each collection directly uses either
54
54
  a Tantivy or Qdrant index with SQL Database as the storage backend.
@@ -83,7 +83,9 @@ class Collection:
83
83
  distance_metric: "DistanceMetric" = "dot",
84
84
  settings: Optional["QdrantCollectionIndexSettings"] = None,
85
85
  query_settings: Optional["QdrantCollectionIndexQuerySettings"] = None,
86
- embedding_model: Optional["EmbeddingModelName"] = "openai/text-embedding-3-small",
86
+ embedding_model: Optional[
87
+ "EmbeddingModelName"
88
+ ] = "openai/text-embedding-3-small",
87
89
  embedding_dimensions: Optional[int] = None,
88
90
  embedding_api_key: Optional[str] = None,
89
91
  embedding_base_url: Optional[str] = None,
@@ -105,11 +107,20 @@ class Collection:
105
107
  # Tantivy-specific parameters
106
108
  fast: bool = True,
107
109
  # Unified settings parameters
108
- settings: Optional[Union["TantivyCollectionIndexSettings", "QdrantCollectionIndexSettings"]] = None,
109
- query_settings: Optional[Union["TantivyCollectionIndexQuerySettings", "QdrantCollectionIndexQuerySettings"]] = None,
110
+ settings: Optional[
111
+ Union["TantivyCollectionIndexSettings", "QdrantCollectionIndexSettings"]
112
+ ] = None,
113
+ query_settings: Optional[
114
+ Union[
115
+ "TantivyCollectionIndexQuerySettings",
116
+ "QdrantCollectionIndexQuerySettings",
117
+ ]
118
+ ] = None,
110
119
  # Vector/Qdrant-specific parameters
111
120
  distance_metric: "DistanceMetric" = "dot",
112
- embedding_model: Optional["EmbeddingModelName"] = "openai/text-embedding-3-small",
121
+ embedding_model: Optional[
122
+ "EmbeddingModelName"
123
+ ] = "openai/text-embedding-3-small",
113
124
  embedding_dimensions: Optional[int] = None,
114
125
  embedding_api_key: Optional[str] = None,
115
126
  embedding_base_url: Optional[str] = None,
@@ -120,7 +131,7 @@ class Collection:
120
131
  ) -> Union["TantivyCollectionIndex", "QdrantCollectionIndex"]:
121
132
  """
122
133
  Create a collection of the specified type.
123
-
134
+
124
135
  Args:
125
136
  name: Name of the collection
126
137
  schema: Optional schema type for validation
@@ -128,26 +139,26 @@ class Collection:
128
139
  path: File path for storage (None = in-memory)
129
140
  vector: Whether this is a vector collection (True) or text search collection (False)
130
141
  vector_size: Size of vectors (required for vector collections)
131
-
142
+
132
143
  # Tantivy parameters (for non-vector collections):
133
144
  fast: Whether to use fast schema building & indexing
134
-
145
+
135
146
  # Unified parameters:
136
147
  settings: Collection settings (TantivyCollectionIndexSettings or QdrantCollectionIndexSettings)
137
148
  query_settings: Query behavior settings (TantivyCollectionIndexQuerySettings or QdrantCollectionIndexQuerySettings)
138
-
149
+
139
150
  # Qdrant parameters (for vector collections):
140
151
  distance_metric: Distance metric for similarity search
141
152
  embedding_model: The embedding model to use (e.g., 'openai/text-embedding-3-small')
142
153
  embedding_dimensions: Number of dimensions for embeddings
143
154
  embedding_api_key: API key for the embedding service
144
155
  embedding_base_url: Base URL for the embedding service
145
-
156
+
146
157
  # Rerank parameters (for vector collections):
147
158
  rerank_model: The rerank model to use (e.g., 'cohere/rerank-english-v3.0')
148
159
  rerank_api_key: API key for the rerank service
149
160
  rerank_base_url: Base URL for the rerank service
150
-
161
+
151
162
  Returns:
152
163
  A TantivyCollectionIndex or QdrantCollectionIndex instance
153
164
  """
@@ -181,7 +192,7 @@ class Collection:
181
192
  settings=settings,
182
193
  query_settings=query_settings,
183
194
  )
184
-
195
+
185
196
 
186
197
  @overload
187
198
  def create_collection(
@@ -197,6 +208,7 @@ def create_collection(
197
208
  query_settings: Optional["TantivyCollectionIndexQuerySettings"] = None,
198
209
  ) -> "TantivyCollectionIndex": ...
199
210
 
211
+
200
212
  @overload
201
213
  def create_collection(
202
214
  name: str = "default",
@@ -213,6 +225,7 @@ def create_collection(
213
225
  embedding_function: Optional[Callable[[Any], List[float]]] = None,
214
226
  ) -> "QdrantCollectionIndex": ...
215
227
 
228
+
216
229
  def create_collection(
217
230
  name: str = "default",
218
231
  *,
@@ -224,8 +237,14 @@ def create_collection(
224
237
  # Tantivy-specific parameters
225
238
  fast: bool = True,
226
239
  # Unified settings parameters
227
- settings: Optional[Union["TantivyCollectionIndexSettings", "QdrantCollectionIndexSettings"]] = None,
228
- query_settings: Optional[Union["TantivyCollectionIndexQuerySettings", "QdrantCollectionIndexQuerySettings"]] = None,
240
+ settings: Optional[
241
+ Union["TantivyCollectionIndexSettings", "QdrantCollectionIndexSettings"]
242
+ ] = None,
243
+ query_settings: Optional[
244
+ Union[
245
+ "TantivyCollectionIndexQuerySettings", "QdrantCollectionIndexQuerySettings"
246
+ ]
247
+ ] = None,
229
248
  # Vector/Qdrant-specific parameters
230
249
  distance_metric: "DistanceMetric" = "dot",
231
250
  embedding_function: Optional[Callable[[Any], List[float]]] = None,
@@ -233,7 +252,7 @@ def create_collection(
233
252
  """
234
253
  Create a data collection of the specified type. Collections are a unified
235
254
  interface for creating searchable, vectorizable data stores.
236
-
255
+
237
256
  Args:
238
257
  name: Name of the collection
239
258
  schema: Optional schema type for validation
@@ -241,21 +260,21 @@ def create_collection(
241
260
  path: File path for storage (None = in-memory)
242
261
  vector: Whether this is a vector collection (True) or text search collection (False)
243
262
  vector_size: Size of vectors (required for vector collections)
244
-
263
+
245
264
  # Tantivy parameters (for non-vector collections):
246
265
  fast: Whether to use fast schema building & indexing
247
-
266
+
248
267
  # Unified parameters:
249
268
  settings: Collection settings (TantivyCollectionIndexSettings or QdrantCollectionIndexSettings)
250
269
  query_settings: Query behavior settings (TantivyCollectionIndexQuerySettings or QdrantCollectionIndexQuerySettings)
251
-
270
+
252
271
  # Qdrant parameters (for vector collections):
253
272
  distance_metric: Distance metric for similarity search
254
273
  embedding_model: The embedding model to use (e.g., 'openai/text-embedding-3-small')
255
274
  embedding_dimensions: Number of dimensions for embeddings
256
275
  embedding_api_key: API key for the embedding service
257
276
  embedding_base_url: Base URL for the embedding service
258
-
277
+
259
278
  Returns:
260
279
  A TantivyCollectionIndex or QdrantCollectionIndex instance
261
280
  """
@@ -271,4 +290,4 @@ def create_collection(
271
290
  query_settings=query_settings,
272
291
  distance_metric=distance_metric,
273
292
  embedding_function=embedding_function,
274
- )
293
+ )
@@ -34,4 +34,4 @@ __getattr__ = create_getattr_importer(__all__)
34
34
 
35
35
  def __dir__() -> list[str]:
36
36
  """Get the attributes of the hammad.data.collections.indexes module."""
37
- return list(__all__)
37
+ return list(__all__)
@@ -1 +1 @@
1
- """hammad.lib.data.collections.indexes.qdrant"""
1
+ """hammad.lib.data.collections.indexes.qdrant"""