hammad-python 0.0.15__py3-none-any.whl → 0.0.16__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 (111) hide show
  1. hammad/__init__.py +178 -0
  2. hammad/_internal.py +237 -0
  3. hammad/cache/__init__.py +40 -0
  4. hammad/cache/base_cache.py +181 -0
  5. hammad/cache/cache.py +169 -0
  6. hammad/cache/decorators.py +261 -0
  7. hammad/cache/file_cache.py +80 -0
  8. hammad/cache/ttl_cache.py +74 -0
  9. hammad/cli/__init__.py +35 -0
  10. hammad/cli/_runner.py +265 -0
  11. hammad/cli/animations.py +573 -0
  12. hammad/cli/plugins.py +836 -0
  13. hammad/cli/styles/__init__.py +55 -0
  14. hammad/cli/styles/settings.py +139 -0
  15. hammad/cli/styles/types.py +358 -0
  16. hammad/cli/styles/utils.py +626 -0
  17. hammad/data/__init__.py +83 -0
  18. hammad/data/collections/__init__.py +44 -0
  19. hammad/data/collections/collection.py +274 -0
  20. hammad/data/collections/indexes/__init__.py +37 -0
  21. hammad/data/collections/indexes/qdrant/__init__.py +1 -0
  22. hammad/data/collections/indexes/qdrant/index.py +735 -0
  23. hammad/data/collections/indexes/qdrant/settings.py +94 -0
  24. hammad/data/collections/indexes/qdrant/utils.py +220 -0
  25. hammad/data/collections/indexes/tantivy/__init__.py +1 -0
  26. hammad/data/collections/indexes/tantivy/index.py +428 -0
  27. hammad/data/collections/indexes/tantivy/settings.py +51 -0
  28. hammad/data/collections/indexes/tantivy/utils.py +200 -0
  29. hammad/data/configurations/__init__.py +35 -0
  30. hammad/data/configurations/configuration.py +564 -0
  31. hammad/data/models/__init__.py +55 -0
  32. hammad/data/models/extensions/__init__.py +4 -0
  33. hammad/data/models/extensions/pydantic/__init__.py +42 -0
  34. hammad/data/models/extensions/pydantic/converters.py +759 -0
  35. hammad/data/models/fields.py +546 -0
  36. hammad/data/models/model.py +1078 -0
  37. hammad/data/models/utils.py +280 -0
  38. hammad/data/sql/__init__.py +23 -0
  39. hammad/data/sql/database.py +578 -0
  40. hammad/data/sql/types.py +141 -0
  41. hammad/data/types/__init__.py +39 -0
  42. hammad/data/types/file.py +358 -0
  43. hammad/data/types/multimodal/__init__.py +24 -0
  44. hammad/data/types/multimodal/audio.py +96 -0
  45. hammad/data/types/multimodal/image.py +80 -0
  46. hammad/data/types/text.py +1066 -0
  47. hammad/formatting/__init__.py +20 -0
  48. hammad/formatting/json/__init__.py +27 -0
  49. hammad/formatting/json/converters.py +158 -0
  50. hammad/formatting/text/__init__.py +63 -0
  51. hammad/formatting/text/converters.py +723 -0
  52. hammad/formatting/text/markdown.py +131 -0
  53. hammad/formatting/yaml/__init__.py +26 -0
  54. hammad/formatting/yaml/converters.py +5 -0
  55. hammad/genai/__init__.py +78 -0
  56. hammad/genai/agents/__init__.py +1 -0
  57. hammad/genai/agents/types/__init__.py +35 -0
  58. hammad/genai/agents/types/history.py +277 -0
  59. hammad/genai/agents/types/tool.py +490 -0
  60. hammad/genai/embedding_models/__init__.py +41 -0
  61. hammad/genai/embedding_models/embedding_model.py +193 -0
  62. hammad/genai/embedding_models/embedding_model_name.py +77 -0
  63. hammad/genai/embedding_models/embedding_model_request.py +65 -0
  64. hammad/genai/embedding_models/embedding_model_response.py +69 -0
  65. hammad/genai/embedding_models/run.py +161 -0
  66. hammad/genai/language_models/__init__.py +35 -0
  67. hammad/genai/language_models/_streaming.py +622 -0
  68. hammad/genai/language_models/_types.py +276 -0
  69. hammad/genai/language_models/_utils/__init__.py +31 -0
  70. hammad/genai/language_models/_utils/_completions.py +131 -0
  71. hammad/genai/language_models/_utils/_messages.py +89 -0
  72. hammad/genai/language_models/_utils/_requests.py +202 -0
  73. hammad/genai/language_models/_utils/_structured_outputs.py +124 -0
  74. hammad/genai/language_models/language_model.py +734 -0
  75. hammad/genai/language_models/language_model_request.py +135 -0
  76. hammad/genai/language_models/language_model_response.py +219 -0
  77. hammad/genai/language_models/language_model_response_chunk.py +53 -0
  78. hammad/genai/language_models/run.py +530 -0
  79. hammad/genai/multimodal_models.py +48 -0
  80. hammad/genai/rerank_models.py +26 -0
  81. hammad/logging/__init__.py +35 -0
  82. hammad/logging/decorators.py +834 -0
  83. hammad/logging/logger.py +954 -0
  84. hammad/mcp/__init__.py +50 -0
  85. hammad/mcp/client/__init__.py +36 -0
  86. hammad/mcp/client/client.py +624 -0
  87. hammad/mcp/client/client_service.py +400 -0
  88. hammad/mcp/client/settings.py +178 -0
  89. hammad/mcp/servers/__init__.py +25 -0
  90. hammad/mcp/servers/launcher.py +1161 -0
  91. hammad/runtime/__init__.py +32 -0
  92. hammad/runtime/decorators.py +142 -0
  93. hammad/runtime/run.py +299 -0
  94. hammad/service/__init__.py +49 -0
  95. hammad/service/create.py +527 -0
  96. hammad/service/decorators.py +285 -0
  97. hammad/typing/__init__.py +435 -0
  98. hammad/web/__init__.py +43 -0
  99. hammad/web/http/__init__.py +1 -0
  100. hammad/web/http/client.py +944 -0
  101. hammad/web/models.py +277 -0
  102. hammad/web/openapi/__init__.py +1 -0
  103. hammad/web/openapi/client.py +740 -0
  104. hammad/web/search/__init__.py +1 -0
  105. hammad/web/search/client.py +1035 -0
  106. hammad/web/utils.py +472 -0
  107. {hammad_python-0.0.15.dist-info → hammad_python-0.0.16.dist-info}/METADATA +8 -1
  108. hammad_python-0.0.16.dist-info/RECORD +110 -0
  109. hammad_python-0.0.15.dist-info/RECORD +0 -4
  110. {hammad_python-0.0.15.dist-info → hammad_python-0.0.16.dist-info}/WHEEL +0 -0
  111. {hammad_python-0.0.15.dist-info → hammad_python-0.0.16.dist-info}/licenses/LICENSE +0 -0
