hammad-python 0.0.29__py3-none-any.whl → 0.0.31__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 (137) hide show
  1. ham/__init__.py +10 -0
  2. {hammad_python-0.0.29.dist-info → hammad_python-0.0.31.dist-info}/METADATA +6 -32
  3. hammad_python-0.0.31.dist-info/RECORD +6 -0
  4. hammad/__init__.py +0 -84
  5. hammad/_internal.py +0 -256
  6. hammad/_main.py +0 -226
  7. hammad/cache/__init__.py +0 -40
  8. hammad/cache/base_cache.py +0 -181
  9. hammad/cache/cache.py +0 -169
  10. hammad/cache/decorators.py +0 -261
  11. hammad/cache/file_cache.py +0 -80
  12. hammad/cache/ttl_cache.py +0 -74
  13. hammad/cli/__init__.py +0 -33
  14. hammad/cli/animations.py +0 -573
  15. hammad/cli/plugins.py +0 -867
  16. hammad/cli/styles/__init__.py +0 -55
  17. hammad/cli/styles/settings.py +0 -139
  18. hammad/cli/styles/types.py +0 -358
  19. hammad/cli/styles/utils.py +0 -634
  20. hammad/data/__init__.py +0 -90
  21. hammad/data/collections/__init__.py +0 -49
  22. hammad/data/collections/collection.py +0 -326
  23. hammad/data/collections/indexes/__init__.py +0 -37
  24. hammad/data/collections/indexes/qdrant/__init__.py +0 -1
  25. hammad/data/collections/indexes/qdrant/index.py +0 -723
  26. hammad/data/collections/indexes/qdrant/settings.py +0 -94
  27. hammad/data/collections/indexes/qdrant/utils.py +0 -210
  28. hammad/data/collections/indexes/tantivy/__init__.py +0 -1
  29. hammad/data/collections/indexes/tantivy/index.py +0 -426
  30. hammad/data/collections/indexes/tantivy/settings.py +0 -40
  31. hammad/data/collections/indexes/tantivy/utils.py +0 -176
  32. hammad/data/configurations/__init__.py +0 -35
  33. hammad/data/configurations/configuration.py +0 -564
  34. hammad/data/models/__init__.py +0 -50
  35. hammad/data/models/extensions/__init__.py +0 -4
  36. hammad/data/models/extensions/pydantic/__init__.py +0 -42
  37. hammad/data/models/extensions/pydantic/converters.py +0 -759
  38. hammad/data/models/fields.py +0 -546
  39. hammad/data/models/model.py +0 -1078
  40. hammad/data/models/utils.py +0 -280
  41. hammad/data/sql/__init__.py +0 -24
  42. hammad/data/sql/database.py +0 -576
  43. hammad/data/sql/types.py +0 -127
  44. hammad/data/types/__init__.py +0 -75
  45. hammad/data/types/file.py +0 -431
  46. hammad/data/types/multimodal/__init__.py +0 -36
  47. hammad/data/types/multimodal/audio.py +0 -200
  48. hammad/data/types/multimodal/image.py +0 -182
  49. hammad/data/types/text.py +0 -1308
  50. hammad/formatting/__init__.py +0 -33
  51. hammad/formatting/json/__init__.py +0 -27
  52. hammad/formatting/json/converters.py +0 -158
  53. hammad/formatting/text/__init__.py +0 -63
  54. hammad/formatting/text/converters.py +0 -723
  55. hammad/formatting/text/markdown.py +0 -131
  56. hammad/formatting/yaml/__init__.py +0 -26
  57. hammad/formatting/yaml/converters.py +0 -5
  58. hammad/genai/__init__.py +0 -217
  59. hammad/genai/a2a/__init__.py +0 -32
  60. hammad/genai/a2a/workers.py +0 -552
  61. hammad/genai/agents/__init__.py +0 -59
  62. hammad/genai/agents/agent.py +0 -1973
  63. hammad/genai/agents/run.py +0 -1024
  64. hammad/genai/agents/types/__init__.py +0 -42
  65. hammad/genai/agents/types/agent_context.py +0 -13
  66. hammad/genai/agents/types/agent_event.py +0 -128
  67. hammad/genai/agents/types/agent_hooks.py +0 -220
  68. hammad/genai/agents/types/agent_messages.py +0 -31
  69. hammad/genai/agents/types/agent_response.py +0 -125
  70. hammad/genai/agents/types/agent_stream.py +0 -327
  71. hammad/genai/graphs/__init__.py +0 -125
  72. hammad/genai/graphs/_utils.py +0 -190
  73. hammad/genai/graphs/base.py +0 -1828
  74. hammad/genai/graphs/plugins.py +0 -316
  75. hammad/genai/graphs/types.py +0 -638
  76. hammad/genai/models/__init__.py +0 -1
  77. hammad/genai/models/embeddings/__init__.py +0 -43
  78. hammad/genai/models/embeddings/model.py +0 -226
  79. hammad/genai/models/embeddings/run.py +0 -163
  80. hammad/genai/models/embeddings/types/__init__.py +0 -37
  81. hammad/genai/models/embeddings/types/embedding_model_name.py +0 -75
  82. hammad/genai/models/embeddings/types/embedding_model_response.py +0 -76
  83. hammad/genai/models/embeddings/types/embedding_model_run_params.py +0 -66
  84. hammad/genai/models/embeddings/types/embedding_model_settings.py +0 -47
  85. hammad/genai/models/language/__init__.py +0 -57
  86. hammad/genai/models/language/model.py +0 -1098
  87. hammad/genai/models/language/run.py +0 -878
  88. hammad/genai/models/language/types/__init__.py +0 -40
  89. hammad/genai/models/language/types/language_model_instructor_mode.py +0 -47
  90. hammad/genai/models/language/types/language_model_messages.py +0 -28
  91. hammad/genai/models/language/types/language_model_name.py +0 -239
  92. hammad/genai/models/language/types/language_model_request.py +0 -127
  93. hammad/genai/models/language/types/language_model_response.py +0 -217
  94. hammad/genai/models/language/types/language_model_response_chunk.py +0 -56
  95. hammad/genai/models/language/types/language_model_settings.py +0 -89
  96. hammad/genai/models/language/types/language_model_stream.py +0 -600
  97. hammad/genai/models/language/utils/__init__.py +0 -28
  98. hammad/genai/models/language/utils/requests.py +0 -421
  99. hammad/genai/models/language/utils/structured_outputs.py +0 -135
  100. hammad/genai/models/model_provider.py +0 -4
  101. hammad/genai/models/multimodal.py +0 -47
  102. hammad/genai/models/reranking.py +0 -26
  103. hammad/genai/types/__init__.py +0 -1
  104. hammad/genai/types/base.py +0 -215
  105. hammad/genai/types/history.py +0 -290
  106. hammad/genai/types/tools.py +0 -507
  107. hammad/logging/__init__.py +0 -35
  108. hammad/logging/decorators.py +0 -834
  109. hammad/logging/logger.py +0 -1018
  110. hammad/mcp/__init__.py +0 -53
  111. hammad/mcp/client/__init__.py +0 -35
  112. hammad/mcp/client/client.py +0 -624
  113. hammad/mcp/client/client_service.py +0 -400
  114. hammad/mcp/client/settings.py +0 -178
  115. hammad/mcp/servers/__init__.py +0 -26
  116. hammad/mcp/servers/launcher.py +0 -1161
  117. hammad/runtime/__init__.py +0 -32
  118. hammad/runtime/decorators.py +0 -142
  119. hammad/runtime/run.py +0 -299
  120. hammad/service/__init__.py +0 -49
  121. hammad/service/create.py +0 -527
  122. hammad/service/decorators.py +0 -283
  123. hammad/types.py +0 -288
  124. hammad/typing/__init__.py +0 -435
  125. hammad/web/__init__.py +0 -43
  126. hammad/web/http/__init__.py +0 -1
  127. hammad/web/http/client.py +0 -944
  128. hammad/web/models.py +0 -275
  129. hammad/web/openapi/__init__.py +0 -1
  130. hammad/web/openapi/client.py +0 -740
  131. hammad/web/search/__init__.py +0 -1
  132. hammad/web/search/client.py +0 -1023
  133. hammad/web/utils.py +0 -472
  134. hammad_python-0.0.29.dist-info/RECORD +0 -135
  135. {hammad → ham}/py.typed +0 -0
  136. {hammad_python-0.0.29.dist-info → hammad_python-0.0.31.dist-info}/WHEEL +0 -0
  137. {hammad_python-0.0.29.dist-info → hammad_python-0.0.31.dist-info}/licenses/LICENSE +0 -0
