MeUtils 2025.4.15.13.18.47__py3-none-any.whl → 2025.4.18.13.49.52__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.
- {MeUtils-2025.4.15.13.18.47.dist-info → MeUtils-2025.4.18.13.49.52.dist-info}/METADATA +261 -261
- {MeUtils-2025.4.15.13.18.47.dist-info → MeUtils-2025.4.18.13.49.52.dist-info}/RECORD +26 -23
- examples/_openaisdk/openai_google.py +10 -7
- examples/_openaisdk/openai_wuwen.py +58 -0
- meutils/ai_audio/tts/openai_tts.py +1 -1
- meutils/apis/baidu/bdaitpzs.py +4 -1
- meutils/apis/google/gemini_sdk.py +4 -2
- meutils/apis/images/edits.py +4 -7
- meutils/apis/images/recraft.py +11 -8
- meutils/apis/oneapi/utils.py +21 -6
- meutils/apis/proxy/kdlapi.py +3 -2
- meutils/apis/volcengine_apis/__init__.py +11 -0
- meutils/apis/volcengine_apis/images.py +148 -0
- meutils/data/VERSION +1 -1
- meutils/db/orm.py +2 -2
- meutils/decorators/contextmanagers.py +13 -13
- meutils/io/files_utils.py +3 -2
- meutils/llm/check_utils.py +3 -1
- meutils/llm/openai_polling/images.py +21 -0
- meutils/schemas/db/oneapi_types.py +1 -0
- meutils/schemas/image_types.py +2 -2
- meutils/schemas/oneapi/common.py +42 -15
- {MeUtils-2025.4.15.13.18.47.dist-info → MeUtils-2025.4.18.13.49.52.dist-info}/LICENSE +0 -0
- {MeUtils-2025.4.15.13.18.47.dist-info → MeUtils-2025.4.18.13.49.52.dist-info}/WHEEL +0 -0
- {MeUtils-2025.4.15.13.18.47.dist-info → MeUtils-2025.4.18.13.49.52.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.4.15.13.18.47.dist-info → MeUtils-2025.4.18.13.49.52.dist-info}/top_level.txt +0 -0
@@ -112,23 +112,20 @@ async def atry_catch(
|
|
112
112
|
data = {
|
113
113
|
"task_name": task_name,
|
114
114
|
}
|
115
|
-
for k, v in kwargs.items():
|
116
|
-
if isinstance(v, BaseModel):
|
117
|
-
v = v.model_dump(exclude_none=True)
|
118
|
-
data[k] = v
|
119
|
-
|
120
|
-
# logger.debug(data)
|
121
115
|
|
122
116
|
try:
|
123
117
|
yield
|
124
118
|
except Exception as e:
|
125
|
-
if is_trace
|
126
|
-
error_msg = f"""{traceback.format_exc()}"""
|
127
|
-
else:
|
128
|
-
error_msg = f"{e}"
|
129
|
-
|
119
|
+
error_msg = f"""{traceback.format_exc()}""" if is_trace else f"{e}"
|
130
120
|
data["error"] = error_msg
|
131
121
|
|
122
|
+
for k, v in kwargs.items():
|
123
|
+
if isinstance(v, BaseModel):
|
124
|
+
v = v.model_dump(exclude_none=True)
|
125
|
+
data[k] = v
|
126
|
+
|
127
|
+
# logger.debug(data)
|
128
|
+
|
132
129
|
callback(data)
|
133
130
|
raise
|
134
131
|
|
@@ -192,6 +189,9 @@ if __name__ == '__main__':
|
|
192
189
|
# print(f"Task result: {result}")
|
193
190
|
# except TimeoutError:
|
194
191
|
# print("Task did not complete in time.")
|
192
|
+
async def main():
|
193
|
+
async with atry_catch("test"):
|
194
|
+
1 / 0
|
195
|
+
|
195
196
|
|
196
|
-
|
197
|
-
1 / 0
|
197
|
+
arun(main())
|
meutils/io/files_utils.py
CHANGED
@@ -147,14 +147,15 @@ async def to_url(
|
|
147
147
|
content_type: Optional[str] = None,
|
148
148
|
mime_type: Optional[str] = None
|
149
149
|
):
|
150
|
+
content_type = content_type or mime_type
|
151
|
+
|
150
152
|
if isinstance(file, list):
|
151
|
-
tasks = [to_url(_, f"{shortuuid.random()}_{filename}", headers) for _ in file]
|
153
|
+
tasks = [to_url(_, f"{shortuuid.random()}_{filename}", headers, content_type=content_type) for _ in file]
|
152
154
|
urls = await asyncio.gather(*tasks)
|
153
155
|
return urls
|
154
156
|
|
155
157
|
if not file: return
|
156
158
|
|
157
|
-
content_type = content_type or mime_type
|
158
159
|
file = await to_bytes(file, headers=headers)
|
159
160
|
file_url = await Minio().upload(file, filename, content_type=content_type)
|
160
161
|
return file_url
|
meutils/llm/check_utils.py
CHANGED
@@ -165,7 +165,9 @@ if __name__ == '__main__':
|
|
165
165
|
|
166
166
|
# arun(check_token_for_jina(["jina_c8da77fed9704d558c8def39837960edplTLkNYrsPTJHBF1HcYg_RkRVh0X"]*10))
|
167
167
|
|
168
|
-
arun(check_token_for_siliconflow("sk-
|
168
|
+
# arun(check_token_for_siliconflow("sk-jcsgbsqkdctaxunqljmghdahokavyliamkcgbhosfsoyaeln"))
|
169
169
|
"https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?sheet=79272d"
|
170
|
+
arun(check_token_for_moonshot("sk-iabLMgfFvuahlh5u3oM7kk84pjIciRzqCbNTDt15PVxQM78K"))
|
171
|
+
# sk-kk7ALp38EG63yPzJtmind5sEPiHipCcI2NbqW97QlWcvJfiW
|
170
172
|
|
171
173
|
# arun(check_token_for_moonshot("sk-Qnr87vtf2Q6MEfc2mVNkVZ4qaoZg3smH9527I25QgcFe7HrT"))
|
@@ -10,4 +10,25 @@
|
|
10
10
|
|
11
11
|
from meutils.pipe import *
|
12
12
|
|
13
|
+
from meutils.llm.clients import AsyncOpenAI
|
14
|
+
from meutils.llm.openai_utils import to_openai_params
|
15
|
+
from meutils.schemas.image_types import ImageRequest, ImagesResponse
|
13
16
|
|
17
|
+
|
18
|
+
class Images(object):
|
19
|
+
def __init__(
|
20
|
+
self,
|
21
|
+
base_url: Optional[str] = None,
|
22
|
+
api_key: Optional[str] = None,
|
23
|
+
http_client: Optional[httpx.AsyncClient] = None
|
24
|
+
):
|
25
|
+
self.base_url = base_url
|
26
|
+
self.api_key = api_key
|
27
|
+
|
28
|
+
self.client = AsyncOpenAI(base_url=self.base_url, api_key=self.api_key, http_client=http_client)
|
29
|
+
|
30
|
+
async def generate(self, request: ImageRequest):
|
31
|
+
data = to_openai_params(request)
|
32
|
+
response = await self.client.images.generate(**data) # todo: 兼容 response_format="b64_json"
|
33
|
+
|
34
|
+
return response
|
meutils/schemas/image_types.py
CHANGED
@@ -54,7 +54,7 @@ class ImagesResponse(_ImagesResponse):
|
|
54
54
|
|
55
55
|
def __init__(self, /, **data: Any):
|
56
56
|
super().__init__(**data)
|
57
|
-
if self.data
|
57
|
+
if not self.data and self.image is not None:
|
58
58
|
if isinstance(self.image, str):
|
59
59
|
self.image = [self.image]
|
60
60
|
|
@@ -78,7 +78,7 @@ class ImageRequest(BaseModel): # openai
|
|
78
78
|
style: Union[str, Literal["vivid", "natural"]] = None
|
79
79
|
size: str = '1024x1024' # 测试默认值 Optional[Literal["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"]]
|
80
80
|
|
81
|
-
response_format: Optional[Literal["url", "b64_json"]] = "url"
|
81
|
+
response_format: Optional[Literal["oss_url", "url", "b64_json"]] = "url"
|
82
82
|
|
83
83
|
seed: Optional[int] = 21
|
84
84
|
|
meutils/schemas/oneapi/common.py
CHANGED
@@ -96,7 +96,9 @@ MODEL_PRICE = {
|
|
96
96
|
"api-images-cogview-3": 0.01,
|
97
97
|
"api-images-stable-diffusion": 0.01,
|
98
98
|
|
99
|
+
"api-images-recraftv3": 0.1,
|
99
100
|
"api-images-seededit": 0.1,
|
101
|
+
|
100
102
|
"seededit": 0.1,
|
101
103
|
"chat-seededit": 0.1,
|
102
104
|
|
@@ -397,23 +399,29 @@ MODEL_RATIO = {
|
|
397
399
|
"kimi": 5,
|
398
400
|
"kimi-128k": 5,
|
399
401
|
|
400
|
-
# 智谱
|
401
|
-
'glm-4-9b-chat': 0.
|
402
|
-
"glm-3-turbo": 0.
|
403
|
-
"glm-4-flash": 0.
|
404
|
-
|
402
|
+
# 智谱 https://www.bigmodel.cn/pricing
|
403
|
+
'glm-4-9b-chat': 0.1,
|
404
|
+
"glm-3-turbo": 0.1,
|
405
|
+
"glm-4-flash": 0.1, # "glm-z1-flash": "glm-z1-flash==THUDM/GLM-4-9B-0414"
|
406
|
+
|
407
|
+
"glm-4-air": 0.25, # THUDM/GLM-4-32B-0414
|
408
|
+
"glm-4-airx": 0.05,
|
405
409
|
|
406
410
|
"glm-4": 2.5,
|
407
411
|
"glm-4-0520": 2.5,
|
408
|
-
"glm-4-
|
412
|
+
"glm-4-plus": 2.5,
|
413
|
+
|
414
|
+
"glm-4v-flash": 0.1,
|
409
415
|
"glm-4v": 2.5,
|
410
416
|
"glm-4v-plus": 2,
|
411
|
-
"glm-4v-flash": 0.1,
|
412
|
-
"glm-4-plus": 25,
|
413
417
|
|
414
418
|
"glm-zero": 5,
|
415
419
|
"glm-zero-preview": 5,
|
416
420
|
|
421
|
+
"glm-z1-flash": 0.1, # "glm-z1-flash": "glm-z1-flash==THUDM/GLM-Z1-9B-0414"
|
422
|
+
"glm-z1-air": 0.25, # "glm-z1-air": "glm-z1-air==THUDM/GLM-Z1-32B-0414"
|
423
|
+
"glm-z1-airx": 2.5, # "glm-z1-airx": "glm-z1-airx==THUDM/GLM-Z1-Rumination-32B-0414"
|
424
|
+
|
417
425
|
# 月之暗面 https://platform.moonshot.cn/docs/price/chat#%E4%BA%A7%E5%93%81%E5%AE%9A%E4%BB%B7
|
418
426
|
"kimi-latest-8k ": 1,
|
419
427
|
"kimi-latest-32k": 2.5,
|
@@ -543,6 +551,7 @@ MODEL_RATIO = {
|
|
543
551
|
'deepseek-r1-8k': 1,
|
544
552
|
'deepseek-reasoner': 2,
|
545
553
|
'deepseek-reasoner-8k': 1,
|
554
|
+
"deepseek-r1-250120": 2,
|
546
555
|
|
547
556
|
"deepseek-search": 1,
|
548
557
|
'deepseek-r1-search': 2,
|
@@ -603,6 +612,11 @@ MODEL_RATIO = {
|
|
603
612
|
"doubao-vision-lite-32k": 0.75,
|
604
613
|
"doubao-vision-pro-32k": 1.5,
|
605
614
|
|
615
|
+
"doubao-1-5-thinking-pro": 2,
|
616
|
+
"doubao-1-5-thinking-pro-250415": 2,
|
617
|
+
"doubao-1-5-thinking-pro-vision": 2,
|
618
|
+
"doubao-1-5-thinking-pro-vision-250415": 2,
|
619
|
+
|
606
620
|
# 商汤 https://platform.sensenova.cn/pricing
|
607
621
|
# https://platform.sensenova.cn/doc?path=/pricingdoc/pricing.md
|
608
622
|
"SenseChat-Turbo": 1 / 5, # 特价
|
@@ -698,16 +712,18 @@ MODEL_RATIO = {
|
|
698
712
|
"gemini-2.0-flash-001": 0.0625,
|
699
713
|
"gemini-2.0-flash-lite-preview-02-05": 0.0625,
|
700
714
|
"gemini-2.0-flash-exp": 0.0625,
|
701
|
-
|
702
|
-
"gemini-2.0-pro": 1.25,
|
703
|
-
"gemini-2.0-pro-exp-02-05": 1.25,
|
704
|
-
"gemini-2.5-pro-exp-03-25": 1.5,
|
705
|
-
"gemini-2.5-pro-preview-03-25": 0.625,
|
706
|
-
|
707
715
|
"gemini-2.0-flash-thinking-exp": 1,
|
708
716
|
"gemini-2.0-flash-thinking-exp-1219": 1,
|
709
717
|
"gemini-2.0-flash-thinking-exp-01-21": 1,
|
710
718
|
|
719
|
+
"gemini-2.5-flash-preview-04-17": 0.15,
|
720
|
+
|
721
|
+
"gemini-2.0-pro": 0.625,
|
722
|
+
"gemini-2.0-pro-exp": 0.625,
|
723
|
+
"gemini-2.0-pro-exp-02-05": 0.625,
|
724
|
+
"gemini-2.5-pro-exp-03-25": 0.625,
|
725
|
+
"gemini-2.5-pro-preview-03-25": 0.625,
|
726
|
+
|
711
727
|
"gemini-1.5-pro-001": 1,
|
712
728
|
"gemini-1.5-pro-002": 1,
|
713
729
|
"gemini-1.5-pro-latest": 1.75,
|
@@ -774,6 +790,7 @@ MODEL_RATIO = {
|
|
774
790
|
"o1-preview": 7.5,
|
775
791
|
"o1-preview-2024-09-12": 7.5,
|
776
792
|
"o3-mini": 0.55,
|
793
|
+
"o4-mini": 0.55,
|
777
794
|
|
778
795
|
# 硅基
|
779
796
|
"llama-3.1-8b-instruct": 0.01,
|
@@ -878,6 +895,7 @@ COMPLETION_RATIO = {
|
|
878
895
|
"o1-mini-2024-09-12": 4,
|
879
896
|
"o1-preview-2024-09-12": 4,
|
880
897
|
"o3-mini": 4,
|
898
|
+
"o4-mini": 4,
|
881
899
|
|
882
900
|
"gpt-4o-realtime-preview": 4,
|
883
901
|
"gpt-4o-realtime-preview-2024-10-01": 4,
|
@@ -956,10 +974,12 @@ COMPLETION_RATIO = {
|
|
956
974
|
"gemini-2.0-flash-thinking-exp-01-21": 5,
|
957
975
|
|
958
976
|
"gemini-2.0-flash-lite-preview-02-05": 4,
|
977
|
+
"gemini-2.5-flash-preview-04-17": 4,
|
959
978
|
|
960
979
|
"gemini-2.0-pro": 5,
|
980
|
+
"gemini-2.0-pro-exp": 5,
|
961
981
|
"gemini-2.0-pro-exp-02-05": 5,
|
962
|
-
"gemini-2.5-pro-exp-03-25":
|
982
|
+
"gemini-2.5-pro-exp-03-25": 8,
|
963
983
|
"gemini-2.5-pro-preview-03-25": 8,
|
964
984
|
|
965
985
|
"gemma2-9b-it": 4,
|
@@ -1034,6 +1054,11 @@ COMPLETION_RATIO = {
|
|
1034
1054
|
"doubao-1-5-pro-256k": 1.8,
|
1035
1055
|
"doubao-1-5-pro-256k-250115": 1.8,
|
1036
1056
|
|
1057
|
+
"doubao-1-5-thinking-pro": 4,
|
1058
|
+
"doubao-1-5-thinking-pro-250415": 4,
|
1059
|
+
"doubao-1-5-thinking-pro-vision": 4,
|
1060
|
+
"doubao-1-5-thinking-pro-vision-250415": 4,
|
1061
|
+
|
1037
1062
|
"deepseek-r1:1.5b": 4,
|
1038
1063
|
"deepseek-r1-distill-qwen-1.5b": 4,
|
1039
1064
|
"deepseek-r1:7b": 4,
|
@@ -1061,6 +1086,7 @@ COMPLETION_RATIO = {
|
|
1061
1086
|
'deepseek-r1': 4,
|
1062
1087
|
'deepseek-reasoner': 4,
|
1063
1088
|
"deepseek-reasoner-164k": 8,
|
1089
|
+
"deepseek-r1-250120": 4,
|
1064
1090
|
|
1065
1091
|
"deepseek-chat:function": 4,
|
1066
1092
|
|
@@ -1294,3 +1320,4 @@ if __name__ == '__main__':
|
|
1294
1320
|
# arun(channel.edit_channel(MODEL_PRICE))
|
1295
1321
|
|
1296
1322
|
print(bjson({k: v * 6 for k, v in MODEL_RATIO.items() if k.startswith('claude')}))
|
1323
|
+
print([k for k in MODEL_RATIO if k.startswith('gpt-4.1')] | xjoin(","))
|
File without changes
|
File without changes
|
{MeUtils-2025.4.15.13.18.47.dist-info → MeUtils-2025.4.18.13.49.52.dist-info}/entry_points.txt
RENAMED
File without changes
|
File without changes
|