MeUtils 2024.12.5.19.33.12__py3-none-any.whl → 2024.12.6.10.16.26__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MeUtils
3
- Version: 2024.12.5.19.33.12
3
+ Version: 2024.12.6.10.16.26
4
4
  Summary: description
5
5
  Home-page: https://github.com/yuanjie-ai/MeUtils
6
6
  Author: yuanjie
@@ -61,42 +61,42 @@ Requires-Dist: sse-starlette ; extra == 'ai'
61
61
  Requires-Dist: openai ; extra == 'ai'
62
62
  Requires-Dist: langchain ; extra == 'ai'
63
63
  Provides-Extra: all
64
- Requires-Dist: langchain ; extra == 'all'
64
+ Requires-Dist: missingno ; extra == 'all'
65
65
  Requires-Dist: pretty-errors ; extra == 'all'
66
- Requires-Dist: jieba ; extra == 'all'
67
- Requires-Dist: pyarrow ; extra == 'all'
68
- Requires-Dist: pymysql ; extra == 'all'
69
- Requires-Dist: faiss-cpu ; extra == 'all'
70
- Requires-Dist: reportlab ; extra == 'all'
71
- Requires-Dist: dataframe-image ; extra == 'all'
72
- Requires-Dist: sqlalchemy ; extra == 'all'
73
- Requires-Dist: schedule ; extra == 'all'
74
- Requires-Dist: pymongo ; extra == 'all'
75
- Requires-Dist: thefuck ; extra == 'all'
76
- Requires-Dist: seaborn ; extra == 'all'
77
- Requires-Dist: polars ; extra == 'all'
78
- Requires-Dist: pymupd ; extra == 'all'
79
66
  Requires-Dist: streamlit ; extra == 'all'
80
- Requires-Dist: missingno ; extra == 'all'
81
- Requires-Dist: simplejson ; extra == 'all'
67
+ Requires-Dist: iteration-utilities ; extra == 'all'
68
+ Requires-Dist: seaborn ; extra == 'all'
82
69
  Requires-Dist: sse-starlette ; extra == 'all'
70
+ Requires-Dist: fastapi ; extra == 'all'
83
71
  Requires-Dist: thriftpy2 ; extra == 'all'
84
- Requires-Dist: jmespath ; extra == 'all'
85
- Requires-Dist: pandas-summary ; extra == 'all'
86
- Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
72
+ Requires-Dist: langchain ; extra == 'all'
73
+ Requires-Dist: cachetools ; extra == 'all'
74
+ Requires-Dist: thefuck ; extra == 'all'
75
+ Requires-Dist: filetype ; extra == 'all'
76
+ Requires-Dist: polars ; extra == 'all'
77
+ Requires-Dist: gunicorn ; extra == 'all'
78
+ Requires-Dist: dataframe-image ; extra == 'all'
79
+ Requires-Dist: geopy ; extra == 'all'
87
80
  Requires-Dist: pymilvus ; extra == 'all'
88
- Requires-Dist: uvicorn ; extra == 'all'
89
- Requires-Dist: iteration-utilities ; extra == 'all'
90
81
  Requires-Dist: jinja2 ; extra == 'all'
91
- Requires-Dist: filetype ; extra == 'all'
92
- Requires-Dist: cachetools ; extra == 'all'
82
+ Requires-Dist: schedule ; extra == 'all'
93
83
  Requires-Dist: fastapi[all] ; extra == 'all'
94
- Requires-Dist: geopy ; extra == 'all'
95
- Requires-Dist: asyncmy ; extra == 'all'
96
- Requires-Dist: openai ; extra == 'all'
97
- Requires-Dist: gunicorn ; extra == 'all'
98
- Requires-Dist: fastapi ; extra == 'all'
84
+ Requires-Dist: pyarrow ; extra == 'all'
85
+ Requires-Dist: pymongo ; extra == 'all'
86
+ Requires-Dist: simplejson ; extra == 'all'
99
87
  Requires-Dist: redis-py-cluster ; extra == 'all'