hammad/cli/_runner.py ADDED
@@ -0,0 +1,265 @@
1
+ """hammad.cli._runner"""
2
+
3
+ from typing import (
4
+ overload,
5
+ TYPE_CHECKING,
6
+ Optional,
7
+ Any,
8
+ Dict,
9
+ List,
10
+ Union,
11
+ Literal,
12
+ IO,
13
+ )
14
+
15
+ if TYPE_CHECKING:
16
+ from rich.console import Console, RenderableType
17
+ from ..cli.animations import (
18
+ CLIFlashingAnimation,
19
+ CLIPulsingAnimation,
20
+ CLIShakingAnimation,
21
+ CLITypingAnimation,
22
+ CLISpinningAnimation,
23
+ CLIRainbowAnimation,
24
+ RainbowPreset,
25
+ )
26
+ from ..cli.styles.types import (
27
+ CLIStyleType,
28
+ CLIStyleBackgroundType,
29
+ CLIStyleColorName,
30
+ )
31
+ from ..cli.styles.settings import (
32
+ CLIStyleRenderableSettings,
33
+ CLIStyleBackgroundSettings,
34
+ CLIStyleLiveSettings,
35
+ )
36
+
37
+
38
+ __all__ = (
39
+ "CLIRunner",
40
+ )
41
+
42
+
43
+
44
+ class CLIRunner:
45
+ """Runner subclass for various CLI-based operations."""
46
+
47
+ @overload
48
+ @staticmethod
49
+ def print(
50
+ *values: object,
51
+ sep: str = " ",
52
+ end: str = "\n",
53
+ file: Optional[IO[str]] = None,
54
+ flush: bool = False,
55
+ ) -> None: ...
56
+
57
+
58
+ @overload
59
+ @staticmethod
60
+ def print(
61
+ *values: object,
62
+ sep: str = " ",
63
+ end: str = "\n",
64
+ file: Optional[IO[str]] = None,
65
+ flush: bool = False,
66
+ style: "CLIStyleType | None" = None,
67
+ style_settings: "CLIStyleRenderableSettings | None" = None,
68
+ bg: "CLIStyleBackgroundType | None" = None,
69
+ bg_settings: "CLIStyleBackgroundSettings | None" = None,
70
+ live: "CLIStyleLiveSettings | int | None" = None,
71
+ ) -> None: ...
72
+
73
+
74
+ @staticmethod
75
+ def print(
76
+ *values: object,
77
+ sep: str = " ",
78
+ end: str = "\n",
79
+ file: Optional[IO[str]] = None,
80
+ flush: bool = False,
81
+ style: "CLIStyleType | None" = None,
82
+ style_settings: "CLIStyleRenderableSettings | None" = None,
83
+ bg: "CLIStyleBackgroundType | None" = None,
84
+ bg_settings: "CLIStyleBackgroundSettings | None" = None,
85
+ live: "CLIStyleLiveSettings | int | None" = None,
86
+ ) -> Optional["CLIStyleLiveSettings"]:
87
+ """Print values to the console with optional styling and live updates.
88
+
89
+ This function extends Python's built-in print() with additional styling
90
+ capabilities including backgrounds and live updating displays.
91
+
92
+ Args:
93
+ *values: Values to print (similar to built-in print())
94
+ sep: String inserted between values (default: " ")
95
+ end: String appended after the last value (default: "\n")
96
+ file: File object to write to (default: sys.stdout)
97
+ flush: Whether to forcibly flush the stream
98
+ console: Rich Console instance to use
99
+ style: Style to apply to the content
100
+ color: Color to apply to the content
101
+ bg: Background style to apply
102
+ live: Whether to enable live updating
103
+ live_settings: Configuration for live display
104
+ settings: General rendering settings
105
+ bg_settings: Background styling settings
106
+ **kwargs: Additional keyword arguments
107
+
108
+ Returns:
109
+ Live settings object if live=True, otherwise None
110
+ """
111
+ from ..cli import print as _run_cli_print_fn
112
+ return _run_cli_print_fn(
113
+ *values,
114
+ sep=sep,
115
+ end=end,
116
+ file=file,
117
+ flush=flush,
118
+ style=style,
119
+ style_settings=style_settings,
120
+ bg=bg,
121
+ bg_settings=bg_settings,
122
+ live=live,
123
+ )
124
+
125
+ @overload
126
+ @staticmethod
127
+ def input(
128
+ prompt: str = "",
129
+ schema: Any = None,
130
+ sequential: bool = True,
131
+ style: "CLIStyleType | None" = None,
132
+ style_settings: "CLIStyleRenderableSettings | None" = None,
133
+ bg: "CLIStyleBackgroundType | None" = None,
134
+ bg_settings: "CLIStyleBackgroundSettings | None" = None,
135
+ multiline: bool = False,
136
+ password: bool = False,
137
+ complete: Optional[List[str]] = None,
138
+ validate: Optional[callable] = None,
139
+ ) -> Any: ...
140
+
141
+ @staticmethod
142
+ def input(
143
+ prompt: str = "",
144
+ schema: Any = None,
145
+ sequential: bool = True,
146
+ style: "CLIStyleType | None" = None,
147
+ style_settings: "CLIStyleRenderableSettings | None" = None,
148
+ bg: "CLIStyleBackgroundType | None" = None,
149
+ bg_settings: "CLIStyleBackgroundSettings | None" = None,
150
+ multiline: bool = False,
151
+ password: bool = False,
152
+ complete: Optional[List[str]] = None,
153
+ validate: Optional[callable] = None,
154
+ ) -> Any:
155
+ """Get input from the user with optional validation and styling.
156
+
157
+ Args:
158
+ prompt: The prompt message to display.
159
+ schema: Optional schema (dataclass, TypedDict, Pydantic model) for structured input.
160
+ sequential: If schema is provided, collect fields sequentially (default: True).
161
+ style: A color or style name to apply to the prompt.
162
+ style_settings: A dictionary of style settings to apply to the prompt.
163
+ bg: A color or box name to apply to the background of the prompt.
164
+ bg_settings: A dictionary of background settings to apply to the prompt.
165
+ multiline: Allow multiline input (default: False).
166
+ password: Hide input (default: False).
167
+ complete: List of strings for autocompletion.
168
+ validate: A callable to validate the input.
169
+
170
+ Returns:
171
+ The user's input, potentially validated and converted according to the schema.
172
+ """
173
+ from ..cli import input as _run_cli_input_fn
174
+ return _run_cli_input_fn(
175
+ prompt=prompt,
176
+ schema=schema,
177
+ sequential=sequential,
178
+ style=style,
179
+ style_settings=style_settings,
180
+ bg=bg,
181
+ bg_settings=bg_settings,
182
+ multiline=multiline,
183
+ password=password,
184
+ complete=complete,
185
+ validate=validate,
186
+ )
187
+
188
+ @staticmethod
189
+ def animate(
190
+ renderable: "RenderableType | str",
191
+ type: Literal["flashing", "pulsing", "shaking", "typing", "spinning", "rainbow"],
192
+ duration: Optional[float] = None,
193
+ # Animation parameters (defaults are handled by the specific animation classes)
194
+ speed: Optional[float] = None,
195
+ colors: "Optional[List[CLIStyleColorName]]" = None,
196
+ on_color: "Optional[CLIStyleColorName]" = None,
197
+ off_color: "Optional[CLIStyleColorName]" = None,
198
+ min_opacity: Optional[float] = None,
199
+ max_opacity: Optional[float] = None,
200
+ color: "Optional[CLIStyleColorName]" = None,
201
+ intensity: Optional[int] = None,
202
+ typing_speed: Optional[float] = None,
203
+ cursor: Optional[str] = None,
204
+ show_cursor: Optional[bool] = None,
205
+ frames: Optional[List[str]] = None,
206
+ prefix: Optional[bool] = None,
207
+ # Rich.Live parameters
208
+ refresh_rate: int = 20,
209
+ transient: bool = True,
210
+ auto_refresh: bool = True,
211
+ console: Optional["Console"] = None,
212
+ screen: bool = False,
213
+ vertical_overflow: str = "ellipsis",
214
+ ) -> None:
215
+ """Create and run an animation based on the specified type.
216
+
217
+ Args:
218
+ renderable: The object to animate (text, panel, etc.)
219
+ type: The type of animation to create
220
+ duration: Duration of the animation in seconds (defaults to 2.0)
221
+ speed: Animation speed (used by flashing, pulsing, shaking, spinning, rainbow)
222
+ colors: Color list (used by flashing, rainbow)
223
+ on_color: Color when flashing "on" (used by flashing)
224
+ off_color: Color when flashing "off" (used by flashing)
225
+ min_opacity: Minimum opacity for pulsing animation
226
+ max_opacity: Maximum opacity for pulsing animation
227
+ color: Color for pulsing animation
228
+ intensity: Shaking intensity for shaking animation
229
+ typing_speed: Speed for typing animation (used by typing)
230
+ cursor: Cursor character for typing animation (used by typing)
231
+ show_cursor: Whether to show cursor for typing animation (used by typing)
232
+ frames: Custom frames for spinning animation
233
+ prefix: Whether to show spinner as prefix for spinning animation
234
+ refresh_rate: Refresh rate per second for Live rendering
235
+ transient: Whether to clear animation after completion
236
+ auto_refresh: Whether to auto-refresh the display
237
+ console: Console to use for rendering
238
+ screen: Whether to use alternate screen buffer
239
+ vertical_overflow: How to handle vertical overflow
240
+ """
241
+ from ..cli import animate as _run_cli_animate_fn
242
+ _run_cli_animate_fn(
243
+ renderable=renderable,
244
+ type=type,
245
+ duration=duration,
246
+ speed=speed,
247
+ colors=colors,
248
+ on_color=on_color,
249
+ off_color=off_color,
250
+ min_opacity=min_opacity,
251
+ max_opacity=max_opacity,
252
+ color=color,
253
+ intensity=intensity,
254
+ typing_speed=typing_speed,
255
+ cursor=cursor,
256
+ show_cursor=show_cursor,
257
+ frames=frames,
258
+ prefix=prefix,
259
+ refresh_rate=refresh_rate,
260
+ transient=transient,
261
+ auto_refresh=auto_refresh,
262
+ console=console,
263
+ screen=screen,
264
+ vertical_overflow=vertical_overflow,
265
+ )