MeUtils 2024.12.5.13.7.4__py3-none-any.whl → 2024.12.5.17.36.18__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.13.7.4
3
+ Version: 2024.12.5.17.36.18
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: thefuck ; extra == 'all'
65
- Requires-Dist: sqlalchemy ; extra == 'all'
66
- Requires-Dist: filetype ; extra == 'all'
67
- Requires-Dist: fastapi ; extra == 'all'
68
- Requires-Dist: gunicorn ; extra == 'all'
69
- Requires-Dist: redis-py-cluster ; extra == 'all'
70
- Requires-Dist: pymysql ; extra == 'all'
71
- Requires-Dist: pymupd ; extra == 'all'
72
- Requires-Dist: pymongo ; extra == 'all'
73
- Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
74
- Requires-Dist: fastapi[all] ; extra == 'all'
75
- Requires-Dist: thriftpy2 ; extra == 'all'
76
- Requires-Dist: pymilvus ; extra == 'all'
77
- Requires-Dist: pandas-summary ; extra == 'all'
78
- Requires-Dist: jieba ; extra == 'all'
79
- Requires-Dist: jinja2 ; extra == 'all'
80
- Requires-Dist: langchain ; extra == 'all'
81
- Requires-Dist: polars ; extra == 'all'
82
- Requires-Dist: streamlit ; extra == 'all'
83
64
  Requires-Dist: openai ; extra == 'all'
84
65
  Requires-Dist: geopy ; extra == 'all'
85
- Requires-Dist: pyarrow ; extra == 'all'
86
- Requires-Dist: faiss-cpu ; extra == 'all'
66
+ Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
67
+ Requires-Dist: pymilvus ; extra == 'all'
87
68
  Requires-Dist: iteration-utilities ; extra == 'all'
69
+ Requires-Dist: pymupd ; extra == 'all'
70
+ Requires-Dist: thefuck ; extra == 'all'
71
+ Requires-Dist: uvicorn ; extra == 'all'
72
+ Requires-Dist: faiss-cpu ; extra == 'all'
73
+ Requires-Dist: jmespath ; extra == 'all'
74
+ Requires-Dist: langchain ; extra == 'all'
75
+ Requires-Dist: sqlalchemy ; extra == 'all'
88
76
  Requires-Dist: missingno ; extra == 'all'
77
+ Requires-Dist: gunicorn ; extra == 'all'
78
+ Requires-Dist: polars ; extra == 'all'
79
+ Requires-Dist: jieba ; extra == 'all'
80
+ Requires-Dist: fastapi[all] ; extra == 'all'
89
81
  Requires-Dist: asyncmy ; extra == 'all'
90
- Requires-Dist: cachetools ; extra == 'all'
91
- Requires-Dist: sse-starlette ; extra == 'all'
82
+ Requires-Dist: pyarrow ; extra == 'all'
83
+ Requires-Dist: streamlit ; extra == 'all'
92
84
  Requires-Dist: reportlab ; extra == 'all'
85
+ Requires-Dist: fastapi ; extra == 'all'
93
86
  Requires-Dist: dataframe-image ; extra == 'all'
87
+ Requires-Dist: pandas-summary ; extra == 'all'
88
+ Requires-Dist: pymysql ; extra == 'all'
94
89
  Requires-Dist: simplejson ; extra == 'all'
95
- Requires-Dist: schedule ; extra == 'all'
96
- Requires-Dist: pretty-errors ; extra == 'all'
97
- Requires-Dist: jmespath ; extra == 'all'
98
- Requires-Dist: uvicorn ; extra == 'all'
99
90
  Requires-Dist: seaborn ; extra == 'all'
91
+ Requires-Dist: thriftpy2 ; extra == 'all'
92
+ Requires-Dist: redis-py-cluster ; extra == 'all'
93
+ Requires-Dist: pymongo ; extra == 'all'
94
+ Requires-Dist: pretty-errors ; extra == 'all'
95
+ Requires-Dist: sse-starlette ; extra == 'all'
96
+ Requires-Dist: jinja2 ; extra == 'all'
97
+ Requires-Dist: cachetools ; extra == 'all'
98
+ Requires-Dist: filetype ; extra == 'all'
99
+ Requires-Dist: schedule ; extra == 'all'
100
100
  Provides-Extra: ann
101
101
  Requires-Dist: pymilvus ; extra == 'ann'
102
102
  Requires-Dist: faiss-cpu ; extra == 'ann'