88
+ Requires-Dist: sqlalchemy ; extra == 'all'
89
+ Requires-Dist: pandas-summary ; extra == 'all'
90
+ Requires-Dist: uvicorn ; extra == 'all'
91
+ Requires-Dist: jieba ; extra == 'all'
92
+ Requires-Dist: reportlab ; extra == 'all'
93
+ Requires-Dist: pymysql ; extra == 'all'
94
+ Requires-Dist: openai ; extra == 'all'
95
+ Requires-Dist: pymupd ; extra == 'all'
96
+ Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
97
+ Requires-Dist: jmespath ; extra == 'all'
98
+ Requires-Dist: asyncmy ; extra == 'all'
99
+ Requires-Dist: faiss-cpu ; extra == 'all'
100
100
  Provides-Extra: ann
101
101
  Requires-Dist: pymilvus ; extra == 'ann'
102
102
  Requires-Dist: faiss-cpu ; extra == 'ann'
@@ -225,7 +225,7 @@ meutils/np_utils.py,sha256=JzernZr0aj93l-hS49W1Wt07Sjuw_6_u9ytNiLt-wO4,3726
225
225
  meutils/path_utils.py,sha256=krhUCuqZozmXhgI6xOJd9Lt_e6enbhHuz3oJRhjZmeQ,2846
226
226
  meutils/pay.py,sha256=J7XeZ2vW7Q6xzt5GLLm2cmDY38sb2ym2Hqg3iu6SpUM,928
227
227
  meutils/pd_utils.py,sha256=UyOnRAH3HXhNd8VjoXxzchxP-9iddWsnYSoK8QzI7lI,6084
228
- meutils/pipe.py,sha256=jWRadwrzRD_bCWEeCyVduNdcFCiMa-tBfWzK9hSMslU,10141
228
+ meutils/pipe.py,sha256=VBSCwNNQRnHBZyb_CHessmjgnBWJ40ZQ-sDRJFM3aIw,12303
229
229
  meutils/sftp.py,sha256=SEkTI4z2fSL6p3shAvUilKC0Wfbi1AkTQZ-9unemKtw,956
230
230
  meutils/sk_utils.py,sha256=uvdbc51cGjznOK9OII2X23wK8oWSffrEKxcczy0au8I,796
231
231
  meutils/smooth_utils.py,sha256=pLCJMLGHgOMfWmwFuJGOVh2vGKFmJ8ZsQfppF7ZGzGQ,1506
@@ -328,7 +328,7 @@ meutils/apis/hf/r.py,sha256=jvD0WBM5dEZGG4rfdGZnUIh2W9sv-fqTFo-8ouLea60,1272
328
328
  meutils/apis/hf/x.py,sha256=QYLiTlTZk1b0wczGHeJMjQABQUQmI_Wk45gbCcCAdIc,862
329
329
  meutils/apis/hf/证件照.py,sha256=NVfFp-wO1YCpvf7ClInK-jVJO9atZuk9VN93GrPohoc,1262
330
330
  meutils/apis/hunyuan/__init__.py,sha256=vJg28p4USaiGt3vAPKurjuxTPtk_LdmThw3cNc48vpI,272
331
- meutils/apis/hunyuan/image_tools.py,sha256=Rkc96xIt31FjpaPNhE9leSAw_scbZwzmqx-VMfDYpxs,2994
331
+ meutils/apis/hunyuan/image_tools.py,sha256=o_Q8_-kp4F11bmZ-VA4_wmI_S5xdH8Dw6VIDbbYjNJY,3232
332
332
  meutils/apis/images/__init__.py,sha256=hs7HUJZvw_3DAtoapPnbZsEb4ng1p0a6fJGFFWwUcUk,272
333
333
  meutils/apis/images/deepinfra.py,sha256=N7IDJ9dubojOY--R30uQlzSBbuuy4OXkCkRB1ey0kcQ,3241
334
334
  meutils/apis/images/demo.py,sha256=Cjk-EKMKbp44czykW_44qR0TzElX8nNCALqXBBw5sJA,4405
@@ -428,7 +428,8 @@ meutils/async_task/utils.py,sha256=6M0YRIPhakpH3Geywkl-NPy_O2pQvnsDcQPyyTrA7Mc,5
428
428
  meutils/async_task/通用设计.py,sha256=kGdrJHJu9VoOkyGHREn0KUtBTibAaLIcG0O6hEJNhLA,3232
