hammad-python 0.0.30__py3-none-any.whl → 0.0.32__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.
- ham/__init__.py +200 -0
- {hammad_python-0.0.30.dist-info → hammad_python-0.0.32.dist-info}/METADATA +6 -32
- hammad_python-0.0.32.dist-info/RECORD +6 -0
- hammad/__init__.py +0 -84
- hammad/_internal.py +0 -256
- hammad/_main.py +0 -226
- hammad/cache/__init__.py +0 -40
- hammad/cache/base_cache.py +0 -181
- hammad/cache/cache.py +0 -169
- hammad/cache/decorators.py +0 -261
- hammad/cache/file_cache.py +0 -80
- hammad/cache/ttl_cache.py +0 -74
- hammad/cli/__init__.py +0 -33
- hammad/cli/animations.py +0 -573
- hammad/cli/plugins.py +0 -867
- hammad/cli/styles/__init__.py +0 -55
- hammad/cli/styles/settings.py +0 -139
- hammad/cli/styles/types.py +0 -358
- hammad/cli/styles/utils.py +0 -634
- hammad/data/__init__.py +0 -90
- hammad/data/collections/__init__.py +0 -49
- hammad/data/collections/collection.py +0 -326
- hammad/data/collections/indexes/__init__.py +0 -37
- hammad/data/collections/indexes/qdrant/__init__.py +0 -1
- hammad/data/collections/indexes/qdrant/index.py +0 -723
- hammad/data/collections/indexes/qdrant/settings.py +0 -94
- hammad/data/collections/indexes/qdrant/utils.py +0 -210
- hammad/data/collections/indexes/tantivy/__init__.py +0 -1
- hammad/data/collections/indexes/tantivy/index.py +0 -426
- hammad/data/collections/indexes/tantivy/settings.py +0 -40
- hammad/data/collections/indexes/tantivy/utils.py +0 -176
- hammad/data/configurations/__init__.py +0 -35
- hammad/data/configurations/configuration.py +0 -564
- hammad/data/models/__init__.py +0 -50
- hammad/data/models/extensions/__init__.py +0 -4
- hammad/data/models/extensions/pydantic/__init__.py +0 -42
- hammad/data/models/extensions/pydantic/converters.py +0 -759
- hammad/data/models/fields.py +0 -546
- hammad/data/models/model.py +0 -1078
- hammad/data/models/utils.py +0 -280
- hammad/data/sql/__init__.py +0 -24
- hammad/data/sql/database.py +0 -576
- hammad/data/sql/types.py +0 -127
- hammad/data/types/__init__.py +0 -75
- hammad/data/types/file.py +0 -431
- hammad/data/types/multimodal/__init__.py +0 -36
- hammad/data/types/multimodal/audio.py +0 -200
- hammad/data/types/multimodal/image.py +0 -182
- hammad/data/types/text.py +0 -1308
- hammad/formatting/__init__.py +0 -33
- hammad/formatting/json/__init__.py +0 -27
- hammad/formatting/json/converters.py +0 -158
- hammad/formatting/text/__init__.py +0 -63
- hammad/formatting/text/converters.py +0 -723
- hammad/formatting/text/markdown.py +0 -131
- hammad/formatting/yaml/__init__.py +0 -26
- hammad/formatting/yaml/converters.py +0 -5
- hammad/genai/__init__.py +0 -217
- hammad/genai/a2a/__init__.py +0 -32
- hammad/genai/a2a/workers.py +0 -552
- hammad/genai/agents/__init__.py +0 -59
- hammad/genai/agents/agent.py +0 -1973
- hammad/genai/agents/run.py +0 -1024
- hammad/genai/agents/types/__init__.py +0 -42
- hammad/genai/agents/types/agent_context.py +0 -13
- hammad/genai/agents/types/agent_event.py +0 -128
- hammad/genai/agents/types/agent_hooks.py +0 -220
- hammad/genai/agents/types/agent_messages.py +0 -31
- hammad/genai/agents/types/agent_response.py +0 -125
- hammad/genai/agents/types/agent_stream.py +0 -327
- hammad/genai/graphs/__init__.py +0 -125
- hammad/genai/graphs/_utils.py +0 -190
- hammad/genai/graphs/base.py +0 -1828
- hammad/genai/graphs/plugins.py +0 -316
- hammad/genai/graphs/types.py +0 -638
- hammad/genai/models/__init__.py +0 -1
- hammad/genai/models/embeddings/__init__.py +0 -43
- hammad/genai/models/embeddings/model.py +0 -226
- hammad/genai/models/embeddings/run.py +0 -163
- hammad/genai/models/embeddings/types/__init__.py +0 -37
- hammad/genai/models/embeddings/types/embedding_model_name.py +0 -75
- hammad/genai/models/embeddings/types/embedding_model_response.py +0 -76
- hammad/genai/models/embeddings/types/embedding_model_run_params.py +0 -66
- hammad/genai/models/embeddings/types/embedding_model_settings.py +0 -47
- hammad/genai/models/language/__init__.py +0 -57
- hammad/genai/models/language/model.py +0 -1098
- hammad/genai/models/language/run.py +0 -878
- hammad/genai/models/language/types/__init__.py +0 -40
- hammad/genai/models/language/types/language_model_instructor_mode.py +0 -47
- hammad/genai/models/language/types/language_model_messages.py +0 -28
- hammad/genai/models/language/types/language_model_name.py +0 -239
- hammad/genai/models/language/types/language_model_request.py +0 -127
- hammad/genai/models/language/types/language_model_response.py +0 -217
- hammad/genai/models/language/types/language_model_response_chunk.py +0 -56
- hammad/genai/models/language/types/language_model_settings.py +0 -89
- hammad/genai/models/language/types/language_model_stream.py +0 -600
- hammad/genai/models/language/utils/__init__.py +0 -28
- hammad/genai/models/language/utils/requests.py +0 -421
- hammad/genai/models/language/utils/structured_outputs.py +0 -135
- hammad/genai/models/model_provider.py +0 -4
- hammad/genai/models/multimodal.py +0 -47
- hammad/genai/models/reranking.py +0 -26
- hammad/genai/types/__init__.py +0 -1
- hammad/genai/types/base.py +0 -215
- hammad/genai/types/history.py +0 -290
- hammad/genai/types/tools.py +0 -507
- hammad/logging/__init__.py +0 -35
- hammad/logging/decorators.py +0 -834
- hammad/logging/logger.py +0 -1018
- hammad/mcp/__init__.py +0 -53
- hammad/mcp/client/__init__.py +0 -35
- hammad/mcp/client/client.py +0 -624
- hammad/mcp/client/client_service.py +0 -400
- hammad/mcp/client/settings.py +0 -178
- hammad/mcp/servers/__init__.py +0 -26
- hammad/mcp/servers/launcher.py +0 -1161
- hammad/runtime/__init__.py +0 -32
- hammad/runtime/decorators.py +0 -142
- hammad/runtime/run.py +0 -299
- hammad/service/__init__.py +0 -49
- hammad/service/create.py +0 -527
- hammad/service/decorators.py +0 -283
- hammad/types.py +0 -288
- hammad/typing/__init__.py +0 -435
- hammad/web/__init__.py +0 -43
- hammad/web/http/__init__.py +0 -1
- hammad/web/http/client.py +0 -944
- hammad/web/models.py +0 -275
- hammad/web/openapi/__init__.py +0 -1
- hammad/web/openapi/client.py +0 -740
- hammad/web/search/__init__.py +0 -1
- hammad/web/search/client.py +0 -1023
- hammad/web/utils.py +0 -472
- hammad_python-0.0.30.dist-info/RECORD +0 -135
- {hammad → ham}/py.typed +0 -0
- {hammad_python-0.0.30.dist-info → hammad_python-0.0.32.dist-info}/WHEEL +0 -0
- {hammad_python-0.0.30.dist-info → hammad_python-0.0.32.dist-info}/licenses/LICENSE +0 -0
hammad/data/__init__.py
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
"""hammad.data"""
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
from .._internal import create_getattr_importer
|
5
|
-
|
6
|
-
if TYPE_CHECKING:
|
7
|
-
from .types import (
|
8
|
-
BaseText,
|
9
|
-
Text,
|
10
|
-
)
|
11
|
-
from .models import (
|
12
|
-
Model,
|
13
|
-
model_settings,
|
14
|
-
field,
|
15
|
-
validator,
|
16
|
-
is_field,
|
17
|
-
is_model,
|
18
|
-
convert_to_pydantic_model,
|
19
|
-
convert_to_pydantic_field,
|
20
|
-
is_pydantic_model_class,
|
21
|
-
)
|
22
|
-
from .models.utils import create_model
|
23
|
-
from .collections import (
|
24
|
-
Collection,
|
25
|
-
create_collection,
|
26
|
-
CollectionType,
|
27
|
-
TantivyCollectionIndex,
|
28
|
-
QdrantCollectionIndex,
|
29
|
-
TantivyCollectionIndexSettings,
|
30
|
-
TantivyCollectionIndexQuerySettings,
|
31
|
-
QdrantCollectionIndexSettings,
|
32
|
-
QdrantCollectionIndexQuerySettings,
|
33
|
-
)
|
34
|
-
from .sql import DatabaseItemType, DatabaseItem, Database, create_database
|
35
|
-
from .configurations import (
|
36
|
-
Configuration,
|
37
|
-
read_configuration_from_file,
|
38
|
-
read_configuration_from_url,
|
39
|
-
read_configuration_from_os_vars,
|
40
|
-
read_configuration_from_os_prefix,
|
41
|
-
read_configuration_from_dotenv,
|
42
|
-
)
|
43
|
-
|
44
|
-
|
45
|
-
__all__ = (
|
46
|
-
# hammad.data.types
|
47
|
-
"BaseText",
|
48
|
-
"Text",
|
49
|
-
# hammad.data.models
|
50
|
-
"Model",
|
51
|
-
"model_settings",
|
52
|
-
"field",
|
53
|
-
"validator",
|
54
|
-
"is_field",
|
55
|
-
"is_model",
|
56
|
-
"convert_to_pydantic_model",
|
57
|
-
"convert_to_pydantic_field",
|
58
|
-
"is_pydantic_model_class",
|
59
|
-
"create_model",
|
60
|
-
# hammad.data.collections
|
61
|
-
"Collection",
|
62
|
-
"create_collection",
|
63
|
-
"CollectionType",
|
64
|
-
"TantivyCollectionIndex",
|
65
|
-
"QdrantCollectionIndex",
|
66
|
-
"TantivyCollectionIndexSettings",
|
67
|
-
"TantivyCollectionIndexQuerySettings",
|
68
|
-
"QdrantCollectionIndexSettings",
|
69
|
-
"QdrantCollectionIndexQuerySettings",
|
70
|
-
# hammad.data.sql
|
71
|
-
"DatabaseItemType",
|
72
|
-
"DatabaseItem",
|
73
|
-
"Database",
|
74
|
-
"create_database",
|
75
|
-
# hammad.data.configurations
|
76
|
-
"Configuration",
|
77
|
-
"read_configuration_from_file",
|
78
|
-
"read_configuration_from_url",
|
79
|
-
"read_configuration_from_os_vars",
|
80
|
-
"read_configuration_from_os_prefix",
|
81
|
-
"read_configuration_from_dotenv",
|
82
|
-
)
|
83
|
-
|
84
|
-
|
85
|
-
__getattr__ = create_getattr_importer(__all__)
|
86
|
-
|
87
|
-
|
88
|
-
def __dir__() -> list[str]:
|
89
|
-
"""Get the attributes of the hammad.data module."""
|
90
|
-
return list(__all__)
|
@@ -1,49 +0,0 @@
|
|
1
|
-
"""hammad.data.collections"""
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
from ..._internal import create_getattr_importer
|
5
|
-
|
6
|
-
if TYPE_CHECKING:
|
7
|
-
from .collection import (
|
8
|
-
Collection,
|
9
|
-
create_collection,
|
10
|
-
CollectionType,
|
11
|
-
)
|
12
|
-
|
13
|
-
from .indexes import (
|
14
|
-
TantivyCollectionIndex,
|
15
|
-
QdrantCollectionIndex,
|
16
|
-
)
|
17
|
-
|
18
|
-
from .indexes.tantivy.settings import (
|
19
|
-
TantivyCollectionIndexSettings,
|
20
|
-
TantivyCollectionIndexQuerySettings,
|
21
|
-
)
|
22
|
-
|
23
|
-
from .indexes.qdrant.settings import (
|
24
|
-
QdrantCollectionIndexSettings,
|
25
|
-
QdrantCollectionIndexQuerySettings,
|
26
|
-
)
|
27
|
-
|
28
|
-
|
29
|
-
__all__ = (
|
30
|
-
# hammad.data.collections.collection
|
31
|
-
"Collection",
|
32
|
-
"create_collection",
|
33
|
-
"CollectionType",
|
34
|
-
# hammad.data.collections.indexes
|
35
|
-
"TantivyCollectionIndex",
|
36
|
-
"QdrantCollectionIndex",
|
37
|
-
"TantivyCollectionIndexSettings",
|
38
|
-
"TantivyCollectionIndexQuerySettings",
|
39
|
-
"QdrantCollectionIndexSettings",
|
40
|
-
"QdrantCollectionIndexQuerySettings",
|
41
|
-
)
|
42
|
-
|
43
|
-
|
44
|
-
__getattr__ = create_getattr_importer(__all__)
|
45
|
-
|
46
|
-
|
47
|
-
def __dir__() -> list[str]:
|
48
|
-
"""Get the attributes of the hammad.data.collections module."""
|
49
|
-
return list(__all__)
|
@@ -1,326 +0,0 @@
|
|
1
|
-
"""hammad.data.collections.collection"""
|
2
|
-
|
3
|
-
from typing import (
|
4
|
-
Literal,
|
5
|
-
Optional,
|
6
|
-
Type,
|
7
|
-
TypeAlias,
|
8
|
-
Union,
|
9
|
-
overload,
|
10
|
-
TYPE_CHECKING,
|
11
|
-
)
|
12
|
-
from pathlib import Path
|
13
|
-
|
14
|
-
if TYPE_CHECKING:
|
15
|
-
from .indexes.tantivy.index import TantivyCollectionIndex
|
16
|
-
from .indexes.qdrant.index import QdrantCollectionIndex, VectorSearchResult
|
17
|
-
from .indexes.tantivy.settings import (
|
18
|
-
TantivyCollectionIndexSettings,
|
19
|
-
TantivyCollectionIndexQuerySettings,
|
20
|
-
)
|
21
|
-
from .indexes.qdrant.settings import (
|
22
|
-
QdrantCollectionIndexSettings,
|
23
|
-
QdrantCollectionIndexQuerySettings,
|
24
|
-
DistanceMetric,
|
25
|
-
)
|
26
|
-
from ..sql.types import DatabaseItemType
|
27
|
-
from ...genai.models.embeddings.types import EmbeddingModelName
|
28
|
-
else:
|
29
|
-
from .indexes.tantivy.index import TantivyCollectionIndex
|
30
|
-
from .indexes.qdrant.index import QdrantCollectionIndex, VectorSearchResult
|
31
|
-
|
32
|
-
|
33
|
-
__all__ = (
|
34
|
-
"Collection",
|
35
|
-
"VectorSearchResult",
|
36
|
-
"CollectionType",
|
37
|
-
)
|
38
|
-
|
39
|
-
|
40
|
-
CollectionType: TypeAlias = Union["TantivyCollectionIndex", "QdrantCollectionIndex"]
|
41
|
-
"""Alias for a type of collection index.
|
42
|
-
|
43
|
-
This is a union of TantivyCollectionIndex and QdrantCollectionIndex.
|
44
|
-
"""
|
45
|
-
|
46
|
-
|
47
|
-
class Collection:
|
48
|
-
"""
|
49
|
-
A unified collection factory that creates the appropriate collection index type
|
50
|
-
based on the provided parameters.
|
51
|
-
|
52
|
-
This class acts as a factory and doesn't contain its own logic - it simply
|
53
|
-
returns instances of TantivyCollectionIndex or QdrantCollectionIndex based on the
|
54
|
-
vector parameter.
|
55
|
-
|
56
|
-
The main difference from the old approach is that now collections are 'unified'
|
57
|
-
- there's no separate collections interface. Each collection directly uses either
|
58
|
-
a Tantivy or Qdrant index with SQL Database as the storage backend.
|
59
|
-
"""
|
60
|
-
|
61
|
-
@overload
|
62
|
-
def __new__(
|
63
|
-
cls,
|
64
|
-
name: str = "default",
|
65
|
-
*,
|
66
|
-
schema: Optional[Type["DatabaseItemType"]] = None,
|
67
|
-
ttl: Optional[int] = None,
|
68
|
-
path: Optional[Union[Path, str]] = None,
|
69
|
-
vector: Literal[False] = False,
|
70
|
-
# Tantivy-specific parameters
|
71
|
-
fast: bool = True,
|
72
|
-
settings: Optional["TantivyCollectionIndexSettings"] = None,
|
73
|
-
query_settings: Optional["TantivyCollectionIndexQuerySettings"] = None,
|
74
|
-
) -> "TantivyCollectionIndex": ...
|
75
|
-
|
76
|
-
@overload
|
77
|
-
def __new__(
|
78
|
-
cls,
|
79
|
-
name: str = "default",
|
80
|
-
*,
|
81
|
-
schema: Optional[Type["DatabaseItemType"]] = None,
|
82
|
-
ttl: Optional[int] = None,
|
83
|
-
path: Optional[Union[Path, str]] = None,
|
84
|
-
vector: Literal[True] = True,
|
85
|
-
vector_size: Optional[int] = None,
|
86
|
-
# Vector/Qdrant-specific parameters
|
87
|
-
distance_metric: "DistanceMetric" = "dot",
|
88
|
-
settings: Optional["QdrantCollectionIndexSettings"] = None,
|
89
|
-
query_settings: Optional["QdrantCollectionIndexQuerySettings"] = None,
|
90
|
-
embedding_model: Optional[
|
91
|
-
"EmbeddingModelName"
|
92
|
-
] = "openai/text-embedding-3-small",
|
93
|
-
embedding_dimensions: Optional[int] = None,
|
94
|
-
embedding_api_key: Optional[str] = None,
|
95
|
-
embedding_base_url: Optional[str] = None,
|
96
|
-
# Rerank-specific parameters
|
97
|
-
rerank_model: Optional[str] = None,
|
98
|
-
rerank_api_key: Optional[str] = None,
|
99
|
-
rerank_base_url: Optional[str] = None,
|
100
|
-
) -> "QdrantCollectionIndex": ...
|
101
|
-
|
102
|
-
def __new__(
|
103
|
-
cls,
|
104
|
-
name: str = "default",
|
105
|
-
*,
|
106
|
-
schema: Optional[Type["DatabaseItemType"]] = None,
|
107
|
-
ttl: Optional[int] = None,
|
108
|
-
path: Optional[Union[Path, str]] = None,
|
109
|
-
vector: bool = False,
|
110
|
-
vector_size: Optional[int] = None,
|
111
|
-
# Tantivy-specific parameters
|
112
|
-
fast: bool = True,
|
113
|
-
# Unified settings parameters
|
114
|
-
settings: Optional[
|
115
|
-
Union["TantivyCollectionIndexSettings", "QdrantCollectionIndexSettings"]
|
116
|
-
] = None,
|
117
|
-
query_settings: Optional[
|
118
|
-
Union[
|
119
|
-
"TantivyCollectionIndexQuerySettings",
|
120
|
-
"QdrantCollectionIndexQuerySettings",
|
121
|
-
]
|
122
|
-
] = None,
|
123
|
-
# Vector/Qdrant-specific parameters
|
124
|
-
distance_metric: "DistanceMetric" = "dot",
|
125
|
-
embedding_model: Optional[
|
126
|
-
"EmbeddingModelName"
|
127
|
-
] = "openai/text-embedding-3-small",
|
128
|
-
embedding_dimensions: Optional[int] = None,
|
129
|
-
embedding_api_key: Optional[str] = None,
|
130
|
-
embedding_base_url: Optional[str] = None,
|
131
|
-
# Rerank-specific parameters
|
132
|
-
rerank_model: Optional[str] = None,
|
133
|
-
rerank_api_key: Optional[str] = None,
|
134
|
-
rerank_base_url: Optional[str] = None,
|
135
|
-
) -> Union["TantivyCollectionIndex", "QdrantCollectionIndex"]:
|
136
|
-
"""
|
137
|
-
Create a collection of the specified type.
|
138
|
-
|
139
|
-
Args:
|
140
|
-
name: Name of the collection
|
141
|
-
schema: Optional schema type for validation
|
142
|
-
ttl: Default TTL for items in seconds
|
143
|
-
path: File path for storage (None = in-memory)
|
144
|
-
vector: Whether this is a vector collection (True) or text search collection (False)
|
145
|
-
vector_size: Size of vectors (required for vector collections)
|
146
|
-
|
147
|
-
# Tantivy parameters (for non-vector collections):
|
148
|
-
fast: Whether to use fast schema building & indexing
|
149
|
-
|
150
|
-
# Unified parameters:
|
151
|
-
settings: Collection settings (TantivyCollectionIndexSettings or QdrantCollectionIndexSettings)
|
152
|
-
query_settings: Query behavior settings (TantivyCollectionIndexQuerySettings or QdrantCollectionIndexQuerySettings)
|
153
|
-
|
154
|
-
# Qdrant parameters (for vector collections):
|
155
|
-
distance_metric: Distance metric for similarity search
|
156
|
-
embedding_model: The embedding model to use (e.g., 'openai/text-embedding-3-small')
|
157
|
-
embedding_dimensions: Number of dimensions for embeddings
|
158
|
-
embedding_api_key: API key for the embedding service
|
159
|
-
embedding_base_url: Base URL for the embedding service
|
160
|
-
|
161
|
-
# Rerank parameters (for vector collections):
|
162
|
-
rerank_model: The rerank model to use (e.g., 'cohere/rerank-english-v3.0')
|
163
|
-
rerank_api_key: API key for the rerank service
|
164
|
-
rerank_base_url: Base URL for the rerank service
|
165
|
-
|
166
|
-
Returns:
|
167
|
-
A TantivyCollectionIndex or QdrantCollectionIndex instance
|
168
|
-
"""
|
169
|
-
if vector:
|
170
|
-
# Vector collection using Qdrant
|
171
|
-
return QdrantCollectionIndex(
|
172
|
-
name=name,
|
173
|
-
vector_size=vector_size,
|
174
|
-
schema=schema,
|
175
|
-
ttl=ttl,
|
176
|
-
path=path,
|
177
|
-
distance_metric=distance_metric,
|
178
|
-
settings=settings,
|
179
|
-
query_settings=query_settings,
|
180
|
-
embedding_model=embedding_model,
|
181
|
-
embedding_dimensions=embedding_dimensions,
|
182
|
-
embedding_api_key=embedding_api_key,
|
183
|
-
embedding_base_url=embedding_base_url,
|
184
|
-
rerank_model=rerank_model,
|
185
|
-
rerank_api_key=rerank_api_key,
|
186
|
-
rerank_base_url=rerank_base_url,
|
187
|
-
)
|
188
|
-
else:
|
189
|
-
# Text search collection using Tantivy
|
190
|
-
return TantivyCollectionIndex(
|
191
|
-
name=name,
|
192
|
-
schema=schema,
|
193
|
-
ttl=ttl,
|
194
|
-
path=path,
|
195
|
-
fast=fast,
|
196
|
-
settings=settings,
|
197
|
-
query_settings=query_settings,
|
198
|
-
)
|
199
|
-
|
200
|
-
|
201
|
-
@overload
|
202
|
-
def create_collection(
|
203
|
-
name: str = "default",
|
204
|
-
*,
|
205
|
-
schema: Optional[Type["DatabaseItemType"]] = None,
|
206
|
-
ttl: Optional[int] = None,
|
207
|
-
path: Optional[Union[Path, str]] = None,
|
208
|
-
vector: Literal[False] = False,
|
209
|
-
# Tantivy-specific parameters
|
210
|
-
fast: bool = True,
|
211
|
-
settings: Optional["TantivyCollectionIndexSettings"] = None,
|
212
|
-
query_settings: Optional["TantivyCollectionIndexQuerySettings"] = None,
|
213
|
-
) -> "TantivyCollectionIndex": ...
|
214
|
-
|
215
|
-
|
216
|
-
@overload
|
217
|
-
def create_collection(
|
218
|
-
name: str = "default",
|
219
|
-
*,
|
220
|
-
schema: Optional[Type["DatabaseItemType"]] = None,
|
221
|
-
ttl: Optional[int] = None,
|
222
|
-
path: Optional[Union[Path, str]] = None,
|
223
|
-
vector: Literal[True],
|
224
|
-
vector_size: Optional[int] = None,
|
225
|
-
# Vector/Qdrant-specific parameters
|
226
|
-
distance_metric: "DistanceMetric" = "dot",
|
227
|
-
settings: Optional["QdrantCollectionIndexSettings"] = None,
|
228
|
-
query_settings: Optional["QdrantCollectionIndexQuerySettings"] = None,
|
229
|
-
embedding_model: Optional[
|
230
|
-
"EmbeddingModelName"
|
231
|
-
] = "openai/text-embedding-3-small",
|
232
|
-
embedding_dimensions: Optional[int] = None,
|
233
|
-
embedding_api_key: Optional[str] = None,
|
234
|
-
embedding_base_url: Optional[str] = None,
|
235
|
-
# Rerank-specific parameters
|
236
|
-
rerank_model: Optional[str] = None,
|
237
|
-
rerank_api_key: Optional[str] = None,
|
238
|
-
rerank_base_url: Optional[str] = None,
|
239
|
-
) -> "QdrantCollectionIndex": ...
|
240
|
-
|
241
|
-
|
242
|
-
def create_collection(
|
243
|
-
name: str = "default",
|
244
|
-
*,
|
245
|
-
schema: Optional[Type["DatabaseItemType"]] = None,
|
246
|
-
ttl: Optional[int] = None,
|
247
|
-
path: Optional[Union[Path, str]] = None,
|
248
|
-
vector: bool = False,
|
249
|
-
vector_size: Optional[int] = None,
|
250
|
-
# Tantivy-specific parameters
|
251
|
-
fast: bool = True,
|
252
|
-
# Unified settings parameters
|
253
|
-
settings: Optional[
|
254
|
-
Union["TantivyCollectionIndexSettings", "QdrantCollectionIndexSettings"]
|
255
|
-
] = None,
|
256
|
-
query_settings: Optional[
|
257
|
-
Union[
|
258
|
-
"TantivyCollectionIndexQuerySettings", "QdrantCollectionIndexQuerySettings"
|
259
|
-
]
|
260
|
-
] = None,
|
261
|
-
# Vector/Qdrant-specific parameters
|
262
|
-
distance_metric: "DistanceMetric" = "dot",
|
263
|
-
embedding_model: Optional[
|
264
|
-
"EmbeddingModelName"
|
265
|
-
] = "openai/text-embedding-3-small",
|
266
|
-
embedding_dimensions: Optional[int] = None,
|
267
|
-
embedding_api_key: Optional[str] = None,
|
268
|
-
embedding_base_url: Optional[str] = None,
|
269
|
-
# Rerank-specific parameters
|
270
|
-
rerank_model: Optional[str] = None,
|
271
|
-
rerank_api_key: Optional[str] = None,
|
272
|
-
rerank_base_url: Optional[str] = None,
|
273
|
-
) -> Union["TantivyCollectionIndex", "QdrantCollectionIndex"]:
|
274
|
-
"""
|
275
|
-
Create a data collection of the specified type. Collections are a unified
|
276
|
-
interface for creating searchable, vectorizable data stores.
|
277
|
-
|
278
|
-
Args:
|
279
|
-
name: Name of the collection
|
280
|
-
schema: Optional schema type for validation
|
281
|
-
ttl: Default TTL for items in seconds
|
282
|
-
path: File path for storage (None = in-memory)
|
283
|
-
vector: Whether this is a vector collection (True) or text search collection (False)
|
284
|
-
vector_size: Size of vectors (required for vector collections)
|
285
|
-
|
286
|
-
# Tantivy parameters (for non-vector collections):
|
287
|
-
fast: Whether to use fast schema building & indexing
|
288
|
-
|
289
|
-
# Unified parameters:
|
290
|
-
settings: Collection settings (TantivyCollectionIndexSettings or QdrantCollectionIndexSettings)
|
291
|
-
query_settings: Query behavior settings (TantivyCollectionIndexQuerySettings or QdrantCollectionIndexQuerySettings)
|
292
|
-
|
293
|
-
# Qdrant parameters (for vector collections):
|
294
|
-
distance_metric: Distance metric for similarity search
|
295
|
-
embedding_model: The embedding model to use (e.g., 'openai/text-embedding-3-small')
|
296
|
-
embedding_dimensions: Number of dimensions for embeddings
|
297
|
-
embedding_api_key: API key for the embedding service
|
298
|
-
embedding_base_url: Base URL for the embedding service
|
299
|
-
|
300
|
-
# Rerank parameters (for vector collections):
|
301
|
-
rerank_model: The rerank model to use (e.g., 'cohere/rerank-english-v3.0')
|
302
|
-
rerank_api_key: API key for the rerank service
|
303
|
-
rerank_base_url: Base URL for the rerank service
|
304
|
-
|
305
|
-
Returns:
|
306
|
-
A TantivyCollectionIndex or QdrantCollectionIndex instance
|
307
|
-
"""
|
308
|
-
return Collection(
|
309
|
-
name=name,
|
310
|
-
schema=schema,
|
311
|
-
ttl=ttl,
|
312
|
-
path=path,
|
313
|
-
vector=vector,
|
314
|
-
vector_size=vector_size,
|
315
|
-
fast=fast,
|
316
|
-
settings=settings,
|
317
|
-
query_settings=query_settings,
|
318
|
-
distance_metric=distance_metric,
|
319
|
-
embedding_model=embedding_model,
|
320
|
-
embedding_dimensions=embedding_dimensions,
|
321
|
-
embedding_api_key=embedding_api_key,
|
322
|
-
embedding_base_url=embedding_base_url,
|
323
|
-
rerank_model=rerank_model,
|
324
|
-
rerank_api_key=rerank_api_key,
|
325
|
-
rerank_base_url=rerank_base_url,
|
326
|
-
)
|
@@ -1,37 +0,0 @@
|
|
1
|
-
"""hammad.data.collections.indexes"""
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
from ...._internal import create_getattr_importer
|
5
|
-
|
6
|
-
if TYPE_CHECKING:
|
7
|
-
from .tantivy.index import TantivyCollectionIndex
|
8
|
-
from .qdrant.index import QdrantCollectionIndex
|
9
|
-
|
10
|
-
from .tantivy.settings import (
|
11
|
-
TantivyCollectionIndexSettings,
|
12
|
-
TantivyCollectionIndexQuerySettings,
|
13
|
-
)
|
14
|
-
from .qdrant.settings import (
|
15
|
-
QdrantCollectionIndexSettings,
|
16
|
-
QdrantCollectionIndexQuerySettings,
|
17
|
-
DistanceMetric,
|
18
|
-
)
|
19
|
-
|
20
|
-
|
21
|
-
__all__ = (
|
22
|
-
"TantivyCollectionIndex",
|
23
|
-
"QdrantCollectionIndex",
|
24
|
-
"TantivyCollectionIndexSettings",
|
25
|
-
"TantivyCollectionIndexQuerySettings",
|
26
|
-
"QdrantCollectionIndexSettings",
|
27
|
-
"QdrantCollectionIndexQuerySettings",
|
28
|
-
"DistanceMetric",
|
29
|
-
)
|
30
|
-
|
31
|
-
|
32
|
-
__getattr__ = create_getattr_importer(__all__)
|
33
|
-
|
34
|
-
|
35
|
-
def __dir__() -> list[str]:
|
36
|
-
"""Get the attributes of the hammad.data.collections.indexes module."""
|
37
|
-
return list(__all__)
|
@@ -1 +0,0 @@
|
|
1
|
-
"""hammad.lib.data.collections.indexes.qdrant"""
|