@@ -100,6 +100,7 @@ examples/_openaisdk/openai_god.py,sha256=O8fbhyxiIlVR7pTvBTXgQ2QTwfcZ2MkEIyDe_jp
100
100
  examples/_openaisdk/openai_groq.py,sha256=_5Ue1yEx0Gp6theFioB_D8kepR0UlqMU96PVGH-LkVY,7363
101
101
  examples/_openaisdk/openai_images.py,sha256=vGuKEbHxuK70Ls2PTbWUeET9q88Kncn22YLBp14bMO8,5114
102
102
  examples/_openaisdk/openai_json.py,sha256=1VfsTKe4yNX1rTRvzlz9oE3FWji_gf36H5OvUNfG0sw,1843
103
+ examples/_openaisdk/openai_modelscope.py,sha256=bKBtXpEN3_YxXRwlQEBV1YmjzT396zxByqdB6nxaEGI,1291
103
104
  examples/_openaisdk/openai_moon.py,sha256=Y7RrB6SUi9taQOlA50nfGTpQa9ON6XmPmrxtL-hSL8M,1753
104
105
  examples/_openaisdk/openai_search.py,sha256=HKRTU6y9j_nUfZgrJt2eZ84d7TVT39WN-dcA_BFkVb4,937
105
106
  examples/_openaisdk/openai_sensenova.py,sha256=TnJpHcD1tG5w_x5DsgFgBRWrU8XUkww0uCebgNFfZDM,3216
@@ -294,7 +295,7 @@ meutils/apis/kuaidi.py,sha256=4KrtOkbGlsLpyvbY80UMSo03iFqFiBHnE0CiqAWWQ4Y,998
294
295
  meutils/apis/llm_qa.py,sha256=XM1VMkOTb4xKzgVk56dPC1e8lg7SbnfobBVgfLXiX9A,1207
295
296
  meutils/apis/niutrans.py,sha256=weWjn-tUTEaAUe5RGbzcjQqPkJxGDrPwMB6CnaiZSsg,1682
296
297
  meutils/apis/search_music.py,sha256=HBLtdterztrccnLAPZrWBlrYSx4WCRflCqz-V30fOA8,972
297
- meutils/apis/textin.py,sha256=4Cd_iof2jgxtPxPsjWbBJ1B2rQoVrdJOFdWxP3ZKBQU,4749
298
+ meutils/apis/textin.py,sha256=6j0aBxhgpFfduGI13Rw9Lmd3d7a631XqopA9eDrNDX8,4867
298
299
  meutils/apis/ts.py,sha256=Q13EOS9Q-Y2-KwOG_cFMVmGj9RUmDtxk5A3E27dxbN0,1511
299
300
  meutils/apis/web_search.py,sha256=6gS3leIB2iyeLtqhB0IbpL_mKzDgArRTqnR7odTWT3E,1035
300
301
  meutils/apis/yezi.py,sha256=26vhnA3lC5049Rqx-CHO-wyGKbdZAfvjEOG90W38cr0,3675
@@ -327,7 +328,7 @@ meutils/apis/hf/r.py,sha256=jvD0WBM5dEZGG4rfdGZnUIh2W9sv-fqTFo-8ouLea60,1272
327
328
  meutils/apis/hf/x.py,sha256=QYLiTlTZk1b0wczGHeJMjQABQUQmI_Wk45gbCcCAdIc,862
328
329
  meutils/apis/hf/证件照.py,sha256=NVfFp-wO1YCpvf7ClInK-jVJO9atZuk9VN93GrPohoc,1262
329
330
  meutils/apis/hunyuan/__init__.py,sha256=vJg28p4USaiGt3vAPKurjuxTPtk_LdmThw3cNc48vpI,272
330
- meutils/apis/hunyuan/image_tools.py,sha256=LZdhmFzV4i9bhJ-4Lu02mEG3QtZryC4HwW9fgStzVGs,2177
331
+ meutils/apis/hunyuan/image_tools.py,sha256=5y93jzU2B4O3JUE1nWBSuhUJCY8zLeiT0BLGdwpYaCo,2550
331
332
  meutils/apis/images/__init__.py,sha256=hs7HUJZvw_3DAtoapPnbZsEb4ng1p0a6fJGFFWwUcUk,272
332
333
  meutils/apis/images/deepinfra.py,sha256=N7IDJ9dubojOY--R30uQlzSBbuuy4OXkCkRB1ey0kcQ,3241
333
334
  meutils/apis/images/demo.py,sha256=Cjk-EKMKbp44czykW_44qR0TzElX8nNCALqXBBw5sJA,4405