429
429
  meutils/async_task/tasks/__init__.py,sha256=flHRXJMdts_9az9T9V1c5l3Y-gaDD88COWrARr4WAKU,246
430
430
  meutils/async_task/tasks/_all.py,sha256=Vz63k9yvgj-IBGjekm0u2t571TTT0nMRMqcPvPqJAbY,533
431
- meutils/async_task/tasks/kling.py,sha256=mqGQ4qtvQOyg7kmhk4AyZBfnFOQOoAFSuzYX5F6MyHo,1037
431
+ meutils/async_task/tasks/hailuo.py,sha256=-H7EUfIP-C9qUvdn120T7QWZ2dQa24WIPDdnMk_qmeQ,875
432
+ meutils/async_task/tasks/kling.py,sha256=QVn5VvPdcH-BFOx8ABtVyqWiUNjI_vvwJtLeJpGNYac,948
432
433
  meutils/async_task/tasks/replicateai.py,sha256=wbxx6kB7GQZPnKRE6J6r1mEv3wO8X7XaGaNMC5rBVoE,716
433
434
  meutils/async_task/tasks/test.py,sha256=-nCQhwEP6hQEnmk3ucDbjbnxbeyOHrg0HXCJmWL0KBU,2675
434
435
  meutils/async_task/tasks/vidu.py,sha256=obBG4_bf1oPIlLxeca1s1dGOnlyam2xYRy-8TrH3ZTk,620
@@ -466,7 +467,7 @@ meutils/config_utils/lark_utils/demo.py,sha256=3g0Fs7oLaeW75T60gYWMLgyNg1OnfOjfH
466
467
  meutils/config_utils/lark_utils/x.py,sha256=MlMQGhehP9xMEgetxVCX68XFaosfKoW1JA5cZ3JqN2w,1857
467
468
  meutils/crawlers/__init__.py,sha256=TBU4xA-IOsHV-0yIkW7YXxn_QT7TT8NncqxO7IykEfs,271
468
469
  meutils/data/SimHei.ttf,sha256=-XEnekS5yHP_URkT4XBI2w22ylV-KxudhkeIYFbrILA,10062565
469
- meutils/data/VERSION,sha256=eznEsN-WnfTMsf7IP1BkLmykXEKhH5-egn-XeQW_SNc,19
470
+ meutils/data/VERSION,sha256=ZMq65B3ohIhOOCkkGA7noi6ApM3It-DG5ngX2y9udkI,19
470
471
  meutils/data/_FLAG,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
471
472
  meutils/data/_SUCCESS,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
472
473
  meutils/data/__init__.py,sha256=Hfwkkxs4zHqKhxht0YrhS566a9P5axtmgNvM5wF8ceQ,243
@@ -801,9 +802,9 @@ meutils/tools/seize.py,sha256=nOKAS63w-Lbi48I0m2MPhdsokUTwxco0laPxYVmW4Mw,1064
801
802
  meutils/tools/service_monitor.py,sha256=ibsLtBN2g2DL7ZnLJ8vhiZOiOcqTAyx711djDdBK-3M,1255
802
803
  meutils/tools/sys_monitor.py,sha256=6MoyzrItqDUOSjfHcMJmMofQkEPTW36CT_aKui0rg84,429
803
804
  meutils/tools/token_monitor.py,sha256=Np-YK-R4P4IPAXyZvMxwvXI4sFmNJQAQK1lSegNaYpA,997
804
- MeUtils-2024.12.5.19.33.12.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
805
- MeUtils-2024.12.5.19.33.12.dist-info/METADATA,sha256=5HluXUigaB2z6pphBk21Zmj-kDUglYD4vXn4v7DOd5c,6143
806
- MeUtils-2024.12.5.19.33.12.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
807
- MeUtils-2024.12.5.19.33.12.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
808
- MeUtils-2024.12.5.19.33.12.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
809
- MeUtils-2024.12.5.19.33.12.dist-info/RECORD,,
805
+ MeUtils-2024.12.6.10.16.26.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
806
+ MeUtils-2024.12.6.10.16.26.dist-info/METADATA,sha256=EITcoDk5xVv2qcN1kpad2AiPqRsgLVt1sJpiiFPiyj0,6143
807
+ MeUtils-2024.12.6.10.16.26.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
808
+ MeUtils-2024.12.6.10.16.26.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
809
+ MeUtils-2024.12.6.10.16.26.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
810
+ MeUtils-2024.12.6.10.16.26.dist-info/RECORD,,
@@ -16,6 +16,7 @@ from meutils.schemas.image_types import HunyuanImageProcessRequest
16
16
 
