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/web/models.py ADDED
@@ -0,0 +1,277 @@
1
+ """hammad.web.models
2
+
3
+ Output models for web search and parsing functionality.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import List, Dict, Any, Optional, Union
9
+
10
+ from pydantic import BaseModel, Field
11
+
12
+
13
+ # -----------------------------------------------------------------------------
14
+ # Search Result Models
15
+ # -----------------------------------------------------------------------------
16
+
17
+
18
+ class SearchResult(BaseModel):
19
+ """DuckDuckGo web search result."""
20
+
21
+ title: str
22
+ """Title of the search result."""
23
+
24
+ href: str
25
+ """URL of the search result."""
26
+
27
+ body: str
28
+ """Description/snippet of the search result."""
29
+
30
+
31
+ class NewsResult(BaseModel):
32
+ """DuckDuckGo news search result."""
33
+
34
+ date: str
35
+ """Publication date of the news article."""
36
+
37
+ title: str
38
+ """Title of the news article."""
39
+
40
+ body: str
41
+ """Description/snippet of the news article."""
42
+
43
+ url: str
44
+ """URL of the news article."""
45
+
46
+ image: str
47
+ """Image URL associated with the news article."""
48
+
49
+ source: str
50
+ """Source/publisher of the news article."""
51
+
52
+
53
+ # -----------------------------------------------------------------------------
54
+ # Web Page Parsing Models
55
+ # -----------------------------------------------------------------------------
56
+
57
+
58
+ class LinkInfo(BaseModel):
59
+ """Information about a link extracted from a web page."""
60
+
61
+ href: str
62
+ """Absolute URL of the link."""
63
+
64
+ text: str
65
+ """Text content of the link."""
66
+
67
+
68
+ class ImageInfo(BaseModel):
69
+ """Information about an image extracted from a web page."""
70
+
71
+ src: str
72
+ """Source URL of the image."""
73
+
74
+ alt: str
75
+ """Alt text of the image."""
76
+
77
+ title: str
78
+ """Title attribute of the image."""
79
+
80
+
81
+ class SelectedElement(BaseModel):
82
+ """Information about a selected element from CSS selector."""
83
+
84
+ tag: str
85
+ """HTML tag name of the element."""
86
+
87
+ text: str
88
+ """Text content of the element."""
89
+
90
+ html: str
91
+ """HTML content of the element."""
92
+
93
+ attributes: Dict[str, str]
94
+ """Attributes of the element."""
95
+
96
+
97
+ class WebPageResult(BaseModel):
98
+ """Result from parsing a single web page."""
99
+
100
+ url: str
101
+ """URL of the parsed page."""
102
+
103
+ status_code: int
104
+ """HTTP status code of the response."""
105
+
106
+ content_type: str
107
+ """Content-Type header from the response."""
108
+
109
+ title: str
110
+ """Title of the web page."""
111
+
112
+ text: str
113
+ """Extracted text content of the page."""
114
+
115
+ links: List[LinkInfo]
116
+ """List of links found on the page."""
117
+
118
+ images: List[ImageInfo]
119
+ """List of images found on the page."""
120
+
121
+ selected_elements: List[SelectedElement]
122
+ """List of elements matching the CSS selector."""
123
+
124
+
125
+ class WebPageErrorResult(BaseModel):
126
+ """Result from a failed web page parsing attempt."""
127
+
128
+ url: str
129
+ """URL that failed to be parsed."""
130
+
131
+ error: str
132
+ """Error message describing what went wrong."""
133
+
134
+ status_code: Optional[int]
135
+ """Always None for error results."""
136
+
137
+ content_type: str
138
+ """Always empty string for error results."""
139
+
140
+ title: str
141
+ """Always empty string for error results."""
142
+
143
+ text: str
144
+ """Always empty string for error results."""
145
+
146
+ links: List[LinkInfo]
147
+ """Always empty list for error results."""
148
+
149
+ images: List[ImageInfo]
150
+ """Always empty list for error results."""
151
+
152
+ selected_elements: List[SelectedElement]
153
+ """Always empty list for error results."""
154
+
155
+
156
+ # -----------------------------------------------------------------------------
157
+ # Enhanced Link Models
158
+ # -----------------------------------------------------------------------------
159
+
160
+
161
+ class ExtractedLink(BaseModel):
162
+ """Information about a link extracted with classification."""
163
+
164
+ href: str
165
+ """Absolute URL of the link."""
166
+
167
+ original_href: str
168
+ """Original href attribute value (may be relative)."""
169
+
170
+ text: str
171
+ """Text content of the link."""
172
+
173
+ title: str
174
+ """Title attribute of the link."""
175
+
176
+ type: str
177
+ """Type of link: 'internal' or 'external'."""
178
+
179
+
180
+ # -----------------------------------------------------------------------------
181
+ # HTTP Request Models
182
+ # -----------------------------------------------------------------------------
183
+
184
+
185
+ class HttpResponse(BaseModel):
186
+ """HTTP response from web requests."""
187
+
188
+ status_code: int
189
+ """HTTP status code."""
190
+
191
+ headers: Dict[str, str]
192
+ """Response headers."""
193
+
194
+ content: Union[str, bytes]
195
+ """Response content."""
196
+
197
+ url: str
198
+ """Final URL after redirects."""
199
+
200
+ elapsed: float
201
+ """Time elapsed for the request in seconds."""
202
+
203
+ # NOTE: This is a workaround to avoid the issue with the `json` field
204
+ # might consider moving to dataclasses
205
+ json_data: Optional[Dict[str, Any]] = Field(
206
+ alias="json"
207
+ )
208
+ """Parsed JSON content if Content-Type is JSON."""
209
+
210
+ text: str
211
+ """Text content if response is text-based."""
212
+
213
+
214
+ # -----------------------------------------------------------------------------
215
+ # Batch Operation Models
216
+ # -----------------------------------------------------------------------------
217
+
218
+
219
+ class WebPageResults(BaseModel):
220
+ """Results from batch web page parsing operations."""
221
+
222
+ urls: List[str]
223
+ """URLs used for the web page parsing operations."""
224
+
225
+ results: List[Union[WebPageResult, WebPageErrorResult]]
226
+ """List of results from batch web page parsing operations."""
227
+
228
+
229
+ class SearchResults(BaseModel):
230
+ """Results from web search operations."""
231
+
232
+ query: str
233
+ """Query used for the web search operations."""
234
+
235
+ results: List[SearchResult]
236
+ """List of results from web search operations."""
237
+
238
+
239
+ class NewsResults(BaseModel):
240
+ """Results from news search operations."""
241
+
242
+ query: str
243
+ """Query used for the news search operations."""
244
+
245
+ results: List[NewsResult]
246
+ """List of results from news search operations."""
247
+
248
+
249
+ class ExtractedLinks(BaseModel):
250
+ """Results from link extraction operations."""
251
+
252
+ url: str
253
+ """URL used for the link extraction operations."""
254
+
255
+ results: List[ExtractedLink]
256
+ """List of results from link extraction operations."""
257
+
258
+
259
+ __all__ = (
260
+ # Search models
261
+ "SearchResult",
262
+ "NewsResult",
263
+ "SearchResults",
264
+ "NewsResults",
265
+ # Web page models
266
+ "LinkInfo",
267
+ "ImageInfo",
268
+ "SelectedElement",
269
+ "WebPageResult",
270
+ "WebPageErrorResult",
271
+ "WebPageResults",
272
+ # Link extraction models
273
+ "ExtractedLink",
274
+ "ExtractedLinks",
275
+ # HTTP models
276
+ "HttpResponse",
277
+ )
@@ -0,0 +1 @@
1
+ """hammad.web.openapi"""