@@ -375,7 +376,7 @@ meutils/apis/oneapi/user.py,sha256=Q4FhUwuUZlOpe9qh8P4ioTnGX3cEtBae39bSMciWDA8,3
375
376
  meutils/apis/pixverse/__init__.py,sha256=WiboEUfJ_3Hs2WI3OymEspx8_ZSTgMglxTJd97Qk7qo,271
376
377
  meutils/apis/pixverse/pixverse.py,sha256=dvnyYVUXCEY_cLnmX9lvq9TesvplCMCuJmmP7ShchQk,5534
377
378
  meutils/apis/proxy/__init__.py,sha256=by7_6GT3xeDjAWLLqbw8uvGaZ3RdprEW-zJ2DFLOdwA,271
378
- meutils/apis/proxy/ips.py,sha256=6ck3GYuJgujyk5lckTbsOE_d3ia1aXA9t2KCPIibwTo,5250
379
+ meutils/apis/proxy/ips.py,sha256=gdnzX7BUuraU4Vpr8l0t1liw9Z6Ow3ZAe7D6wkWk01c,5339
379
380
  meutils/apis/remini/__init__.py,sha256=8TbAnbI_bDfH8g0Y9EHXHBum7C0rZt9MzgAAz_MbAeI,271
380
381
  meutils/apis/remini/remini.py,sha256=bJjvtqrCNlAu7No4gYGjoWAM0ch6dCsofYSy2jPZrXg,4239
381
382
  meutils/apis/replicateai/__init__.py,sha256=PK7e7-xhn5aj5WOyGHLzpsHQvpeM5uTOiMylvj40ZmU,272
@@ -465,14 +466,14 @@ meutils/config_utils/lark_utils/demo.py,sha256=3g0Fs7oLaeW75T60gYWMLgyNg1OnfOjfH
465
466
  meutils/config_utils/lark_utils/x.py,sha256=MlMQGhehP9xMEgetxVCX68XFaosfKoW1JA5cZ3JqN2w,1857
466
467
  meutils/crawlers/__init__.py,sha256=TBU4xA-IOsHV-0yIkW7YXxn_QT7TT8NncqxO7IykEfs,271
467
468
  meutils/data/SimHei.ttf,sha256=-XEnekS5yHP_URkT4XBI2w22ylV-KxudhkeIYFbrILA,10062565
468
- meutils/data/VERSION,sha256=GcxSWoczXhMN72dD3Lh09C7sI4RiXKukQ1j5kgvCxqs,19
469
+ meutils/data/VERSION,sha256=h8fEMh2gMBwxWG4H4NJxSMgC5u83FZ9NORoJX3KasgA,19
469
470
  meutils/data/_FLAG,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
470
471
  meutils/data/_SUCCESS,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
471
472
  meutils/data/__init__.py,sha256=Hfwkkxs4zHqKhxht0YrhS566a9P5axtmgNvM5wF8ceQ,243
472
473
  meutils/data/coordinate.py,sha256=VbFtcdho0XG4j-rZD0DgqcIf2_LR2LlbLtfhLXbxiDY,600
473
474
  meutils/data/cowboy-hat-face.webp,sha256=AHi2t-WclDVKWgGEe-oZzI4xKACNlgGWUgd622y0K-E,24814
474
475
  meutils/data/oneapi/FOOTER.md,sha256=UHv39ey2ICocxPoCj-UI_PWyyWxZYLS8zG1inqtWNQ4,448
475
- meutils/data/oneapi/NOTICE.md,sha256=7yF5djeqq0MBUTtcYZxcYzeSGzPLdeJTceEldxS2eUA,1751
476
+ meutils/data/oneapi/NOTICE.md,sha256=PXUnFv_3MBM-MTrrvQrCFQdPjubM-1bTy_tIE9lREEg,1855
476
477
  meutils/data/oneapi/__init__.py,sha256=cm2Kq2RDXPfdVMWcoBB77bu00zJpTDd21Rgc6bTlhws,398
477
478
  meutils/db/__init__.py,sha256=HR99rqxoFTWXUHDhLVl33tzIn8M86gigHLmEzOKH1Ec,7637
478
479
  meutils/db/mongo.py,sha256=B-B_t939rxtnNGt0PxhivjIUwinmHPzLUpXsjUIaTkQ,2337
@@ -490,7 +491,7 @@ meutils/decorators/decorator_demo.py,sha256=JLCulTW04uYHzLg6jRxVseaAdU-YeyL8Z2p-
490
491
  meutils/decorators/demo.py,sha256=EZ9uYz5zGdAqUxa9l2C8gTZqdjY5Uw2uZsAUa9tZXq0,710