17
17
  from meutils.config_utils.lark_utils import get_next_token_for_polling
18
18
  from meutils.io.files_utils import to_url
19
+ from meutils.notice.feishu import send_message
19
20
 
20
21
 
21
22
  @retrying(min=3, ignored_exception_types=(IgnoredRetryException,))
@@ -40,10 +41,14 @@ async def image_process(request: HunyuanImageProcessRequest, token: Optional[str
40
41
  logger.debug(response.text)
41
42
 
42
43
  # 新版本的位置可能不一样 注意
43
- data = json_repair.repair_json(
44
- response.text.replace(r'\u0026', '&').rsplit("data: [TRACEID", 1)[0],
45
- return_objects=True
46
- )[-1]
44
+ # data = json_repair.repair_json(
45
+ # response.text.replace(r'\u0026', '&').rsplit("data: [TRACEID", 1)[0],
46
+ # return_objects=True
47
+ # )[-1]
48
+
49
+ skip_strings = ['DONE', 'TRACEID']
50
+ data = response.text.replace(r'\u0026', '&').splitlines() | xsse_parser(skip_strings=skip_strings)
51
+ data = data and data[-1]
47
52
  logger.debug(data)
48
53
 
49
54
  # todo: 错误处理
@@ -77,4 +82,3 @@ if __name__ == '__main__':
77
82
  request = HunyuanImageProcessRequest(image=image, task='removewatermark')
78
83
 
79
84
  arun(image_process(request))
80
-
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # @Project : AI. @by PyCharm
4
+ # @File : hailuo
5
+ # @Time : 2024/12/6 09:05
6
+ # @Author : betterme
7
+ # @WeChat : meutils
8
+ # @Software : PyCharm
9
+ # @Description :
10
+
11
+
12
+ from meutils.async_utils import async_to_sync_pro
13
+ from meutils.async_task import worker, shared_task
14
+ from meutils.apis.hailuoai.videos import VideoRequest, create_task, get_task
15
+
16
+
17
+ @shared_task(pydantic=True, retry_kwargs={'max_retries': 10, 'countdown': 10})
18
+ @async_to_sync_pro
19
+ async def create_task(request, **kwargs):
20
+ if isinstance(request, dict):
21
+ request = VideoRequest(**request)
22
+
23
+ response = await create_task(request)
24
+ return response.model_dump()
25
+
26
+
27
+ # celery_task
28
+
29
+
30
+ if __name__ == '__main__':
31
+ pass
32
+ # create_task.apply_async()
33
+ create_task.apply_async(kwargs={"request": VideoRequest().model_dump()})
@@ -8,9 +8,7 @@
8
8
  # @Software : PyCharm
9
9
  # @Description : 注册任务
10
10
 
11
- from meutils.pipe import *
12
11
  from meutils.async_utils import async_to_sync_pro
13
- from meutils.decorators.retry import retrying
14
12
  from meutils.async_task import worker, shared_task
15
13
 
16
14
  from meutils.apis.kling import kolors_virtual_try_on
@@ -26,9 +24,6 @@ async def create_task(request: kolors_virtual_try_on.TryOnRequest, **kwargs):
26
24
  return response.model_dump()
27
25
 
28
26
 
29
- # celery_task
30
-
31
-
32
27
  if __name__ == '__main__':
33
28
  pass
34
29
  # create_task.apply_async()
meutils/data/VERSION CHANGED
@@ -1 +1 @@
1
- 2024.12.05.19.33.12
1
+ 2024.12.06.10.16.26
meutils/pipe.py CHANGED
@@ -6,7 +6,8 @@
6
6
  # @Author : yuanjie
7
7
  # @Email : meutils@qq.com
8
8
  # @Software : PyCharm
9
- # @Description :
9
+ # @Description :
10
+ import json
10
11
 
11
12
  from meutils.common import *
12
13
  from meutils.async_utils.common import arun, aclose, alru_cache, async2sync_generator, close_event_loop, achain
@@ -303,6 +304,22 @@ def xAsyncio(tasks, return_exceptions=False):
303
304
  return loop.run_until_complete(_)
304
305
 
305
306
 
307
+ @Pipe
308
+ def xsse_parser(iterable, prefix: str = 'data:', skip_strings: Optional[list] = None):
309
+ l = []
310
+ skip_strings = skip_strings or []
311
+ for line in iterable:
312
+ if (line := line.lstrip()) and line.startswith(prefix):
313
+ if any(s in line for s in skip_strings):
314
+ continue
315
+ try:
316
+ _ = json.loads(line[len(prefix):])
317
+ l.append(_)
318
+ except Exception as e:
319
+ logger.debug(f'error: {e}\nline: {line}')
320
+ return l
321
+
322
+
306
323
  if __name__ == '__main__':
307
324
  # @Pipe
308
325
  # def xfunc1(x):
@@ -356,5 +373,21 @@ if __name__ == '__main__':
356
373
  # print(range(10) | xThreadPoolExecutor(print, 1) | xlist)
357
374
  # print(range(10) | xThreadPoolExecutor(print, 2) | xlist)
358
375
 
359
- print(range(10) | xProcessPoolExecutor(print, 1) | xlist)
360
- print(range(10) | xProcessPoolExecutor(print, 2) | xlist)
376
+ # print(range(10) | xProcessPoolExecutor(print, 1) | xlist)
377
+ # print(range(10) | xProcessPoolExecutor(print, 2) | xlist)
378
+
379
+ sse = """
380
+ data: {"type":"step","msg":"努力生成中...","code":200}
381
+ data: {"type":"progress","value":0.08333333333333333,"code":200}
382
+ data: {"type":"progress","value":0.16666666666666666,"code":200}
383
+ data: {"type":"progress","value":0.25,"code":200}
384
+ data: {"type":"progress","value":0.3333333333333333,"code":200}
385
+ data: {"type":"progress","value":0.4166666666666667,"code":200}
386
+ data: {"type":"progress","value":0.5,"code":200}
387
+ data: {"type":"removewatermark","id":"c0d1e312-b374-11ef-a22c-6a452a83f9ec","imageUrl":"https://hunyuan-prod-1258344703.cos.ap-guangzhou.myqcloud.com/removewatermark/f55df3ef029c13eba0832a11f77d03ad/20241206095236h0_d589b0620869d87ad340b4b4ed68b4ec.png?q-sign-algorithm=sha1\u0026q-ak=AKID0qSq0xJRL7h3A4nIYJFrFOJ1VlnbIm26\u0026q-sign-time=1733449957;1764985957\u0026q-key-time=1733449957;1764985957\u0026q-header-list=host\u0026q-url-param-list=\u0026q-signature=7bbec24fe87917896f662f65b80320a4a3fb8569","source":"inspiration","code":200,"thumbnailUrl":"https://hunyuan-prod-1258344703.cos.ap-guangzhou.myqcloud.com/removewatermark/f55df3ef029c13eba0832a11f77d03ad/20241206095236h0_d589b0620869d87ad340b4b4ed68b4ec.png?q-sign-algorithm=sha1\u0026q-ak=AKID0qSq0xJRL7h3A4nIYJFrFOJ1VlnbIm26\u0026q-sign-time=1733449957;1764985957\u0026q-key-time=1733449957;1764985957\u0026q-header-list=host\u0026q-url-param-list=\u0026q-signature=7bbec24fe87917896f662f65b80320a4a3fb8569\u0026imageMogr2/strip/format/jpg/size-limit/500k!/ignore-error/1"}
388
+ data: [TRACEID:8a50e3687e26e03097e507c076fe7145]
389
+ data: [DONE]"""
390
+
391
+ # print()
392
+
393
+ sse.splitlines() | xsse_parser(skip_strings=['DONE', 'TRACEID']) | xprint