huggingface-hub 0.24.6__py3-none-any.whl → 0.25.0rc0__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.
Potentially problematic release.
This version of huggingface-hub might be problematic. Click here for more details.
- huggingface_hub/__init__.py +21 -1
- huggingface_hub/_commit_api.py +4 -4
- huggingface_hub/_inference_endpoints.py +13 -1
- huggingface_hub/_local_folder.py +191 -4
- huggingface_hub/_login.py +6 -6
- huggingface_hub/_snapshot_download.py +8 -17
- huggingface_hub/_space_api.py +5 -0
- huggingface_hub/_tensorboard_logger.py +29 -13
- huggingface_hub/_upload_large_folder.py +573 -0
- huggingface_hub/_webhooks_server.py +1 -1
- huggingface_hub/commands/_cli_utils.py +5 -0
- huggingface_hub/commands/download.py +8 -0
- huggingface_hub/commands/huggingface_cli.py +6 -1
- huggingface_hub/commands/lfs.py +2 -1
- huggingface_hub/commands/repo_files.py +2 -2
- huggingface_hub/commands/scan_cache.py +99 -57
- huggingface_hub/commands/tag.py +1 -1
- huggingface_hub/commands/upload.py +2 -1
- huggingface_hub/commands/upload_large_folder.py +129 -0
- huggingface_hub/commands/version.py +37 -0
- huggingface_hub/community.py +2 -2
- huggingface_hub/errors.py +218 -1
- huggingface_hub/fastai_utils.py +2 -3
- huggingface_hub/file_download.py +63 -63
- huggingface_hub/hf_api.py +758 -314
- huggingface_hub/hf_file_system.py +15 -23
- huggingface_hub/hub_mixin.py +27 -25
- huggingface_hub/inference/_client.py +78 -127
- huggingface_hub/inference/_generated/_async_client.py +169 -144
- huggingface_hub/inference/_generated/types/base.py +0 -9
- huggingface_hub/inference/_templating.py +2 -3
- huggingface_hub/inference_api.py +2 -2
- huggingface_hub/keras_mixin.py +2 -2
- huggingface_hub/lfs.py +7 -98
- huggingface_hub/repocard.py +6 -5
- huggingface_hub/repository.py +5 -5
- huggingface_hub/serialization/_torch.py +64 -11
- huggingface_hub/utils/__init__.py +13 -14
- huggingface_hub/utils/_cache_manager.py +97 -14
- huggingface_hub/utils/_fixes.py +18 -2
- huggingface_hub/utils/_http.py +228 -2
- huggingface_hub/utils/_lfs.py +110 -0
- huggingface_hub/utils/_runtime.py +7 -1
- huggingface_hub/utils/_token.py +3 -2
- {huggingface_hub-0.24.6.dist-info → huggingface_hub-0.25.0rc0.dist-info}/METADATA +2 -2
- {huggingface_hub-0.24.6.dist-info → huggingface_hub-0.25.0rc0.dist-info}/RECORD +50 -48
- huggingface_hub/inference/_types.py +0 -52
- huggingface_hub/utils/_errors.py +0 -397
- {huggingface_hub-0.24.6.dist-info → huggingface_hub-0.25.0rc0.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.24.6.dist-info → huggingface_hub-0.25.0rc0.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.24.6.dist-info → huggingface_hub-0.25.0rc0.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.24.6.dist-info → huggingface_hub-0.25.0rc0.dist-info}/top_level.txt +0 -0
huggingface_hub/utils/_errors.py
DELETED
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
from requests import HTTPError, Response
|
|
5
|
-
|
|
6
|
-
from ._fixes import JSONDecodeError
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
REPO_API_REGEX = re.compile(
|
|
10
|
-
r"""
|
|
11
|
-
# staging or production endpoint
|
|
12
|
-
^https://[^/]+
|
|
13
|
-
(
|
|
14
|
-
# on /api/repo_type/repo_id
|
|
15
|
-
/api/(models|datasets|spaces)/(.+)
|
|
16
|
-
|
|
|
17
|
-
# or /repo_id/resolve/revision/...
|
|
18
|
-
/(.+)/resolve/(.+)
|
|
19
|
-
)
|
|
20
|
-
""",
|
|
21
|
-
flags=re.VERBOSE,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class FileMetadataError(OSError):
|
|
26
|
-
"""Error triggered when the metadata of a file on the Hub cannot be retrieved (missing ETag or commit_hash).
|
|
27
|
-
|
|
28
|
-
Inherits from `OSError` for backward compatibility.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class HfHubHTTPError(HTTPError):
|
|
33
|
-
"""
|
|
34
|
-
HTTPError to inherit from for any custom HTTP Error raised in HF Hub.
|
|
35
|
-
|
|
36
|
-
Any HTTPError is converted at least into a `HfHubHTTPError`. If some information is
|
|
37
|
-
sent back by the server, it will be added to the error message.
|
|
38
|
-
|
|
39
|
-
Added details:
|
|
40
|
-
- Request id from "X-Request-Id" header if exists.
|
|
41
|
-
- Server error message from the header "X-Error-Message".
|
|
42
|
-
- Server error message if we can found one in the response body.
|
|
43
|
-
|
|
44
|
-
Example:
|
|
45
|
-
```py
|
|
46
|
-
import requests
|
|
47
|
-
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
|
|
48
|
-
|
|
49
|
-
response = get_session().post(...)
|
|
50
|
-
try:
|
|
51
|
-
hf_raise_for_status(response)
|
|
52
|
-
except HfHubHTTPError as e:
|
|
53
|
-
print(str(e)) # formatted message
|
|
54
|
-
e.request_id, e.server_message # details returned by server
|
|
55
|
-
|
|
56
|
-
# Complete the error message with additional information once it's raised
|
|
57
|
-
e.append_to_message("\n`create_commit` expects the repository to exist.")
|
|
58
|
-
raise
|
|
59
|
-
```
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
request_id: Optional[str] = None
|
|
63
|
-
server_message: Optional[str] = None
|
|
64
|
-
|
|
65
|
-
def __init__(self, message: str, response: Optional[Response] = None):
|
|
66
|
-
# Parse server information if any.
|
|
67
|
-
if response is not None:
|
|
68
|
-
self.request_id = response.headers.get("X-Request-Id")
|
|
69
|
-
try:
|
|
70
|
-
server_data = response.json()
|
|
71
|
-
except JSONDecodeError:
|
|
72
|
-
server_data = {}
|
|
73
|
-
|
|
74
|
-
# Retrieve server error message from multiple sources
|
|
75
|
-
server_message_from_headers = response.headers.get("X-Error-Message")
|
|
76
|
-
server_message_from_body = server_data.get("error")
|
|
77
|
-
server_multiple_messages_from_body = "\n".join(
|
|
78
|
-
error["message"] for error in server_data.get("errors", []) if "message" in error
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
# Concatenate error messages
|
|
82
|
-
_server_message = ""
|
|
83
|
-
if server_message_from_headers is not None: # from headers
|
|
84
|
-
_server_message += server_message_from_headers + "\n"
|
|
85
|
-
if server_message_from_body is not None: # from body "error"
|
|
86
|
-
if isinstance(server_message_from_body, list):
|
|
87
|
-
server_message_from_body = "\n".join(server_message_from_body)
|
|
88
|
-
if server_message_from_body not in _server_message:
|
|
89
|
-
_server_message += server_message_from_body + "\n"
|
|
90
|
-
if server_multiple_messages_from_body is not None: # from body "errors"
|
|
91
|
-
if server_multiple_messages_from_body not in _server_message:
|
|
92
|
-
_server_message += server_multiple_messages_from_body + "\n"
|
|
93
|
-
_server_message = _server_message.strip()
|
|
94
|
-
|
|
95
|
-
# Set message to `HfHubHTTPError` (if any)
|
|
96
|
-
if _server_message != "":
|
|
97
|
-
self.server_message = _server_message
|
|
98
|
-
|
|
99
|
-
super().__init__(
|
|
100
|
-
_format_error_message(
|
|
101
|
-
message,
|
|
102
|
-
request_id=self.request_id,
|
|
103
|
-
server_message=self.server_message,
|
|
104
|
-
),
|
|
105
|
-
response=response, # type: ignore
|
|
106
|
-
request=response.request if response is not None else None, # type: ignore
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
def append_to_message(self, additional_message: str) -> None:
|
|
110
|
-
"""Append additional information to the `HfHubHTTPError` initial message."""
|
|
111
|
-
self.args = (self.args[0] + additional_message,) + self.args[1:]
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
class RepositoryNotFoundError(HfHubHTTPError):
|
|
115
|
-
"""
|
|
116
|
-
Raised when trying to access a hf.co URL with an invalid repository name, or
|
|
117
|
-
with a private repo name the user does not have access to.
|
|
118
|
-
|
|
119
|
-
Example:
|
|
120
|
-
|
|
121
|
-
```py
|
|
122
|
-
>>> from huggingface_hub import model_info
|
|
123
|
-
>>> model_info("<non_existent_repository>")
|
|
124
|
-
(...)
|
|
125
|
-
huggingface_hub.utils._errors.RepositoryNotFoundError: 401 Client Error. (Request ID: PvMw_VjBMjVdMz53WKIzP)
|
|
126
|
-
|
|
127
|
-
Repository Not Found for url: https://huggingface.co/api/models/%3Cnon_existent_repository%3E.
|
|
128
|
-
Please make sure you specified the correct `repo_id` and `repo_type`.
|
|
129
|
-
If the repo is private, make sure you are authenticated.
|
|
130
|
-
Invalid username or password.
|
|
131
|
-
```
|
|
132
|
-
"""
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
class GatedRepoError(RepositoryNotFoundError):
|
|
136
|
-
"""
|
|
137
|
-
Raised when trying to access a gated repository for which the user is not on the
|
|
138
|
-
authorized list.
|
|
139
|
-
|
|
140
|
-
Note: derives from `RepositoryNotFoundError` to ensure backward compatibility.
|
|
141
|
-
|
|
142
|
-
Example:
|
|
143
|
-
|
|
144
|
-
```py
|
|
145
|
-
>>> from huggingface_hub import model_info
|
|
146
|
-
>>> model_info("<gated_repository>")
|
|
147
|
-
(...)
|
|
148
|
-
huggingface_hub.utils._errors.GatedRepoError: 403 Client Error. (Request ID: ViT1Bf7O_026LGSQuVqfa)
|
|
149
|
-
|
|
150
|
-
Cannot access gated repo for url https://huggingface.co/api/models/ardent-figment/gated-model.
|
|
151
|
-
Access to model ardent-figment/gated-model is restricted and you are not in the authorized list.
|
|
152
|
-
Visit https://huggingface.co/ardent-figment/gated-model to ask for access.
|
|
153
|
-
```
|
|
154
|
-
"""
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
class DisabledRepoError(HfHubHTTPError):
|
|
158
|
-
"""
|
|
159
|
-
Raised when trying to access a repository that has been disabled by its author.
|
|
160
|
-
|
|
161
|
-
Example:
|
|
162
|
-
|
|
163
|
-
```py
|
|
164
|
-
>>> from huggingface_hub import dataset_info
|
|
165
|
-
>>> dataset_info("laion/laion-art")
|
|
166
|
-
(...)
|
|
167
|
-
huggingface_hub.utils._errors.DisabledRepoError: 403 Client Error. (Request ID: Root=1-659fc3fa-3031673e0f92c71a2260dbe2;bc6f4dfb-b30a-4862-af0a-5cfe827610d8)
|
|
168
|
-
|
|
169
|
-
Cannot access repository for url https://huggingface.co/api/datasets/laion/laion-art.
|
|
170
|
-
Access to this resource is disabled.
|
|
171
|
-
```
|
|
172
|
-
"""
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
class RevisionNotFoundError(HfHubHTTPError):
|
|
176
|
-
"""
|
|
177
|
-
Raised when trying to access a hf.co URL with a valid repository but an invalid
|
|
178
|
-
revision.
|
|
179
|
-
|
|
180
|
-
Example:
|
|
181
|
-
|
|
182
|
-
```py
|
|
183
|
-
>>> from huggingface_hub import hf_hub_download
|
|
184
|
-
>>> hf_hub_download('bert-base-cased', 'config.json', revision='<non-existent-revision>')
|
|
185
|
-
(...)
|
|
186
|
-
huggingface_hub.utils._errors.RevisionNotFoundError: 404 Client Error. (Request ID: Mwhe_c3Kt650GcdKEFomX)
|
|
187
|
-
|
|
188
|
-
Revision Not Found for url: https://huggingface.co/bert-base-cased/resolve/%3Cnon-existent-revision%3E/config.json.
|
|
189
|
-
```
|
|
190
|
-
"""
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
class EntryNotFoundError(HfHubHTTPError):
|
|
194
|
-
"""
|
|
195
|
-
Raised when trying to access a hf.co URL with a valid repository and revision
|
|
196
|
-
but an invalid filename.
|
|
197
|
-
|
|
198
|
-
Example:
|
|
199
|
-
|
|
200
|
-
```py
|
|
201
|
-
>>> from huggingface_hub import hf_hub_download
|
|
202
|
-
>>> hf_hub_download('bert-base-cased', '<non-existent-file>')
|
|
203
|
-
(...)
|
|
204
|
-
huggingface_hub.utils._errors.EntryNotFoundError: 404 Client Error. (Request ID: 53pNl6M0MxsnG5Sw8JA6x)
|
|
205
|
-
|
|
206
|
-
Entry Not Found for url: https://huggingface.co/bert-base-cased/resolve/main/%3Cnon-existent-file%3E.
|
|
207
|
-
```
|
|
208
|
-
"""
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
class LocalEntryNotFoundError(EntryNotFoundError, FileNotFoundError, ValueError):
|
|
212
|
-
"""
|
|
213
|
-
Raised when trying to access a file or snapshot that is not on the disk when network is
|
|
214
|
-
disabled or unavailable (connection issue). The entry may exist on the Hub.
|
|
215
|
-
|
|
216
|
-
Note: `ValueError` type is to ensure backward compatibility.
|
|
217
|
-
Note: `LocalEntryNotFoundError` derives from `HTTPError` because of `EntryNotFoundError`
|
|
218
|
-
even when it is not a network issue.
|
|
219
|
-
|
|
220
|
-
Example:
|
|
221
|
-
|
|
222
|
-
```py
|
|
223
|
-
>>> from huggingface_hub import hf_hub_download
|
|
224
|
-
>>> hf_hub_download('bert-base-cased', '<non-cached-file>', local_files_only=True)
|
|
225
|
-
(...)
|
|
226
|
-
huggingface_hub.utils._errors.LocalEntryNotFoundError: Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable hf.co look-ups and downloads online, set 'local_files_only' to False.
|
|
227
|
-
```
|
|
228
|
-
"""
|
|
229
|
-
|
|
230
|
-
def __init__(self, message: str):
|
|
231
|
-
super().__init__(message, response=None)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
class BadRequestError(HfHubHTTPError, ValueError):
|
|
235
|
-
"""
|
|
236
|
-
Raised by `hf_raise_for_status` when the server returns a HTTP 400 error.
|
|
237
|
-
|
|
238
|
-
Example:
|
|
239
|
-
|
|
240
|
-
```py
|
|
241
|
-
>>> resp = requests.post("hf.co/api/check", ...)
|
|
242
|
-
>>> hf_raise_for_status(resp, endpoint_name="check")
|
|
243
|
-
huggingface_hub.utils._errors.BadRequestError: Bad request for check endpoint: {details} (Request ID: XXX)
|
|
244
|
-
```
|
|
245
|
-
"""
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
|
|
249
|
-
"""
|
|
250
|
-
Internal version of `response.raise_for_status()` that will refine a
|
|
251
|
-
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
|
|
252
|
-
|
|
253
|
-
This helper is meant to be the unique method to raise_for_status when making a call
|
|
254
|
-
to the Hugging Face Hub.
|
|
255
|
-
|
|
256
|
-
Example:
|
|
257
|
-
```py
|
|
258
|
-
import requests
|
|
259
|
-
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
|
|
260
|
-
|
|
261
|
-
response = get_session().post(...)
|
|
262
|
-
try:
|
|
263
|
-
hf_raise_for_status(response)
|
|
264
|
-
except HfHubHTTPError as e:
|
|
265
|
-
print(str(e)) # formatted message
|
|
266
|
-
e.request_id, e.server_message # details returned by server
|
|
267
|
-
|
|
268
|
-
# Complete the error message with additional information once it's raised
|
|
269
|
-
e.append_to_message("\n`create_commit` expects the repository to exist.")
|
|
270
|
-
raise
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
Args:
|
|
274
|
-
response (`Response`):
|
|
275
|
-
Response from the server.
|
|
276
|
-
endpoint_name (`str`, *optional*):
|
|
277
|
-
Name of the endpoint that has been called. If provided, the error message
|
|
278
|
-
will be more complete.
|
|
279
|
-
|
|
280
|
-
<Tip warning={true}>
|
|
281
|
-
|
|
282
|
-
Raises when the request has failed:
|
|
283
|
-
|
|
284
|
-
- [`~utils.RepositoryNotFoundError`]
|
|
285
|
-
If the repository to download from cannot be found. This may be because it
|
|
286
|
-
doesn't exist, because `repo_type` is not set correctly, or because the repo
|
|
287
|
-
is `private` and you do not have access.
|
|
288
|
-
- [`~utils.GatedRepoError`]
|
|
289
|
-
If the repository exists but is gated and the user is not on the authorized
|
|
290
|
-
list.
|
|
291
|
-
- [`~utils.RevisionNotFoundError`]
|
|
292
|
-
If the repository exists but the revision couldn't be find.
|
|
293
|
-
- [`~utils.EntryNotFoundError`]
|
|
294
|
-
If the repository exists but the entry (e.g. the requested file) couldn't be
|
|
295
|
-
find.
|
|
296
|
-
- [`~utils.BadRequestError`]
|
|
297
|
-
If request failed with a HTTP 400 BadRequest error.
|
|
298
|
-
- [`~utils.HfHubHTTPError`]
|
|
299
|
-
If request failed for a reason not listed above.
|
|
300
|
-
|
|
301
|
-
</Tip>
|
|
302
|
-
"""
|
|
303
|
-
try:
|
|
304
|
-
response.raise_for_status()
|
|
305
|
-
except HTTPError as e:
|
|
306
|
-
error_code = response.headers.get("X-Error-Code")
|
|
307
|
-
error_message = response.headers.get("X-Error-Message")
|
|
308
|
-
|
|
309
|
-
if error_code == "RevisionNotFound":
|
|
310
|
-
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
|
|
311
|
-
raise RevisionNotFoundError(message, response) from e
|
|
312
|
-
|
|
313
|
-
elif error_code == "EntryNotFound":
|
|
314
|
-
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
|
|
315
|
-
raise EntryNotFoundError(message, response) from e
|
|
316
|
-
|
|
317
|
-
elif error_code == "GatedRepo":
|
|
318
|
-
message = (
|
|
319
|
-
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
|
|
320
|
-
)
|
|
321
|
-
raise GatedRepoError(message, response) from e
|
|
322
|
-
|
|
323
|
-
elif error_message == "Access to this resource is disabled.":
|
|
324
|
-
message = (
|
|
325
|
-
f"{response.status_code} Client Error."
|
|
326
|
-
+ "\n\n"
|
|
327
|
-
+ f"Cannot access repository for url {response.url}."
|
|
328
|
-
+ "\n"
|
|
329
|
-
+ "Access to this resource is disabled."
|
|
330
|
-
)
|
|
331
|
-
raise DisabledRepoError(message, response) from e
|
|
332
|
-
|
|
333
|
-
elif error_code == "RepoNotFound" or (
|
|
334
|
-
response.status_code == 401
|
|
335
|
-
and response.request is not None
|
|
336
|
-
and response.request.url is not None
|
|
337
|
-
and REPO_API_REGEX.search(response.request.url) is not None
|
|
338
|
-
):
|
|
339
|
-
# 401 is misleading as it is returned for:
|
|
340
|
-
# - private and gated repos if user is not authenticated
|
|
341
|
-
# - missing repos
|
|
342
|
-
# => for now, we process them as `RepoNotFound` anyway.
|
|
343
|
-
# See https://gist.github.com/Wauplin/46c27ad266b15998ce56a6603796f0b9
|
|
344
|
-
message = (
|
|
345
|
-
f"{response.status_code} Client Error."
|
|
346
|
-
+ "\n\n"
|
|
347
|
-
+ f"Repository Not Found for url: {response.url}."
|
|
348
|
-
+ "\nPlease make sure you specified the correct `repo_id` and"
|
|
349
|
-
" `repo_type`.\nIf you are trying to access a private or gated repo,"
|
|
350
|
-
" make sure you are authenticated."
|
|
351
|
-
)
|
|
352
|
-
raise RepositoryNotFoundError(message, response) from e
|
|
353
|
-
|
|
354
|
-
elif response.status_code == 400:
|
|
355
|
-
message = (
|
|
356
|
-
f"\n\nBad request for {endpoint_name} endpoint:" if endpoint_name is not None else "\n\nBad request:"
|
|
357
|
-
)
|
|
358
|
-
raise BadRequestError(message, response=response) from e
|
|
359
|
-
|
|
360
|
-
elif response.status_code == 403:
|
|
361
|
-
message = (
|
|
362
|
-
f"\n\n{response.status_code} Forbidden: {error_message}."
|
|
363
|
-
+ f"\nCannot access content at: {response.url}."
|
|
364
|
-
+ "\nIf you are trying to create or update content, "
|
|
365
|
-
+ "make sure you have a token with the `write` role."
|
|
366
|
-
)
|
|
367
|
-
raise HfHubHTTPError(message, response=response) from e
|
|
368
|
-
|
|
369
|
-
# Convert `HTTPError` into a `HfHubHTTPError` to display request information
|
|
370
|
-
# as well (request id and/or server error message)
|
|
371
|
-
raise HfHubHTTPError(str(e), response=response) from e
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
def _format_error_message(message: str, request_id: Optional[str], server_message: Optional[str]) -> str:
|
|
375
|
-
"""
|
|
376
|
-
Format the `HfHubHTTPError` error message based on initial message and information
|
|
377
|
-
returned by the server.
|
|
378
|
-
|
|
379
|
-
Used when initializing `HfHubHTTPError`.
|
|
380
|
-
"""
|
|
381
|
-
# Add message from response body
|
|
382
|
-
if server_message is not None and len(server_message) > 0 and server_message.lower() not in message.lower():
|
|
383
|
-
if "\n\n" in message:
|
|
384
|
-
message += "\n" + server_message
|
|
385
|
-
else:
|
|
386
|
-
message += "\n\n" + server_message
|
|
387
|
-
|
|
388
|
-
# Add Request ID
|
|
389
|
-
if request_id is not None and str(request_id).lower() not in message.lower():
|
|
390
|
-
request_id_message = f" (Request ID: {request_id})"
|
|
391
|
-
if "\n" in message:
|
|
392
|
-
newline_index = message.index("\n")
|
|
393
|
-
message = message[:newline_index] + request_id_message + message[newline_index:]
|
|
394
|
-
else:
|
|
395
|
-
message += request_id_message
|
|
396
|
-
|
|
397
|
-
return message
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|