491
492
  meutils/decorators/fastapi_decorator.py,sha256=TH5XtzALxDOFVJsK9XMx9xwV9_n9u7cGa9pwHUR218Q,3428
492
493
  meutils/decorators/feishu.py,sha256=0mJSJXIQSc2qYafZzeDPb6XhH6fL8u0pUI9bhOljn1M,3634
493
- meutils/decorators/retry.py,sha256=ar0e9_rwxEDpc2pV3H88NZjBKOyUaB85MDMpd8I7rdo,5249
494
+ meutils/decorators/retry.py,sha256=PV42YxBzzf5r8MKjzfkSyV3r6JiH9R_OBIo_1W2tPqg,6242
494
495
  meutils/decorators/scheduler.py,sha256=NHeUXABx8YpHbxASqAJWEKa3i1AcyvIGcUW461glYKY,1678
495
496
  meutils/decorators/schedulers.py,sha256=pZrqMVXl7levZdUgUYHfjwA8oJIPJvbVcQw5CwhuiWU,2664
496
497
  meutils/easy_search/__init__.py,sha256=ZWP75-HhKeyckGGR7M_dOXPjuY9PjWDl_bLhZOes0g0,242
@@ -640,7 +641,7 @@ meutils/schemas/fish_types.py,sha256=yC0ZFr3Ebh8F0OhtMsXYaIfNNvzOM2LT9YtKTaRoHGU
640
641
  meutils/schemas/hailuo_types.py,sha256=hmkjFPID5HS26Ayk80xS2a38XcubokEHxzg86cC0Ki8,6150
641
642
  meutils/schemas/haimian_types.py,sha256=jGu484UviAeBgy5OIUyRY4uYCxXfv16zDPqiJQr9wNQ,1364
642
643
  meutils/schemas/idphoto_types.py,sha256=nuHbpppejRSkJCiQ7YKx0Gnke0ShKZhOvdg0e7tk9-0,1074
643
- meutils/schemas/image_types.py,sha256=u8lPJU3robAxbACv54sMhCdET2VAb8g-zSW8EqtDuh8,11291
644
+ meutils/schemas/image_types.py,sha256=mba128lFaIGhPcUJG5JZeDGxNYFRgkJrMuWPY8iG6LA,11569
644
645
  meutils/schemas/jina_types.py,sha256=SLRRBCap2B1uXnHF7Sgnlz1Work8HvdIltjj4oVlGTk,8826
645
646
  meutils/schemas/kimi_types.py,sha256=PjCgHwCDNzKasn4X6rUzvOENqKYT3xj07cgp71IdsDA,3607
646
647
  meutils/schemas/kling_types.py,sha256=brWaREBtQeZGUuwgOW2p-vIm2WWInYkq8UfrLInT-Ik,6959
@@ -673,7 +674,7 @@ meutils/schemas/db/__init__.py,sha256=m1maURVoM6dIW0yt6ELZrZTzULtkHybVOSXtHNJRVI
673
674
  meutils/schemas/db/oneapi_types.py,sha256=Jtt1hXRS5C3DHf_wrkjklVcdPllsAFrzvLq9JLuTdtc,2858
674
675
  meutils/schemas/oneapi/__init__.py,sha256=uevbi3QAvFzN9WPbx9bYKTDyKt7P2ueZO6W0nSiD0sk,289
675
676
  meutils/schemas/oneapi/_types.py,sha256=ClvAaNy3SahEN8lL8KEErHTD6HANelXUeKc_3iLfosQ,1488
676
- meutils/schemas/oneapi/common.py,sha256=ULNre1gz100UuP2wMLlIjkcCO7tbhXmDcKwo0u-9XGk,22723
677
+ meutils/schemas/oneapi/common.py,sha256=GbOIYs2JIvmO_9GVKE-EY6ddeHbAPpu4uz8k0AHQe2o,22822
677
678
  meutils/schemas/oneapi/icons.py,sha256=T7W5gInBJoHe62wzMimbG_UI-wn3_-rmQ1O4O2z-CQY,1089
678
679
  meutils/schemas/oneapi/model_group_info.py,sha256=rGtflYJuFIjk5MsVEvK9JUR4IciX8jfErqeLqf8DIlQ,1586
679
680
  meutils/schemas/oneapi/model_info.py,sha256=_uwKEPIIqm7ZYfhmpxtXB2QNsS83SpJY-OaBzvogC9w,772