@@ -1,226 +0,0 @@
1
- """hammad.genai.embedding_models.embedding_model"""
2
-
3
- import asyncio
4
- from dataclasses import dataclass, field
5
- from typing import Any, List, Optional
6
- import sys
7
-
8
- if sys.version_info >= (3, 12):
9
- from typing import TypedDict
10
- else:
11
- from typing_extensions import TypedDict
12
-
13
- from ..model_provider import litellm
14
-
15
- from .types import (
16
- EmbeddingModelName,
17
- EmbeddingModelRunParams,
18
- EmbeddingModelSettings,
19
- Embedding,
20
- EmbeddingUsage,
21
- EmbeddingModelResponse,
22
- )
23
- from ....formatting.text import convert_to_text
24
-
25
-
26
- __all__ = (
27
- "EmbeddingModel",
28
- "EmbeddingModelError",
29
- "create_embedding_model",
30
- )
31
-
32
-
33
- class EmbeddingModelError(Exception):
34
- """Exception raised when an error occurs while generating embeddings
35
- using an embedding model."""
36
-
37
- def __init__(self, message: str, response: Any):
38
- self.message = message
39
- self.response = response
40
- super().__init__(self.message)
41
-
42
-
43
- def _parse_litellm_response_to_embedding_model_response(
44
- response: "litellm.EmbeddingResponse",
45
- ) -> EmbeddingModelResponse:
46
- """Parse the response from `litellm` to an `EmbeddingModelResponse` object."""
47
- try:
48
- embedding_data: List[Embedding] = []
49
-
50
- for i, item in enumerate(response.data):
51
- embedding_data.append(
52
- Embedding(embedding=item["embedding"], index=i, object="embedding")
53
- )
54
- usage = EmbeddingUsage(
55
- prompt_tokens=response.usage.prompt_tokens,
56
- total_tokens=response.usage.total_tokens,
57
- )
58
- return EmbeddingModelResponse(
59
- output=embedding_data,
60
- model=response.model,
61
- object="list",
62
- usage=usage,
63
- type="embedding_model",
64
- )
65
- except Exception as e:
66
- raise EmbeddingModelError(
67
- f"Failed to parse litellm response to embedding response: {e}",
68
- response,
69
- )
70
-
71
-
72
- @dataclass
73
- class EmbeddingModel:
74
- """Embeddings provider client that utilizes the `litellm` module
75
- when generating embeddings."""
76
-
77
- model: EmbeddingModelName | str = "openai/text-embedding-3-small"
78
-
79
- base_url: Optional[str] = None
80
- """Optional base URL for a custom embedding provider."""
81
-
82
- api_key: Optional[str] = None
83
- """Optional API key for a custom embedding provider."""
84
-
85
- api_type: Optional[str] = None
86
- """Optional API type for a custom embedding provider."""
87
-
88
- api_version: Optional[str] = None
89
- """Optional API version for a custom embedding provider."""
90
-
91
- settings: EmbeddingModelSettings = field(default_factory=EmbeddingModelSettings)
92
- """Optional settings for the embedding model."""
93
-
94
- async def async_run(
95
- self,
96
- input: List[Any] | Any,
97
- dimensions: Optional[int] = None,
98
- encoding_format: Optional[str] = None,
99
- timeout=600,
100
- caching: bool = False,
101
- user: Optional[str] = None,
102
- format: bool = False,
103
- ) -> EmbeddingModelResponse:
104
- """Asynchronously generate embeddings for the given input using
105
- a valid `litellm` model.
106
-
107
- Args:
108
- input (List[Any] | Any) : The input text / content to generate embeddings for.
109
- dimensions (Optional[int]) : The number of dimensions for the embedding.
110
- encoding_format (Optional[str]) : The format to return the embeddings in. (e.g. "float", "base64")
111
- timeout (int) : The timeout for the request.
112
- api_base (Optional[str]) : The base URL for the API.
113
- api_version (Optional[str]) : The version of the API.
114
- api_key (Optional[str]) : The API key to use for the request.
115
- api_type (Optional[str]) : The API type to use for the request.
116
- caching (bool) : Whether to cache the request.
117
- user (Optional[str]) : The user to use for the request.
118
- format (bool) : Whether to format each non-string input as a markdown string.
119
-
120
- Returns:
121
- EmbeddingModelResponse : The embedding response generated for the given input.
122
- """
123
- if not isinstance(input, list):
124
- input = [input]
125
-
126
- if format:
127
- for i in input:
128
- try:
129
- i = convert_to_text(i)
130
- except Exception as e:
131
- raise EmbeddingModelError(
132
- f"Failed to format input to text: {e}",
133
- i,
134
- )
135
-
136
- async_embedding_fn = litellm.aembedding
137
-
138
- try:
139
- response = await async_embedding_fn(
140
- model=self.model,
141
- input=input,
142
- dimensions=dimensions or self.settings.dimensions,
143
- encoding_format=encoding_format or self.settings.encoding_format,
144
- timeout=timeout or self.settings.timeout,
145
- api_base=self.base_url or self.settings.api_base,
146
- api_version=self.api_version or self.settings.api_version,
147
- api_key=self.api_key or self.settings.api_key,
148
- api_type=self.api_type or self.settings.api_type,
149
- caching=caching or self.settings.caching,
150
- user=user or self.settings.user,
151
- )
152
- except Exception as e:
153
- raise EmbeddingModelError(
154
- f"Error in embedding model request: {e}", response=None
155
- ) from e
156
-
157
- return _parse_litellm_response_to_embedding_model_response(response)
158
-
159
- def run(
160
- self,
161
- input: List[Any] | Any,
162
- dimensions: Optional[int] = None,
163
- encoding_format: Optional[str] = None,
164
- timeout=600,
165
- caching: bool = False,
166
- user: Optional[str] = None,
167
- format: bool = False,
168
- ) -> EmbeddingModelResponse:
169
- """Generate embeddings for the given input using
170
- a valid `litellm` model.
171
-
172
- Args:
173
- input (List[Any] | Any) : The input text / content to generate embeddings for.
174
- dimensions (Optional[int]) : The number of dimensions for the embedding.
175
- encoding_format (Optional[str]) : The format to return the embeddings in. (e.g. "float", "base64")
176
- timeout (int) : The timeout for the request.
177
- api_base (Optional[str]) : The base URL for the API.
178
- api_version (Optional[str]) : The version of the API.
179
- api_key (Optional[str]) : The API key to use for the request.
180
- api_type (Optional[str]) : The API type to use for the request.
181
- caching (bool) : Whether to cache the request.
182
- user (Optional[str]) : The user to use for the request.
183
- format (bool) : Whether to format each non-string input as a markdown string.
184
-
185
- Returns:
186
- EmbeddingModelResponse : The embedding response generated for the given input.
187
- """
188
- return asyncio.run(
189
- self.async_run(
190
- input=input,
191
- dimensions=dimensions,
192
- encoding_format=encoding_format,
193
- timeout=timeout,
194
- caching=caching,
195
- user=user,
196
- format=format,
197
- )
198
- )
199
-
200
-
201
- def create_embedding_model(
202
- model: str | EmbeddingModelName = "openai/text-embedding-3-small",
203
- base_url: Optional[str] = None,
204
- api_key: Optional[str] = None,
205
- api_version: Optional[str] = None,
206
- api_type: Optional[str] = None,
207
- settings: Optional[EmbeddingModelSettings] = None,
208
- ) -> EmbeddingModel:
209
- """Create an embedding model instance.
210
-
211
- Args:
212
- model (str | EmbeddingModelName) : The model to use for the embedding.
213
- base_url (Optional[str]) : The base URL for the API.
214
- api_key (Optional[str]) : The API key to use for the request.
215
- api_version (Optional[str]) : The version of the API.
216
- api_type (Optional[str]) : The API type to use for the request.
217
- settings (Optional[EmbeddingModelSettings]) : The settings for the embedding model.
218
- """
219
- return EmbeddingModel(
220
- model=model,
221
- base_url=base_url,
222
- api_key=api_key,
223
- api_version=api_version,
224
- api_type=api_type,
225
- settings=settings or EmbeddingModelSettings(),
226
- )
@@ -1,163 +0,0 @@
1
- """hammad.genai.embedding_models.run
2
-
3
- Standalone functions for running embedding models with full parameter typing.
4
- """
5
-
6
- from typing import Any, List, Optional, overload, Union
7
-
8
- from .types import (
9
- EmbeddingModelName,
10
- EmbeddingModelResponse,
11
- )
12
- from .model import EmbeddingModel
13
-
14
- __all__ = [
15
- "run_embedding_model",
16
- "async_run_embedding_model",
17
- ]
18
-
19
-
20
- # Overloads for run_embedding_model
21
- @overload
22
- def run_embedding_model(
23
- input: List[Any] | Any,
24
- *,
25
- # Provider settings
26
- model: EmbeddingModelName = "openai/text-embedding-3-small",
27
- api_base: Optional[str] = None,
28
- api_key: Optional[str] = None,
29
- api_version: Optional[str] = None,
30
- api_type: Optional[str] = None,
31
- # Extended settings
32
- dimensions: Optional[int] = None,
33
- encoding_format: Optional[str] = None,
34
- timeout: int = 600,
35
- caching: bool = False,
36
- user: Optional[str] = None,
37
- format: bool = False,
38
- ) -> EmbeddingModelResponse: ...
39
-
40
-
41
- def run_embedding_model(
42
- input: List[Any] | Any,
43
- *,
44
- # Provider settings
45
- model: EmbeddingModelName = "openai/text-embedding-3-small",
46
- api_base: Optional[str] = None,
47
- api_key: Optional[str] = None,
48
- api_version: Optional[str] = None,
49
- api_type: Optional[str] = None,
50
- # Extended settings
51
- dimensions: Optional[int] = None,
52
- encoding_format: Optional[str] = None,
53
- timeout: int = 600,
54
- caching: bool = False,
55
- user: Optional[str] = None,
56
- format: bool = False,
57
- ) -> EmbeddingModelResponse:
58
- """Run an embedding model with the given input.
59
-
60
- Args:
61
- input: The input text/content to generate embeddings for
62
- model: The embedding model to use
63
- api_base: The base URL for the API
64
- api_key: The API key to use for the request
65
- api_version: The version of the API
66
- api_type: The API type to use for the request
67
- dimensions: The number of dimensions for the embedding
68
- encoding_format: The format to return the embeddings in
69
- timeout: The timeout for the request
70
- caching: Whether to cache the request
71
- user: The user to use for the request
72
- format: Whether to format each non-string input as a markdown string
73
-
74
- Returns:
75
- EmbeddingModelResponse: The embedding response
76
- """
77
- embedding_model = EmbeddingModel(model=model)
78
- return embedding_model.run(
79
- input=input,
80
- dimensions=dimensions,
81
- encoding_format=encoding_format,
82
- timeout=timeout,
83
- api_base=api_base,
84
- api_version=api_version,
85
- api_key=api_key,
86
- api_type=api_type,
87
- caching=caching,
88
- user=user,
89
- format=format,
90
- )
91
-
92
-
93
- # Overloads for async_run_embedding_model
94
- @overload
95
- async def async_run_embedding_model(
96
- input: List[Any] | Any,
97
- *,
98
- # Provider settings
99
- model: EmbeddingModelName = "openai/text-embedding-3-small",
100
- api_base: Optional[str] = None,
101
- api_key: Optional[str] = None,
102
- api_version: Optional[str] = None,
103
- api_type: Optional[str] = None,
104
- # Extended settings
105
- dimensions: Optional[int] = None,
106
- encoding_format: Optional[str] = None,
107
- timeout: int = 600,
108
- caching: bool = False,
109
- user: Optional[str] = None,
110
- format: bool = False,
111
- ) -> EmbeddingModelResponse: ...
112
-
113
-
114
- async def async_run_embedding_model(
115
- input: List[Any] | Any,
116
- *,
117
- # Provider settings
118
- model: EmbeddingModelName = "openai/text-embedding-3-small",
119
- api_base: Optional[str] = None,
120
- api_key: Optional[str] = None,
121
- api_version: Optional[str] = None,
122
- api_type: Optional[str] = None,
123
- # Extended settings
124
- dimensions: Optional[int] = None,
125
- encoding_format: Optional[str] = None,
126
- timeout: int = 600,
127
- caching: bool = False,
128
- user: Optional[str] = None,
129
- format: bool = False,
130
- ) -> EmbeddingModelResponse:
131
- """Asynchronously run an embedding model with the given input.
132
-
133
- Args:
134
- input: The input text/content to generate embeddings for
135
- model: The embedding model to use
136
- api_base: The base URL for the API
137
- api_key: The API key to use for the request
138
- api_version: The version of the API
139
- api_type: The API type to use for the request
140
- dimensions: The number of dimensions for the embedding
141
- encoding_format: The format to return the embeddings in
142
- timeout: The timeout for the request
143
- caching: Whether to cache the request
144
- user: The user to use for the request
145
- format: Whether to format each non-string input as a markdown string
146
-
147
- Returns:
148
- EmbeddingModelResponse: The embedding response
149
- """
150
- embedding_model = EmbeddingModel(model=model)
151
- return await embedding_model.async_run(
152
- input=input,
153
- dimensions=dimensions,
154
- encoding_format=encoding_format,
155
- timeout=timeout,
156
- api_base=api_base,
157
- api_version=api_version,
158
- api_key=api_key,
159
- api_type=api_type,
160
- caching=caching,
161
- user=user,
162
- format=format,
163
- )
@@ -1,37 +0,0 @@
1
- """hammad.genai.models.embeddings.types"""
2
-
3
- from typing import TYPE_CHECKING
4
- from ....._internal import create_getattr_importer
5
-
6
-
7
- if TYPE_CHECKING:
8
- from .embedding_model_name import EmbeddingModelName
9
- from .embedding_model_run_params import EmbeddingModelRunParams
10
- from .embedding_model_response import (
11
- Embedding,
12
- EmbeddingUsage,
13
- EmbeddingModelResponse,
14
- )
15
- from .embedding_model_settings import EmbeddingModelSettings
16
-
17
-
18
- __all__ = [
19
- # hammad.genai.models.embeddings.types.embedding_model_name
20
- "EmbeddingModelName",
21
- # hammad.genai.models.embeddings.types.embedding_model_run_params
22
- "EmbeddingModelRunParams",
23
- # hammad.genai.models.embeddings.types.embedding_model_response
24
- "Embedding",
25
- "EmbeddingUsage",
26
- "EmbeddingModelResponse",
27
- # hammad.genai.models.embeddings.types.embedding_model_settings
28
- "EmbeddingModelSettings",
29
- ]
30
-
31
-
32
- __getattr__ = create_getattr_importer(__all__)
33
-
34
-
35
- def __dir__() -> list[str]:
36
- """Return the list of attributes to be shown in the REPL."""
37
- return __all__
@@ -1,75 +0,0 @@
1
- """hammad.genai.embedding_models.embedding_model_name"""
2
-
3
- from typing import Literal
4
-
5
-
6
- __all__ = ("EmbeddingModelName",)
7
-
8
-
9
- EmbeddingModelName = Literal[
10
- # OpenAI Embedding Models
11
- "text-embedding-3-small",
12
- "text-embedding-3-large",
13
- "text-embedding-ada-002",
14
- # OpenAI Compatible Embedding Models
15
- "openai/text-embedding-3-small",
16
- "openai/text-embedding-3-large",
17
- "openai/text-embedding-ada-002",
18
- # Bedrock Embedding Models
19
- "amazon.titan-embed-text-v1",
20
- "cohere.embed-english-v3",
21
- "cohere.embed-multilingual-v3",
22
- # Cohere Embedding Models
23
- "embed-english-v3.0",
24
- "embed-english-light-v3.0",
25
- "embed-multilingual-v3.0",
26
- "embed-multilingual-light-v3.0",
27
- "embed-english-v2.0",
28
- "embed-english-light-v2.0",
29
- "embed-multilingual-v2.0",
30
- # NVIDIA NIM Embedding Models
31
- "nvidia_nim/NV-Embed-QA",
32
- "nvidia_nim/nvidia/nv-embed-v1",
33
- "nvidia_nim/nvidia/nv-embedqa-mistral-7b-v2",
34
- "nvidia_nim/nvidia/nv-embedqa-e5-v5",
35
- "nvidia_nim/nvidia/embed-qa-4",
36
- "nvidia_nim/nvidia/llama-3.2-nv-embedqa-1b-v1",
37
- "nvidia_nim/nvidia/llama-3.2-nv-embedqa-1b-v2",
38
- "nvidia_nim/snowflake/arctic-embed-l",
39
- "nvidia_nim/baai/bge-m3",
40
- # HuggingFace Embedding Models
41
- "huggingface/microsoft/codebert-base",
42
- "huggingface/BAAI/bge-large-zh",
43
- # Mistral AI Embedding Models
44
- "mistral/mistral-embed",
45
- # Gemini AI Embedding Models
46
- "gemini/text-embedding-004",
47
- # Vertex AI Embedding Models
48
- "vertex_ai/textembedding-gecko",
49
- "vertex_ai/textembedding-gecko-multilingual",
50
- "vertex_ai/textembedding-gecko-multilingual@001",
51
- "vertex_ai/textembedding-gecko@001",
52
- "vertex_ai/textembedding-gecko@003",
53
- "vertex_ai/text-embedding-preview-0409",
54
- "vertex_ai/text-multilingual-embedding-preview-0409",
55
- # Voyage AI Embedding Models
56
- "voyage/voyage-01",
57
- "voyage/voyage-lite-01",
58
- "voyage/voyage-lite-01-instruct",
59
- # Nebius AI Studio Embedding Models
60
- "nebius/BAAI/bge-en-icl",
61
- "nebius/BAAI/bge-multilingual-gemma2",
62
- "nebius/intfloat/e5-mistral-7b-instruct",
63
- # Ollama Embedding Models
64
- "ollama/granite-embedding:30m",
65
- "ollama/granite-embedding:278m",
66
- "ollama/snowflake-arctic-embed2",
67
- "ollama/bge-large",
68
- "ollama/paraphrase-multilingual",
69
- "ollama/bge-m3",
70
- "ollama/snowflake-arctic-embed",
71
- "ollama/mxbai-embed-large",
72
- "ollama/all-minilm",
73
- "ollama/nomic-embed-text",
74
- ]
75
- """Common embedding models supported by `litellm`."""
@@ -1,76 +0,0 @@
1
- """hammad.genai.embedding_models.embedding_model_response"""
2
-
3
- from typing import List, Literal
4
-
5
- from pydantic import BaseModel
6
-
7
- from ....types.base import BaseGenAIModelResponse
8
-
9
- __all__ = (
10
- "Embedding",
11
- "EmbeddingUsage",
12
- "EmbeddingResponse",
13
- )
14
-
15
-
16
- class Embedding(BaseModel):
17
- embedding: List[float]
18
- """The embedding vector, which is a list of floats.
19
-
20
- The length of vector depends on the model as listed in the
21
- [embedding guide](https://platform.openai.com/docs/guides/embeddings).
22
- """
23
-
24
- index: int
25
- """The index of the embedding in the list of embeddings."""
26
-
27
- object: Literal["embedding"]
28
- """The object type, which is always "embedding"."""
29
-
30
- @property
31
- def dimensions(self) -> int:
32
- """The dimensions of the embedding."""
33
- return len(self.embedding)
34
-
35
-
36
- class EmbeddingUsage(BaseModel):
37
- """Usage statistics for embedding requests."""
38
-
39
- prompt_tokens: int
40
- """The number of tokens used by the prompt."""
41
-
42
- total_tokens: int
43
- """The total number of tokens used by the request."""
44
-
45
-
46
- class EmbeddingModelResponse(BaseGenAIModelResponse[List[Embedding]]):
47
- output: List[Embedding]
48
- """The list of embeddings generated by the model."""
49
-
50
- model: str
51
- """The name of the model used to generate the embedding."""
52
-
53
- object: Literal["list"]
54
- """The object type, which is always "list"."""
55
-
56
- usage: EmbeddingUsage
57
- """The usage information for the request."""
58
-
59
- @property
60
- def data(self) -> List[Embedding]:
61
- """The list of embeddings generated by the model."""
62
- return self.output
63
-
64
- @property
65
- def dimensions(self) -> int:
66
- """The dimensions of the embedding."""
67
- return len(self.output[0].embedding)
68
-
69
- def __str__(self) -> str:
70
- return (
71
- "EmbeddingModelResponse:\n"
72
- f">>> Model: {self.model}\n"
73
- f">>> Dimensions: {self.dimensions}\n"
74
- f">>> Usage: {self.usage}\n"
75
- f">>> Number of Generated Embeddings: {len(self.output)}\n"
76
- )
@@ -1,66 +0,0 @@
1
- """hammad.genai.embedding_models.embedding_model_run_params"""
2
-
3
- import sys
4
-
5
- if sys.version_info >= (3, 12):
6
- from typing import TypedDict, Required, NotRequired
7
- else:
8
- from typing_extensions import TypedDict, Required, NotRequired
9
-
10
- from typing import (
11
- Any,
12
- Dict,
13
- List,
14
- Optional,
15
- Type,
16
- TypeVar,
17
- Union,
18
- Literal,
19
- )
20
-
21
- from .embedding_model_name import EmbeddingModelName
22
-
23
- __all__ = [
24
- "EmbeddingModelRunParams",
25
- ]
26
-
27
-
28
- class EmbeddingModelRunParams(TypedDict, total=False):
29
- """A request to an embedding model."""
30
-
31
- input: List[Any] | Any
32
- """The input items to embed."""
33
-
34
- model: EmbeddingModelName | str
35
- """The embedding model to use."""
36
-
37
- format: bool = False
38
- """Whether to format each non-string input as a markdown string."""
39
-
40
- # LiteLLM Settings
41
- dimensions: Optional[int] = None
42
- """The dimensions of the embedding."""
43
-
44
- encoding_format: Optional[str] = None
45
- """The encoding format of the embedding."""
46
-
47
- timeout: Optional[int] = None
48
- """The timeout for the embedding request."""
49
-
50
- api_base: Optional[str] = None
51
- """The API base for the embedding request."""
52
-
53
- api_version: Optional[str] = None
54
- """The API version for the embedding request."""
55
-
56
- api_key: Optional[str] = None
57
- """The API key for the embedding request."""
58
-
59
- api_type: Optional[str] = None
60
- """The API type for the embedding request."""
61
-
62
- caching: bool = False
63
- """Whether to cache the embedding request."""
64
-
65
- user: Optional[str] = None
66
- """The user for the embedding request."""
@@ -1,47 +0,0 @@
1
- """hammad.genai.models.embeddings.types.embedding_model_settings"""
2
-
3
- from pydantic import BaseModel
4
- from typing import Any, List, Optional
5
-
6
- from .embedding_model_name import EmbeddingModelName
7
- from ....types.base import BaseGenAIModelSettings
8
-
9
-
10
- __all__ = [
11
- "EmbeddingModelSettings",
12
- ]
13
-
14
-
15
- class EmbeddingModelSettings(BaseGenAIModelSettings):
16
- """A request to an embedding model."""
17
-
18
- format: bool = False
19
- """Whether to format each non-string input as a markdown string."""
20
-
21
- # LiteLLM Settings
22
- dimensions: Optional[int] = None
23
- """The dimensions of the embedding."""
24
-
25
- encoding_format: Optional[str] = None
26
- """The encoding format of the embedding."""
27
-
28
- timeout: Optional[int] = None
29
- """The timeout for the embedding request."""
30
-
31
- api_base: Optional[str] = None
32
- """The API base for the embedding request."""
33
-
34
- api_version: Optional[str] = None
35
- """The API version for the embedding request."""
36
-
37
- api_key: Optional[str] = None
38
- """The API key for the embedding request."""
39
-
40
- api_type: Optional[str] = None
41
- """The API type for the embedding request."""
42
-
43
- caching: bool = False
44
- """Whether to cache the embedding request."""
45
-
46
- user: Optional[str] = None
47
- """The user for the embedding request."""