MeUtils 2025.2.25.19.14.31__py3-none-any.whl → 2025.3.1.11.32.36__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.2.25.19.14.31.dist-info → MeUtils-2025.3.1.11.32.36.dist-info}/METADATA +262 -262
- {MeUtils-2025.2.25.19.14.31.dist-info → MeUtils-2025.3.1.11.32.36.dist-info}/RECORD +25 -24
- examples/_openaisdk/openai_files.py +6 -1
- examples/_openaisdk/openai_images.py +6 -3
- examples/_openaisdk/openai_x.py +20 -0
- examples/_openaisdk/openai_zhipu.py +0 -1
- meutils/apis/baidu/bdaitpzs.py +11 -11
- meutils/apis/fal/images.py +59 -11
- meutils/apis/images/edits.py +2 -2
- meutils/apis/images/recraft.py +2 -2
- meutils/apis/jimeng/checks.py +11 -0
- meutils/apis/jimeng/common.py +13 -11
- meutils/apis/jimeng/images.py +1 -1
- meutils/apis/oneapi/user.py +1 -1
- meutils/apis/vidu/vidu_video.py +2 -2
- meutils/data/VERSION +1 -1
- meutils/llm/check_utils.py +1 -1
- meutils/llm/completions/qwenllm.py +50 -7
- meutils/llm/completions/yuanbao.py +26 -28
- meutils/schemas/oneapi/common.py +16 -20
- meutils/schemas/yuanbao_types.py +4 -1
- {MeUtils-2025.2.25.19.14.31.dist-info → MeUtils-2025.3.1.11.32.36.dist-info}/LICENSE +0 -0
- {MeUtils-2025.2.25.19.14.31.dist-info → MeUtils-2025.3.1.11.32.36.dist-info}/WHEEL +0 -0
- {MeUtils-2025.2.25.19.14.31.dist-info → MeUtils-2025.3.1.11.32.36.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.2.25.19.14.31.dist-info → MeUtils-2025.3.1.11.32.36.dist-info}/top_level.txt +0 -0
@@ -17,8 +17,10 @@ AttributeError: 'str' object has no attribute 'choices'
|
|
17
17
|
from openai import AsyncOpenAI
|
18
18
|
|
19
19
|
from meutils.pipe import *
|
20
|
-
from meutils.
|
20
|
+
from meutils.io.files_utils import to_bytes
|
21
|
+
from meutils.decorators.retry import retrying
|
21
22
|
|
23
|
+
from meutils.llm.clients import qwen_client
|
22
24
|
from meutils.llm.openai_utils import to_openai_params
|
23
25
|
|
24
26
|
from meutils.config_utils.lark_utils import get_next_token_for_polling
|
@@ -33,6 +35,14 @@ from fake_useragent import UserAgent
|
|
33
35
|
ua = UserAgent()
|
34
36
|
|
35
37
|
|
38
|
+
@retrying()
|
39
|
+
async def to_file(file, mime_type: str = "application/octet-stream"):
|
40
|
+
file_bytes = await to_bytes(file)
|
41
|
+
file = ("filename", file_bytes, mime_type)
|
42
|
+
file_object = await qwen_client.files.create(file=file, purpose="file-extract")
|
43
|
+
return file_object
|
44
|
+
|
45
|
+
|
36
46
|
async def create(request: ChatCompletionRequest, token: Optional[str] = None): # ChatCompletionRequest 重构
|
37
47
|
token = token or await get_next_token_for_polling(feishu_url=FEISHU_URL)
|
38
48
|
|
@@ -44,18 +54,28 @@ async def create(request: ChatCompletionRequest, token: Optional[str] = None):
|
|
44
54
|
|
45
55
|
# qwen结构
|
46
56
|
if any(i in request.model.lower() for i in ("search",)):
|
47
|
-
request.model = "qwen-
|
57
|
+
request.model = "qwen-max-latest"
|
48
58
|
request.messages[-1]['chat_type'] = "search"
|
49
59
|
|
50
60
|
if any(i in request.model.lower() for i in ("qwq", "think")):
|
51
|
-
request.model = "qwen-
|
61
|
+
request.model = "qwen-max-latest"
|
52
62
|
request.messages[-1]['feature_config'] = {"thinking_enabled": True}
|
53
63
|
|
54
64
|
# 多模态: todo
|
55
|
-
|
65
|
+
if any(i in request.model.lower() for i in ("-vl", "qvq")):
|
66
|
+
# await to_file
|
67
|
+
last_message = request.messages[-1]
|
68
|
+
if isinstance(last_message.get("content"), list):
|
69
|
+
for content in last_message.get("content"):
|
70
|
+
if content.get("type") == 'file':
|
71
|
+
pass
|
56
72
|
|
57
|
-
|
73
|
+
pass
|
58
74
|
|
75
|
+
elif request.model.lower().endswith("-1m"):
|
76
|
+
pass
|
77
|
+
|
78
|
+
data = to_openai_params(request)
|
59
79
|
if request.stream:
|
60
80
|
_chunk = ""
|
61
81
|
async for chunk in await client.chat.completions.create(**data):
|
@@ -86,7 +106,9 @@ if __name__ == '__main__':
|
|
86
106
|
request = ChatCompletionRequest(
|
87
107
|
# model="qwen-turbo-2024-11-01",
|
88
108
|
# model="qwen-max-latest",
|
89
|
-
model="qwen-max-latest-search",
|
109
|
+
# model="qwen-max-latest-search",
|
110
|
+
# model="qwq-max",
|
111
|
+
model="qwen2.5-vl-72b-instruct",
|
90
112
|
|
91
113
|
# model="qwen-plus-latest",
|
92
114
|
|
@@ -94,6 +116,7 @@ if __name__ == '__main__':
|
|
94
116
|
{
|
95
117
|
'role': 'user',
|
96
118
|
# 'content': '今天南京天气',
|
119
|
+
# 'content': "9.8 9.11哪个大",
|
97
120
|
# 'content': '总结下',
|
98
121
|
|
99
122
|
# "chat_type": "search",
|
@@ -113,10 +136,30 @@ if __name__ == '__main__':
|
|
113
136
|
}
|
114
137
|
]
|
115
138
|
|
139
|
+
# "content": [
|
140
|
+
# {
|
141
|
+
# "type": "text",
|
142
|
+
# "text": "总结下",
|
143
|
+
# # "chat_type": "t2t"
|
144
|
+
#
|
145
|
+
# },
|
146
|
+
# {
|
147
|
+
# "type": "image",
|
148
|
+
# "image": "703dabac-b0d9-4357-8a85-75b9456df1dd"
|
149
|
+
# },
|
150
|
+
# {
|
151
|
+
# "type": "image",
|
152
|
+
# "image": "https://oss.ffire.cc/files/kling_watermark.png"
|
153
|
+
#
|
154
|
+
# }
|
155
|
+
# ]
|
156
|
+
|
116
157
|
},
|
117
158
|
|
118
159
|
],
|
119
160
|
stream=True,
|
120
161
|
|
121
162
|
)
|
122
|
-
arun(create(request))
|
163
|
+
# arun(create(request))
|
164
|
+
|
165
|
+
arun(to_file("/Users/betterme/PycharmProjects/AI/MeUtils/meutils/llm/completions/yuanbao.py"))
|
@@ -43,7 +43,6 @@ class Completions(object):
|
|
43
43
|
self,
|
44
44
|
request: Optional[ChatCompletionRequest] = None,
|
45
45
|
image_request: Optional[HunyuanImageRequest] = None,
|
46
|
-
enable_search: bool = False,
|
47
46
|
token: Optional[str] = None
|
48
47
|
):
|
49
48
|
token = token or await get_next_token_for_polling(FEISHU_URL, check_token=check_token)
|
@@ -54,7 +53,7 @@ class Completions(object):
|
|
54
53
|
|
55
54
|
payload = {
|
56
55
|
"model": "gpt_175B_0404",
|
57
|
-
"chatModelId":
|
56
|
+
"chatModelId": request.model,
|
58
57
|
"version": "v2",
|
59
58
|
"supportHint": 2, # 1
|
60
59
|
|
@@ -78,6 +77,11 @@ class Completions(object):
|
|
78
77
|
},
|
79
78
|
|
80
79
|
}
|
80
|
+
if "search" in request.model:
|
81
|
+
# deep_seek deep_seek_v3 hunyuan_t1 hunyuan_gpt_175B_0404
|
82
|
+
payload['chatModelId'] = request.model.replace('-search', '')
|
83
|
+
payload['supportFunctions'] = ["supportInternetSearch"]
|
84
|
+
|
81
85
|
if image_request:
|
82
86
|
payload["displayImageIntentionLabels"] = [
|
83
87
|
{"type": "resolution", "disPlayValue": "超清", "startIndex": 0, "endIndex": 1}
|
@@ -96,11 +100,6 @@ class Completions(object):
|
|
96
100
|
}
|
97
101
|
)
|
98
102
|
|
99
|
-
if enable_search:
|
100
|
-
payload['supportFunctions'] = [
|
101
|
-
"supportInternetSearch"
|
102
|
-
]
|
103
|
-
|
104
103
|
headers = {
|
105
104
|
'cookie': token
|
106
105
|
}
|
@@ -119,7 +118,6 @@ class Completions(object):
|
|
119
118
|
yield sse.image
|
120
119
|
|
121
120
|
if request:
|
122
|
-
|
123
121
|
yield sse.content
|
124
122
|
|
125
123
|
def generate_id(self, random: bool = True):
|
@@ -148,26 +146,26 @@ async def check_token(token):
|
|
148
146
|
|
149
147
|
|
150
148
|
if __name__ == '__main__':
|
151
|
-
# chatid = generate_id()
|
152
|
-
# print(chatid)
|
153
|
-
# print(delete_conv(chatid))
|
154
|
-
# payload = {
|
155
|
-
# # "model": "gpt_175B_0404",
|
156
|
-
# # "prompt": "1+1",
|
157
|
-
# "prompt": "错了",
|
158
|
-
#
|
159
|
-
# # "plugin": "Adaptive",
|
160
|
-
# # "displayPrompt": "1+1",
|
161
|
-
# # "displayPromptType": 1,
|
162
|
-
# # "options": {},
|
163
|
-
# # "multimedia": [],
|
164
|
-
# # "agentId": "naQivTmsDa",
|
165
|
-
# # "version": "v2"
|
166
|
-
# }
|
167
|
-
# chat(payload)
|
168
|
-
|
169
|
-
# async2sync_generator(Completions(api_key).achat('画条狗')) | xprint
|
170
|
-
# request = HunyuanImageRequest(prompt='画条狗', size='16:9')
|
149
|
+
# chatid = generate_id()
|
150
|
+
# print(chatid)
|
151
|
+
# print(delete_conv(chatid))
|
152
|
+
# payload = {
|
153
|
+
# # "model": "gpt_175B_0404",
|
154
|
+
# # "prompt": "1+1",
|
155
|
+
# "prompt": "错了",
|
156
|
+
#
|
157
|
+
# # "plugin": "Adaptive",
|
158
|
+
# # "displayPrompt": "1+1",
|
159
|
+
# # "displayPromptType": 1,
|
160
|
+
# # "options": {},
|
161
|
+
# # "multimedia": [],
|
162
|
+
# # "agentId": "naQivTmsDa",
|
163
|
+
# # "version": "v2"
|
164
|
+
# }
|
165
|
+
# chat(payload)
|
166
|
+
|
167
|
+
# async2sync_generator(Completions(api_key).achat('画条狗')) | xprint
|
168
|
+
# request = HunyuanImageRequest(prompt='画条狗', size='16:9')
|
171
169
|
|
172
170
|
arun(Completions().create(
|
173
171
|
ChatCompletionRequest(messages=[{'role': 'user', 'content': '南京天气如何'}]),
|
meutils/schemas/oneapi/common.py
CHANGED
@@ -81,19 +81,6 @@ MODEL_PRICE = {
|
|
81
81
|
"api-images-cogview-3": 0.01,
|
82
82
|
"api-images-stable-diffusion": 0.01,
|
83
83
|
|
84
|
-
"api-images-flux1.0-turbo": 0.02,
|
85
|
-
"api-images-flux-schnell": 0.01,
|
86
|
-
"api-images-flux1.0-schnell": 0.01,
|
87
|
-
"api-images-flux1.0-dev": 0.05,
|
88
|
-
"api-images-flux.1-dev": 0.05,
|
89
|
-
|
90
|
-
"api-images-flux-pro-max": 0.1,
|
91
|
-
"api-images-flux1.0-pro": 0.1,
|
92
|
-
"api-images-flux.1-pro": 0.1,
|
93
|
-
"api-images-flux1.1-pro": 0.1,
|
94
|
-
"api-images-flux.1.1-pro": 0.1,
|
95
|
-
"api-images-recraftv3": 0.03,
|
96
|
-
|
97
84
|
"api-images-seededit": 0.1,
|
98
85
|
"seededit": 0.1,
|
99
86
|
"chat-seededit": 0.1,
|
@@ -102,9 +89,14 @@ MODEL_PRICE = {
|
|
102
89
|
|
103
90
|
# 图片 音频 视频
|
104
91
|
"recraftv3": 0.1, # 官方的
|
92
|
+
"recraft-v3": 0.1, # d3
|
105
93
|
"recraft-api": 0.1,
|
106
94
|
"chat-recraftv3": 0.1,
|
107
95
|
|
96
|
+
"flux-pro-1.1-ultra": 0.2,
|
97
|
+
"ideogram-ai/ideogram-v2": 0.2,
|
98
|
+
"ideogram-ai/ideogram-v2-turbo": 0.1,
|
99
|
+
|
108
100
|
"api-asr": 0.01,
|
109
101
|
"api-stt": 0.01,
|
110
102
|
"api-tts": 0.01,
|
@@ -112,8 +104,6 @@ MODEL_PRICE = {
|
|
112
104
|
"kolors": 0.02,
|
113
105
|
"kling": 0.02,
|
114
106
|
|
115
|
-
"ideogram": 0.3,
|
116
|
-
|
117
107
|
"api-hunyuan-video": 0.1,
|
118
108
|
|
119
109
|
"deepseek-ai/Janus-Pro-7B": 0.01,
|
@@ -219,11 +209,14 @@ MODEL_PRICE = {
|
|
219
209
|
"api-translator": 0.0001,
|
220
210
|
"api-voice-clone": 0.01,
|
221
211
|
|
212
|
+
# suno
|
222
213
|
"suno_music": 0.3,
|
223
214
|
"suno_lyrics": 0.01,
|
224
215
|
"suno_uploads": 0.01,
|
225
216
|
"suno_upload": 0.01,
|
226
217
|
"suno_concat": 0.01,
|
218
|
+
"chirp-v3-5": 0.5,
|
219
|
+
"chat-suno": 0.5,
|
227
220
|
|
228
221
|
# all
|
229
222
|
"o1-plus": 0.2,
|
@@ -638,11 +631,11 @@ MODEL_RATIO = {
|
|
638
631
|
"gemini-2.0-flash": 0.0625,
|
639
632
|
"gemini-2.0-flash-001": 0.0625,
|
640
633
|
"gemini-2.0-flash-lite-preview-02-05": 0.0625,
|
634
|
+
"gemini-2.0-flash-exp": 0.0625,
|
641
635
|
|
642
636
|
"gemini-2.0-pro": 1.25,
|
643
637
|
"gemini-2.0-pro-exp-02-05": 1.25,
|
644
638
|
|
645
|
-
"gemini-2.0-flash-exp": 0.5,
|
646
639
|
"gemini-2.0-flash-thinking-exp": 1,
|
647
640
|
"gemini-2.0-flash-thinking-exp-1219": 1,
|
648
641
|
"gemini-2.0-flash-thinking-exp-01-21": 1,
|
@@ -689,6 +682,7 @@ MODEL_RATIO = {
|
|
689
682
|
"gpt-4o-mini-2024-07-18": 0.075,
|
690
683
|
"gpt-4o-2024-08-06": 1.25,
|
691
684
|
"gpt-4o-2024-11-20": 1.25,
|
685
|
+
"gpt-4.5-preview-2025-02-27": 37.5,
|
692
686
|
|
693
687
|
"o1": 7.5,
|
694
688
|
"o1-2024-12-17": 7.5,
|
@@ -716,14 +710,12 @@ MODEL_RATIO = {
|
|
716
710
|
"llama3-8b-8192": 0.01,
|
717
711
|
"llama3-70b-8192": 0.01,
|
718
712
|
"mixtral-8x7b-32768": 0.01,
|
719
|
-
"gemma-7b-it": 0.01,
|
720
713
|
"llama-3.1-8b-instant": 0.01,
|
721
714
|
"llama-3.1-70b-versatile": 3,
|
722
715
|
|
723
716
|
# sili
|
724
|
-
"gemma2-9b-it": 0.
|
725
|
-
"gemma2-27b-it": 0.
|
726
|
-
"google/gemma-2-27b-it": 0.09,
|
717
|
+
"gemma2-9b-it": 0.1,
|
718
|
+
"gemma2-27b-it": 0.5,
|
727
719
|
|
728
720
|
"internlm2_5-7b-chat": 0.01,
|
729
721
|
'internlm2_5-20b-chat': 0.5,
|
@@ -774,6 +766,7 @@ COMPLETION_RATIO = {
|
|
774
766
|
"gpt-4-all": 4,
|
775
767
|
"gpt-4-gizmo-*": 4,
|
776
768
|
"gpt-4o-all": 4,
|
769
|
+
"gpt-4.5-preview-2025-02-27":2,
|
777
770
|
|
778
771
|
"o1-mini": 4,
|
779
772
|
"o1-preview": 4,
|
@@ -844,6 +837,9 @@ COMPLETION_RATIO = {
|
|
844
837
|
"gemini-2.0-pro": 4,
|
845
838
|
"gemini-2.0-pro-exp-02-05": 4,
|
846
839
|
|
840
|
+
"gemma2-9b-it": 4,
|
841
|
+
"gemma2-27b-it": 4,
|
842
|
+
|
847
843
|
"hunyuan-a52b-instruct": 5,
|
848
844
|
"qwen2.5-coder-32b-instruct": 3,
|
849
845
|
|
meutils/schemas/yuanbao_types.py
CHANGED
@@ -253,9 +253,12 @@ class SSEData(BaseModel):
|
|
253
253
|
# df['title'] = "[" + df['title'] + "](" + df['url'] + ")"
|
254
254
|
# df['image'] = ""
|
255
255
|
|
256
|
-
elif '{"type":"think"' in chunk:
|
256
|
+
elif '{"type":"think"' in chunk: # 思考中...
|
257
257
|
content = self.reasoning_content = json.loads(chunk).get("content", "")
|
258
258
|
|
259
|
+
elif '{"type":"searchGuid"' in chunk: # 思考中...
|
260
|
+
content = self.reasoning_content = json.loads(chunk).get("docs", "")
|
261
|
+
|
259
262
|
else:
|
260
263
|
content = ""
|
261
264
|
# chunk.strip() or logger.debug(chunk) # debug
|
File without changes
|
File without changes
|
{MeUtils-2025.2.25.19.14.31.dist-info → MeUtils-2025.3.1.11.32.36.dist-info}/entry_points.txt
RENAMED
File without changes
|
File without changes
|