@@ -800,9 +801,9 @@ meutils/tools/seize.py,sha256=nOKAS63w-Lbi48I0m2MPhdsokUTwxco0laPxYVmW4Mw,1064
800
801
  meutils/tools/service_monitor.py,sha256=ibsLtBN2g2DL7ZnLJ8vhiZOiOcqTAyx711djDdBK-3M,1255
801
802
  meutils/tools/sys_monitor.py,sha256=6MoyzrItqDUOSjfHcMJmMofQkEPTW36CT_aKui0rg84,429
802
803
  meutils/tools/token_monitor.py,sha256=Np-YK-R4P4IPAXyZvMxwvXI4sFmNJQAQK1lSegNaYpA,997
803
- MeUtils-2024.12.5.13.7.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
804
- MeUtils-2024.12.5.13.7.4.dist-info/METADATA,sha256=9AM688byUDAMgIIrtjLD3qA42XljQfzUCMSBiP9r-Vs,6141
805
- MeUtils-2024.12.5.13.7.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
806
- MeUtils-2024.12.5.13.7.4.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
807
- MeUtils-2024.12.5.13.7.4.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
808
- MeUtils-2024.12.5.13.7.4.dist-info/RECORD,,
804
+ MeUtils-2024.12.5.17.36.18.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
805
+ MeUtils-2024.12.5.17.36.18.dist-info/METADATA,sha256=5DREhdZbj1QqcUYBeCanVPJ0wydI6PbCMjmZpiMhgnQ,6143
806
+ MeUtils-2024.12.5.17.36.18.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
807
+ MeUtils-2024.12.5.17.36.18.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
808
+ MeUtils-2024.12.5.17.36.18.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
809
+ MeUtils-2024.12.5.17.36.18.dist-info/RECORD,,
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # @Project : AI. @by PyCharm
4
+ # @File : openai_siliconflow
5
+ # @Time : 2024/6/26 10:42
6
+ # @Author : betterme
7
+ # @WeChat : meutils
8
+ # @Software : PyCharm
9
+ # @Description :
10
+ """
11
+ Qwen/Qwen2.5-Coder-32B-InstructQwen/Qwen2.5-Coder-14B-InstructQwen/Qwen2.5-Coder-7B-InstructQwen/Qwen2.5-72B-InstructQwen/Qwen2.5-32B-InstructQwen/Qwen2.5-14B-InstructQwen/Qwen2.5-7B-Instruct
12
+
13
+ """
14
+ import os
15
+
16
+ from meutils.pipe import *
17
+ from openai import OpenAI
18
+ from openai import OpenAI, APIStatusError
19
+
20
+ client = OpenAI(
21
+ # api_key=os.getenv("STEP_API_KEY"),
22
+ # base_url="https://api.stepfun.com/v1",
23
+ base_url=os.getenv("MODELSCOPE_BASE_URL"),
24
+ api_key=os.getenv("MODELSCOPE_API_KEY")
25
+ )
26
+
27
+ print(client.models.list())
28
+
29
+ try:
30
+ completion = client.chat.completions.create(
31
+ # model="step-1-8k",
32
+ model="Qwen/QwQ-32B-Preview",
33
+ messages=[
34
+ {"role": "user", "content": "讲个故事"}
35
+ ],
36
+ # top_p=0.7,
37
+ top_p=None,
38
+ temperature=None,
39
+ stream=True,
40
+ max_tokens=1000
41
+ )
42
+ except APIStatusError as e:
43
+ print(e.status_code)
44
+
45
+ print(e.response)
46
+ print(e.message)
47
+ print(e.code)
48
+
49
+ for chunk in completion:
50
+ print(chunk.choices[0].delta.content)
@@ -10,7 +10,7 @@
10
10
  import json_repair
11
11
 
12
12
  from meutils.pipe import *
13
- from meutils.decorators.retry import retrying
13
+ from meutils.decorators.retry import retrying, IgnoredRetryException
14
14
  from meutils.schemas.yuanbao_types import FEISHU_URL, YUANBAO_BASE_URL
15
15
  from meutils.schemas.image_types import HunyuanImageProcessRequest
16
16
 
@@ -18,7 +18,7 @@ from meutils.config_utils.lark_utils import get_next_token_for_polling
18
18
  from meutils.io.files_utils import to_url
19
19
 
20
20
 
21
- @retrying(min=3)
21
+ @retrying(min=3, ignored_exception_types=(IgnoredRetryException,))
22
22
  async def image_process(request: HunyuanImageProcessRequest, token: Optional[str] = None):
23
23
  token = token or await get_next_token_for_polling(FEISHU_URL)
24
24
 
@@ -39,10 +39,15 @@ async def image_process(request: HunyuanImageProcessRequest, token: Optional[str
39
39
  response.raise_for_status()
40
40
  logger.debug(response.text)
41
41
 
42
- data: dict = json_repair.repair_json(response.text.replace(r'\u0026', '&'), return_objects=True)[-2]
43
- if any(data["code"] == code for code in {"429"}):
42
+ data = json_repair.repair_json(response.text.replace(r'\u0026', '&'), return_objects=True)[-2]
43
+
44
+ # todo: 错误处理
45
+ if isinstance(data, dict) and any(data["code"] == code for code in {"429"}):
44
46
  Exception("重试")
45
47
 
48
+ elif any(i in response.text for i in {"当前图片没有检测到水印"}): # 跳过重试并返回原始错误
49
+ raise IgnoredRetryException(data)
50
+
46
51
  data = {
47
52
  "data": [
48
53
  {
@@ -61,6 +66,7 @@ if __name__ == '__main__':
61
66
 
62
67
  with timer():
63
68
  image = "https://sfile.chatglm.cn/chatglm4/3dcb1cc2-22ad-420b-9d16-dc71dffc02b2.png"
64
- request = ImageProcessRequest(image=image, task='clarity')
69
+ image = "https://oss.ffire.cc/files/kling_watermark.png"
70
+ request = HunyuanImageProcessRequest(image=image, task='removewatermark')
65
71
 
66
72
  arun(image_process(request))
meutils/apis/proxy/ips.py CHANGED
@@ -36,12 +36,15 @@ async def get_one_proxy(token: Optional[str] = None, feishu_url: str = "", from_
36
36
  else:
37
37
  # 随机获取ip: 如果从redis就是循环队列 check_proxy
38
38
  ip = await get_next_token_for_polling(feishu_url, from_redis=from_redis)
39
+ # https://github.com/encode/httpx/pull/2879
40
+ # proxies = {
41
+ # "http://": f"http://{ip}", # 自建 38443
42
+ # "https://": f"http://{ip}",
43
+ # }
39
44
 
40
- proxies = {
41
- "http://": f"http://{ip}", # 自建 38443
42
- "https://": f"http://{ip}",
43
- }
44
- return proxies
45
+ proxy = f"http://{ip}"
46
+
47
+ return proxy
45
48
 
46
49
 
47
50
  def checkip(): # 获取本地ip
@@ -154,12 +157,11 @@ if __name__ == '__main__':
154
157
  #
155
158
  # logger.debug(resp.text)
156
159
  ip = "http://proxy.chatfire.cn"
157
- ip="http://chatfire:chatfire@110.42.51.201:38443"
158
- ip="http://154.9.253.9:38443"
160
+ ip = "http://chatfire:chatfire@110.42.51.201:38443"
161
+ ip = "http://154.9.253.9:38443"
159
162
  ip = "http://154.9.252.28:38443"
160
- ip="http://110.42.51.223:38443"
161
- ip="http://154.40.54.76:38443"
162
-
163
+ ip = "http://110.42.51.223:38443"
164
+ ip = "http://154.40.54.76:38443"
163
165
 
164
166
  proxies = {'http://': ip, 'https://': ip}
165
167
 
meutils/apis/textin.py CHANGED
@@ -9,6 +9,8 @@
9
9
  # @Description : todo: 重构 https://tools.textin.com/
10
10
  # https://www.textin.com/console/recognition/robot_enhance?service=watermark-remove
11
11
 
12
+ # proxies 取消了 https://github.com/encode/httpx/pull/2879
13
+
12
14
  from meutils.pipe import *
13
15
  from meutils.decorators.retry import retrying
14
16
  from meutils.notice.feishu import send_message
@@ -21,14 +23,7 @@ ua = UserAgent()
21
23
 
22
24
  BASE_URL = "https://api.textin.com/home"
23
25
 
24
- ip = "110.42.51.201"
25
- ip = "http://proxy.chatfire.cn/"
26
- proxies = {
27
- "http://": ip, # 自建 8443
28
- "https://": ip,
29
- }
30
-
31
-
26
+ proxy = "http://110.42.51.201:38443"
32
27
 
33
28
 
34
29
  @alru_cache(ttl=3600 * 24)
@@ -72,27 +67,32 @@ async def document_process(data: bytes,
72
67
  logger.debug(response.status_code)
73
68
  # logger.info(response.json()) # {'msg': '今日请求超过限制次数', 'code': 431}
74
69
 
75
- if response.is_success:
76
- _ = response.json()
70
+ _ = response.json()
71
+
72
+ raise Exception("更新请求头或者加代理")
73
+
74
+ # if '今日请求超过限制次数' in str(_):
75
+ # # logger.info(response.json())
76
+ # raise Exception("更新请求头或者加代理")
77
+ # else:
78
+ # break
77
79
 
78
- if '今日请求超过限制次数' in str(_):
79
- # logger.info(response.json())
80
- raise Exception("更新请求头或者加代理")
81
- else:
82
- break
83
80
 
84
81
  except Exception as e: # 加代理
85
82
  logger.error(e)
86
83
 
87
84
  request_kwargs = {
88
- "proxies": await get_one_proxy(),
89
- # "proxies": proxies,
85
+ # "proxy": await get_one_proxy(),
86
+ "proxy": proxy,
87
+
90
88
  }
91
89
 
92
- if response_format == "url" and service in {"watermark-remove", "dewarp"}:
90
+ if response_format == "url" and service in {"watermark-remove", "crop_enhance_image"}:
93
91
  if "data" not in _:
94
92
  send_message(_, title=__name__)
95
93
 
94
+ # _ => {'msg': '今日请求超过限制次数', 'code': 431}
95
+
96
96
  url = await to_url(_['data']['result']['image'])
97
97
  _ = {"data": [{"url": url}]}
98
98
 
@@ -119,15 +119,16 @@ if __name__ == '__main__':
119
119
 
120
120
  service = Purpose.watermark_remove.value
121
121
 
122
-
123
122
  # service = "pdf_to_markdown"
124
123
 
125
- service = 'dewarp'
124
+ service = 'bill_recognize_v2'
125
+
126
126
 
127
127
  async def main(n=1):
128
128
  for i in tqdm(range(n)):
129
129
  try:
130
130
  _ = await document_process(data, service=service)
131
+ logger.debug(bjson(_))
131
132
  except Exception as e:
132
133
  logger.error(f"{i}: {e}")
133
134
  break
meutils/data/VERSION CHANGED
@@ -1 +1 @@
1
- 2024.12.05.13.07.04
1
+ 2024.12.05.17.36.18
@@ -2,6 +2,10 @@
2
2
 
3
3
  ---
4
4
 
5
+ ## 2024-12-05
6
+ - 新增模型gpt-4-plus/gpt-4o-plus按倍率计算
7
+ > OpenAI-plus会员 逆向工程
8
+
5
9
  ## 2024-11-29
6
10
  - 新增推理模型
7
11
  - Qwen/QwQ-32B-Preview
@@ -11,12 +11,17 @@
11
11
  from meutils.pipe import *
12
12
  from tenacity import retry, stop_after_attempt, before_sleep_log
13
13
  from tenacity import wait_fixed, wait_exponential, wait_incrementing, wait_exponential_jitter # Wait strategy
14
- from tenacity import retry_if_result, retry_if_exception, retry_if_exception_type, RetryCallState # 重试策略
14
+ from tenacity import retry_if_result, RetryCallState # 重试策略
15
+ from tenacity import retry_if_exception, retry_if_exception_type, retry_if_not_exception_type
15
16
 
16
17
  # 不兼容异步
17
18
  from meutils.notice.feishu import send_message
18
19
 
19
20
 
21
+ class IgnoredRetryException(Exception):
22
+ pass
23
+
24
+
20
25
  def default_retry_error_callback(retry_state: RetryCallState, title: Optional[str] = None):
21
26
  """return the result of the last call attempt"""
22
27
  # logger.debug(f"最后一次重试仍然失败调用的函数: {retry_state.outcome}")
@@ -50,7 +55,11 @@ def retrying(
50
55
  max: int = 100000,
51
56
  retry_error_callback: Optional[Callable[[RetryCallState], Any]] = None,
52
57
  predicate: Callable[[Any], bool] = lambda r: False,
53
- title: Optional[str] = None
58
+ title: Optional[str] = None,
59
+ ignored_exception_types: Optional[typing.Union[
60
+ typing.Type[BaseException],
61
+ typing.Tuple[typing.Type[BaseException], ...],
62
+ ]] = None, # 该错误类型不重试
54
63
  ):
55
64
  import logging
56
65
 
@@ -65,8 +74,9 @@ def retrying(
65
74
  & retry_if_exception(not_in_status_codes)
66
75
  )
67
76
  | retry_if_result(predicate)
68
-
69
77
  )
78
+ if ignored_exception_types:
79
+ retry_reasons = retry_reasons & retry_if_not_exception_type(ignored_exception_types)
70
80
 
71
81
  _retry_decorator = retry(
72
82
  reraise=True,
@@ -166,13 +176,12 @@ if __name__ == '__main__':
166
176
  # # print(wait_incrementing(100, -10)(retry_state))
167
177
  # print(wait_exponential(1, exp_base=2)(retry_state))
168
178
 
169
- @retrying(3)
170
- async def f():
171
- logger.debug("retry")
172
- pass
173
- # 1 / 0
174
- raise Exception('xx')
175
-
179
+ # @retrying(3)
180
+ # async def f():
181
+ # logger.debug("retry")
182
+ # pass
183
+ # # 1 / 0
184
+ # raise Exception('xx')
176
185
 
177
186
  # try:
178
187
  # f()
@@ -181,17 +190,43 @@ if __name__ == '__main__':
181
190
  # print(e)
182
191
  # print(type(e))
183
192
 
184
- @retrying(3)
185
- def f():
186
- # async def f():
187
- logger.debug("retry")
188
- for i in range(10):
189
- yield ""
190
- if i == 8:
191
- raise Exception('xx')
193
+ # @retrying(3)
194
+ # def f():
195
+ # # async def f():
196
+ # logger.debug("retry")
197
+ # for i in range(10):
198
+ # yield ""
199
+ # if i == 8:
200
+ # raise Exception('xx')
192
201
 
202
+ # arun(f())
193
203
 
204
+ # f()
205
+
206
+ # 示例使用
207
+ class CustomError1(Exception):
208
+ pass
209
+
210
+
211
+ class CustomError2(Exception):
212
+ pass
213
+
214
+
215
+ @retrying(
216
+ max_retries=3,
217
+ ignored_exception_types=(CustomError1, IgnoredRetryException)
218
+ )
219
+ def my_function():
220
+ logger.debug(1)
221
+ # 模拟抛出异常
222
+ raise IgnoredRetryException("This is a custom error")
223
+
224
+
225
+ def main():
226
+ try:
227
+ my_function()
228
+ except Exception as e:
229
+ print(f"Operation failed after all retries: {e}")
194
230
 
195
- # arun(f())
196
231
 
197
- f()
232
+ main()
@@ -385,11 +385,24 @@ class HunyuanImageProcessRequest(ImageProcessRequest):
385
385
 
386
386
 
387
387
  TEXTIN_TASKS = {
388
+ # 文本解析
388
389
  "image-to-markdown": "pdf_to_markdown",
389
390
  "pdf-to-markdown": "pdf_to_markdown",
391
+ "textin-pdf-to-markdown": "pdf_to_markdown",
392
+
393
+ # 去水印
390
394
  'textin-removewatermark': 'watermark-remove',
395
+
396
+ 'textin-ocr': 'text_recognize_3d1',
391
397
  'text-recognize': 'text_recognize_3d1',
392
- 'dewarp': 'dewarp'
398
+
399
+ # 图片提取表格
400
+ "textin-table": "table",
401
+
402
+ "textin-crop-enhance": "crop_enhance_image",
403
+
404
+ # 票据识别
405
+ "textin-bill-recognize": "bill_recognize_v2",
393
406
  }
394
407
 
395
408
 
@@ -176,7 +176,6 @@ MODEL_PRICE = {
176
176
  "gpt-4-all": 0.1,
177
177
  "gpt-4o-all": 0.1,
178
178
 
179
- "gpt-4-mobile": 0.1,
180
179
  "gpt-4-gizmo-*": 0.1,
181
180
  "advanced-voice": 1,
182
181
 
@@ -236,6 +235,10 @@ MODEL_PRICE = {
236
235
  }
237
236
 
238
237
  MODEL_RATIO = {
238
+ # 智能体
239
+ "gpt-4-plus": 2.5,
240
+ "gpt-4o-plus": 2.5,
241
+
239
242
  # embedding & rerank
240
243
  "rerank-multilingual-v2.0": 0.1,
241
244
  "rerank-multilingual-v3.0": 0.1,
@@ -550,6 +553,10 @@ MODEL_RATIO = {
550
553
  }
551
554
 
552
555
  COMPLETION_RATIO = {
556
+ # 智能体
557
+ "gpt-4-plus": 5,
558
+ "gpt-4o-plus": 5,
559
+
553
560
  "grok": 3,
554
561
  "grok-beta": 3,
555
562
  "x-ai/grok-beta": 3,