MeUtils 2025.8.7.20.31.52__py3-none-any.whl → 2025.8.11.16.30.21__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.
@@ -18,9 +18,9 @@ client = OpenAI(
18
18
  # api_key=os.getenv("OPENAI_API_KEY_GUOCHAN"),
19
19
  # api_key="sk-acnBrFLJo3E732FfHN0kf0tcHyjfAiCEomyjKr56AUtPIWso",
20
20
  # api_key="31c64288-e87d-4020-9d24-0ae6f4abaa7a",
21
- # base_url="https://ark.cn-beijing.volces.com/api/v3", # /chat/completions
22
- base_url="https://api.ffire.cc/v1",
23
- api_key="sk-5lkoeVerPmupyCnCLi1PNpuhbZ31NreEfUMwoZbdyrPPDqcD"
21
+ base_url="https://ark.cn-beijing.volces.com/api/v3", # /chat/completions
22
+ # base_url="https://api.ffire.cc/v1",
23
+ api_key="80f33bac-41ac-4ea8-91ff-ef4e61720b23"
24
24
 
25
25
  # api_key=os.getenv("OPENAI_API_KEY") +'-3587'
26
26
 
@@ -29,9 +29,9 @@ client = OpenAI(
29
29
  try:
30
30
  completion = client.chat.completions.create(
31
31
  # model="ep-20241225184145-7nf5n",
32
- # model="deepseek-r1-250528",
32
+ model="deepseek-r1-250528",
33
33
  # model="doubao-1-5-pro-32k-250115",
34
- model="doubao-1-5-thinking-vision-pro-250428",
34
+ # model="doubao-1-5-thinking-vision-pro-250428",
35
35
 
36
36
  # model="doubao-lite-32k-character",
37
37
  # model="doubao-pro-32k-character",
@@ -55,6 +55,7 @@ data = {
55
55
  # 'extra_body': {'guidance_scale': 4.5, 'num_inference_steps': 25, 'seed': None, 'negative_prompt': None}
56
56
  }
57
57
 
58
+
58
59
  from openai import OpenAI
59
60
 
60
61
  # model = "stable-diffusion-3"
@@ -150,6 +151,9 @@ with timer('image'):
150
151
 
151
152
  # base_url="https://oneapi.chatfire.cn/v1",
152
153
 
154
+ base_url=os.getenv("MODELSCOPE_BASE_URL"),
155
+ api_key=os.getenv("MODELSCOPE_API_KEY")
156
+
153
157
  )
154
158
 
155
159
  # print(client.models.list())
@@ -199,6 +203,7 @@ with timer('image'):
199
203
  # prompt = "一个小女孩举着横幅,上面写着“新年快乐”"
200
204
 
201
205
  model = "doubao-seedream-3-0-t2i-250415"
206
+ model = "black-forest-labs/FLUX.1-Krea-dev"
202
207
 
203
208
  response = client.images.generate(
204
209
  model=model,
@@ -16,7 +16,7 @@ from meutils.llm.clients import OpenAI
16
16
 
17
17
  client = OpenAI(
18
18
  # api_key=os.getenv("SILICONFLOW_API_KEY"),
19
- api_key="sk-fjusrufaajpmvefmxotsvbgvwumqfujunhinzlhapdhopduk",
19
+ api_key="sk-ugfakteneejitibfzpwttxplymratxacudosclwlvzopexwq",
20
20
  base_url="https://api.siliconflow.cn/v1",
21
21
  # http_client=httpx.Client(
22
22
  # proxy="http://110.42.51.201:38443",
@@ -65,7 +65,7 @@ def request_many():
65
65
  # model='alibaba/Qwen1.5-110B-Chat',
66
66
  model=model,
67
67
  messages=[
68
- {'role': 'user', 'content': "抛砖引玉是什么意思呀"*2000}
68
+ {'role': 'user', 'content': "抛砖引玉是什么意思呀"*1}
69
69
  ],
70
70
  # messages=messages,
71
71
  stream=False,
@@ -44,6 +44,8 @@ if __name__ == '__main__':
44
44
  "prompt_wav_url": "https://s3.ffire.cc/files/jay_prompt.wav",
45
45
  "response_format": "url"
46
46
  }
47
+
48
+
47
49
  print(TTSRequest(**data))
48
50
 
49
51
  request = TTSRequest(
@@ -53,6 +55,5 @@ if __name__ == '__main__':
53
55
  response_format="b64_json"
54
56
  )
55
57
 
56
-
57
58
  # arun(text_to_speech(request))
58
59
  # print(MODELS.values())
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # @Project : AI. @by PyCharm
4
+ # @File : images
5
+ # @Time : 2025/8/11 16:04
6
+ # @Author : betterme
7
+ # @WeChat : meutils
8
+ # @Software : PyCharm
9
+ # @Description :
10
+
11
+
12
+ from meutils.pipe import *
13
+ from meutils.db.redis_db import redis_aclient
14
+ from meutils.io.files_utils import to_bytes
15
+
16
+ from meutils.apis.utils import make_request_httpx
17
+ from meutils.llm.clients import AsyncClient
18
+ from meutils.llm.openai_utils import to_openai_params
19
+
20
+ from meutils.schemas.gitee_types import FEISHU_URL, BASE_URL
21
+ from meutils.schemas.image_types import ImageRequest, ImagesResponse
22
+
23
+ from meutils.config_utils.lark_utils import get_next_token_for_polling
24
+
25
+
26
+ async def generate(request: ImageRequest, api_key: Optional[str] = None):
27
+ api_key = api_key or await get_next_token_for_polling(FEISHU_URL)
28
+
29
+ client = AsyncClient(base_url=BASE_URL, api_key=api_key)
30
+
31
+ data = {**request.model_dump(exclude_none=True, exclude={"extra_fields"}), **(request.extra_fields or {})}
32
+ data = to_openai_params(ImageRequest(**(data)))
33
+ logger.debug(data)
34
+ response = await client.images.generate(**data)
35
+ return response
36
+
37
+
38
+ if __name__ == '__main__':
39
+ data = {
40
+ "prompt": "A robot sitting on open grassland, painting on a canvas.",
41
+ "model": "FLUX_1-Krea-dev",
42
+ "size": "1536x1536",
43
+ "num_inference_steps": 28,
44
+ "guidance_scale": 4.5,
45
+ "seed": 42
46
+ }
47
+ data = {
48
+ "prompt": "一幅精致细腻的工笔画,画面中心是一株蓬勃生长的红色牡丹,花朵繁茂,既有盛开的硕大花瓣,也有含苞待放的花蕾,层次丰富,色彩艳丽而不失典雅。牡丹枝叶舒展,叶片浓绿饱满,脉络清晰可见,与红花相映成趣。一只蓝紫色蝴蝶仿佛被画中花朵吸引,停驻在画面中央的一朵盛开牡丹上,流连忘返,蝶翼轻展,细节逼真,仿佛随时会随风飞舞。整幅画作笔触工整严谨,色彩浓郁鲜明,展现出中国传统工笔画的精妙与神韵,画面充满生机与灵动之感。",
49
+ "model": "Qwen-Image",
50
+ "size": "1024x1024",
51
+ "num_inference_steps": 30,
52
+ "cfg_scale": 4
53
+ }
54
+ arun(generate(ImageRequest(**data)))
@@ -212,12 +212,14 @@ async def get_request_policy(token):
212
212
  # 'serverTime': '2024-11-08T10:38:31Z'}
213
213
 
214
214
 
215
- @retrying(predicate=lambda r: r.base_resp.status_code in {1000061, 1500009}) # 限流
215
+ # @retrying(predicate=lambda r: r.base_resp.status_code in {1000061, 1500009}) # 限流
216
216
  async def create_task(request: VideoRequest, token: Optional[str] = None):
217
217
  # if request.model.lower() == "minimax-hailuo-02": # 走派欧
218
218
  if 1: # 全部走派欧
219
219
  request.model = "minimax-hailuo-02"
220
- return await ppio_videos.create_task(request)
220
+ _ = await ppio_videos.create_task(request)
221
+ logger.debug(_)
222
+ return _
221
223
 
222
224
  refresh_token = token or await get_next_token_for_polling(FEISHU_URL, from_redis=True, check_token=check_token)
223
225
  # refresh_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDA0NzA4NzgsInVzZXIiOnsiaWQiOiIzMjg2MDg4ODkzNTA4MTU3NDQiLCJuYW1lIjoiUm9idXN0IEdlcnRydWRlIiwiYXZhdGFyIjoiaHR0cHM6Ly9jZG4uaGFpbHVvYWkudmlkZW8vbW9zcy9wcm9kLzIwMjQtMTItMjgtMTYvdXNlci91c2VyX2F2YXRhci8xNzM1Mzc1OTI0OTkyMTcxMDY3LWF2YXRhcl8zMjg2MDg4ODkzNTA4MTU3NDQiLCJkZXZpY2VJRCI6IjMwMjgzMzc1OTUxMjc2NDQxNyIsImlzQW5vbnltb3VzIjpmYWxzZX19.dLNBSHjqnKutGl3ralS2g8A-RodHjOdos11vdpbkPwc"
@@ -161,15 +161,6 @@ async def make_request_for_baidu(payload, token: Optional[str] = None, response_
161
161
 
162
162
 
163
163
  async def edit_image(request: ImageProcess):
164
- if request.model == "clarity":
165
- # payload['type'] = "3"
166
- #
167
- # return await make_request_for_baidu(payload, response_format=request.response_format)
168
- # 临时替换
169
- from meutils.apis.baidu.image_enhance import image_enhance
170
- data = await image_enhance(request.image)
171
- return ImagesResponse(data=[{"url": data.get("image")}])
172
-
173
164
  image, mask = await asyncio.gather(to_base64(request.image), to_base64(request.mask))
174
165
 
175
166
  # baidu_url = "https://chatfire.hkg.bcebos.com/zjz.jpg"
@@ -191,7 +182,16 @@ async def edit_image(request: ImageProcess):
191
182
 
192
183
  }
193
184
 
194
- if request.model == "remove-watermark":
185
+ if request.model == "clarity":
186
+ payload['type'] = "3"
187
+
188
+ return await make_request_for_baidu(payload, response_format=request.response_format)
189
+ # 临时替换
190
+ # from meutils.apis.baidu.image_enhance import image_enhance
191
+ # data = await image_enhance(request.image)
192
+ # return ImagesResponse(data=[{"url": data.get("image")}])
193
+
194
+ elif request.model == "remove-watermark":
195
195
  if mask: ####### todo: mask 抠图
196
196
  payload['type'] = "2"
197
197
  return await make_request_for_baidu(payload, response_format=request.response_format)
@@ -236,8 +236,8 @@ if __name__ == '__main__':
236
236
  token = "web_uid=ac283ec7-4bf6-40c9-a0ce-5a2e0cd7db06; hy_source=web; hy_user=I09MgMfFcUUyVSIg; hy_token=hevVCi/QuVjQcre5NDRMO7FuiWCZoDMIq3Zp8IwNxrPUofl4zWYazHEdeZ2S5o7q; _qimei_q36=; _qimei_h38=f2d27f50f0f23e085296d28303000006a17a09; _qimei_fingerprint=efbb885a22f7d4e5589008c28bc8e7ba; _qimei_uuid42=18c0310102d1002a082420cd40bb9717523c3c7e12; _gcl_au=1.1.915258067.1733278380; _ga_RPMZTEBERQ=GS1.1.1733722091.3.1.1733722108.0.0.0; _ga=GA1.2.981511920.1725261466; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22100000458739%22%2C%22first_id%22%3A%22191b198c7b2d52-0fcca8d731cb9b8-18525637-2073600-191b198c7b31fd9%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%A4%BE%E4%BA%A4%E7%BD%91%E7%AB%99%E6%B5%81%E9%87%8F%22%2C%22%24latest_utm_medium%22%3A%22cpc%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTkxYjE5OGM3YjJkNTItMGZjY2E4ZDczMWNiOWI4LTE4NTI1NjM3LTIwNzM2MDAtMTkxYjE5OGM3YjMxZmQ5IiwiJGlkZW50aXR5X2xvZ2luX2lkIjoiMTAwMDAwNDU4NzM5In0%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%22100000458739%22%7D%2C%22%24device_id%22%3A%22191b198c7b2d52-0fcca8d731cb9b8-18525637-2073600-191b198c7b31fd9%22%7D"
237
237
 
238
238
  # url = "https://api.chatfire.cn/beta/https://s3.ffire.cc/files/jimeng.jpg"
239
- url = "https://juzhen-1318772386.cos.ap-guangzhou.myqcloud.com/mj/2025/06/07/7b347a36-8146-4d3d-a5dc-0b8dc365817d.png"
240
- # url = "https://oss.ffire.cc/files/shuiyin.jpg"
239
+ # url = "https://juzhen-1318772386.cos.ap-guangzhou.myqcloud.com/mj/2025/06/07/7b347a36-8146-4d3d-a5dc-0b8dc365817d.png"
240
+ url = "https://oss.ffire.cc/files/shuiyin.jpg"
241
241
  # url = "https://oss.ffire.cc/files/shuiyin3.jpg"
242
242
 
243
243
  # url = "https://s22-def.ap4r.com/bs2/upload-ylab-stunt-sgp/se/ai_portal_sgp_queue_mmu_txt2img_aiweb/9c520b80-efc2-4321-8f0e-f1d34d483ddd/1.png"
@@ -42,7 +42,7 @@ async def create_draft_content(request: ImageRequest, token: str):
42
42
  创建草稿内容
43
43
  """
44
44
  # 参考人物
45
- face_recognize_data = request.controls.get("face_recognize_data", {})
45
+ face_recognize_data = (request.controls or {}).get("face_recognize_data", {})
46
46
  image_uri = face_recognize_data.pop("image_uri", None)
47
47
 
48
48
  request.model = MODELS_MAP.get(request.model, MODELS_MAP["default"])
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # @Project : AI. @by PyCharm
4
+ # @File : videos
5
+ # @Time : 2025/8/8 17:32
6
+ # @Author : betterme
7
+ # @WeChat : meutils
8
+ # @Software : PyCharm
9
+ # @Description :
10
+ """
11
+
12
+ 2x08hnrb@yyu.hdernm.com----uc7jqzax----eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJHcm91cE5hbWUiOiJhYXZ5IHJ5ZGgiLCJVc2VyTmFtZSI6ImFhdnkgcnlkaCIsIkFjY291bnQiOiIiLCJTdWJqZWN0SUQiOiIxOTI0MzY5NjUwMjE3MzkwNDMyIiwiUGhvbmUiOiIiLCJHcm91cElEIjoiMTkyNDM2OTY1MDIwOTAwMTgyNCIsIlBhZ2VOYW1lIjoiIiwiTWFpbCI6IjJ4MDhobnJiQHl5dS5oZGVybm0uY29tIiwiQ3JlYXRlVGltZSI6IjIwMjUtMDUtMTkgMTY6MzY6MzMiLCJUb2tlblR5cGUiOjEsImlzcyI6Im1pbmltYXgifQ.ZQ_cSiErTQNHT37w8Ie2nIy4zLfmo0sBXbuIQd0uEU_HDyLn4WBrJ6O-CAnWldtxi9PY53YHZW6zTb33S9zDx4VcXVRO3Nxl5o2WQNYRj3KxxNtHWAGwtA-cCplmgY71m-Xe4kZtN-K25tgXVcWbdze4nev_OGdkDPHBxfhiP462P0wgQ_tqkl5BgTxgUhcskYNs6JogNQUP4c1LFoSR6vYoAYek95K199ehpBuE1jkLFa2JDzNlKlVq_e2LPZkwA7qW67Ih0yONFDEtvM5GXr9ZMjyFIhww4hIeYPGTpqwHnjY00GUzlh4F9e_gpsx-FLqxZn0Xfnhyz8YvUDidfQ
13
+
14
+ """
15
+
16
+ from meutils.pipe import *
17
+ from meutils.caches import rcache
18
+ from meutils.db.redis_db import redis_aclient
19
+
20
+ from meutils.config_utils.lark_utils import get_next_token_for_polling
21
+ from meutils.apis.utils import make_request_httpx
22
+
23
+ base_url = "https://api.minimax.io/v1"
24
+ feishu_url = "https://xchatllm.feishu.cn/sheets/Z59Js10DbhT8wdt72LachSDlnlf?sheet=oOK2uj"
25
+
26
+
27
+ @rcache(ttl=3600)
28
+ async def create_task(request: dict, api_key: Optional[str] = None):
29
+ api_key = api_key or await get_next_token_for_polling(feishu_url)
30
+
31
+ headers = {"Authorization": f"Bearer {api_key}"}
32
+ path = "/video_generation"
33
+ payload = request
34
+
35
+ response = await make_request_httpx(
36
+ base_url=base_url,
37
+ headers=headers,
38
+
39
+ path=path,
40
+ payload=payload,
41
+ )
42
+ if task_id := response.get("task_id"):
43
+ await redis_aclient.set(task_id, api_key, ex=7 * 24 * 3600)
44
+
45
+ logger.debug(response)
46
+ return response
47
+
48
+
49
+ @alru_cache(ttl=30)
50
+ async def get_task(task_id: str):
51
+ token = await redis_aclient.get(task_id) # 绑定对应的 token
52
+ api_key = token and token.decode()
53
+
54
+ headers = {"Authorization": f"Bearer {api_key}"}
55
+ path = f"/query/video_generation?task_id={task_id}"
56
+
57
+ response = await make_request_httpx(
58
+ base_url=base_url,
59
+ headers=headers,
60
+
61
+ path=path
62
+ )
63
+ if file_id := response.get("file_id"):
64
+ await redis_aclient.set(file_id, api_key, ex=7 * 24 * 3600)
65
+
66
+ return response
67
+
68
+
69
+ @alru_cache(ttl=30)
70
+ async def get_file(file_id: str):
71
+ token = await redis_aclient.get(file_id) # 绑定对应的 token
72
+ api_key = token and token.decode()
73
+
74
+ headers = {"Authorization": f"Bearer {api_key}"}
75
+ path = f"/files/retrieve?file_id={file_id}"
76
+
77
+ response = await make_request_httpx(
78
+ base_url=base_url,
79
+ headers=headers,
80
+
81
+ path=path
82
+ )
83
+ """
84
+ {'file': {'file_id': 299393334087796,
85
+ 'bytes': 0,
86
+ 'created_at': 1754647084,
87
+ 'filename': 'output.mp4',
88
+ 'purpose': 'video_generation',
89
+ 'download_url': 'https://public-cdn-video-data-algeng.oss-cn-wulanchabu.aliyuncs.com/inference_output%2Fvideo%2F2025-08-08%2F5caadc3e-b812-4df2-8153-fa463d7ebab3%2Foutput.mp4?Expires=1754679844&OSSAccessKeyId=LTAI5tAmwsjSaaZVA6cEFAUu&Signature=%2FxSqhj1bI9MY%2FlS8SNrSJWphNTI%3D',
90
+ 'backup_download_url': 'https://public-cdn-video-data-algeng-us.oss-us-east-1.aliyuncs.com/inference_output%2Fvideo%2F2025-08-08%2F5caadc3e-b812-4df2-8153-fa463d7ebab3%2Foutput.mp4?Expires=1754679844&OSSAccessKeyId=LTAI5tCpJNKCf5EkQHSuL9xg&Signature=PPvLDVrhqzt%2FXi%2BaBvZRFAr1IEI%3D'},
91
+ 'base_resp': {'status_code': 0, 'status_msg': 'success'}}
92
+
93
+ """
94
+ return response
95
+
96
+
97
+ if __name__ == '__main__':
98
+ data = {
99
+ "model": "T2V-01",
100
+ "prompt": "男子拿起一本书[上升],然后阅读[固定]。",
101
+ "duration": 6,
102
+ "resolution": "1080P"
103
+ } # 299392563388531
104
+ arun(
105
+ create_task(data)
106
+ )
107
+
108
+ arun(
109
+ get_task('299392563388531')
110
+ )
111
+
112
+ arun(
113
+ get_file('299393334087796')
114
+ )
meutils/apis/models.py CHANGED
@@ -12,7 +12,13 @@ from meutils.pipe import *
12
12
 
13
13
 
14
14
  def make_billing_model(model: str, request: dict):
15
- _model = model.removeprefix("fal-")
15
+ """
16
+
17
+ :param model: biz model
18
+ :param request:
19
+ :return:
20
+ """
21
+ _model = model.removeprefix("fal-").lower()
16
22
  if _model.startswith(("pika", "fal-pika")):
17
23
  duration = request.get("duration")
18
24
  resolution = request.get("resolution")
@@ -25,3 +31,35 @@ def make_billing_model(model: str, request: dict):
25
31
  billing_model = request.get("rendering_speed", "BALANCED").lower()
26
32
 
27
33
  return f"{model}_{billing_model}"
34
+
35
+ elif _model.startswith(("minimax")):
36
+ # MiniMax-Hailuo-02 T2V-01-Director I2V-01-Director S2V-01 I2V-01-live I2V-01 T2V-01
37
+ duration = request.get("duration", 6)
38
+ resolution = request.get("resolution", "720P")
39
+ model = request.get("model", "").lower()
40
+
41
+ if model.startswith("minimax"): # 02
42
+ resolution = request.get("resolution", "768P")
43
+
44
+ billing_model = f"""minimax-{model.removeprefix("minimax-")}_{duration}s_{resolution}"""
45
+
46
+ return billing_model
47
+
48
+
49
+ if __name__ == '__main__':
50
+ data = {
51
+ # "model": "MiniMax-Hailuo-02",
52
+ "model": "T2V-01-Director",
53
+ "prompt": "男子拿起一本书[上升],然后阅读[固定]。",
54
+ # "duration": 6,
55
+ # "resolution": "1080P"
56
+ }
57
+
58
+ data = {
59
+ "model": "T2V-01",
60
+ "prompt": "男子拿起一本书[上升],然后阅读[固定]。",
61
+ "duration": 6,
62
+ # "resolution": "1080P"
63
+ }
64
+
65
+ print(make_billing_model("minimax", data))
@@ -6,7 +6,7 @@
6
6
  # @Author : betterme
7
7
  # @WeChat : meutils
8
8
  # @Software : PyCharm
9
- # @Description :
9
+ # @Description : https://ppio.com/pricing
10
10
 
11
11
  from meutils.pipe import *
12
12
  from meutils.db.redis_db import redis_aclient
@@ -21,6 +21,7 @@ base_url = "https://api.ppinfra.com/v3"
21
21
  feishu_url = "https://xchatllm.feishu.cn/sheets/Z59Js10DbhT8wdt72LachSDlnlf?sheet=b0e241"
22
22
 
23
23
 
24
+
24
25
  async def get_valid_token(min_points=18000):
25
26
  _ = await get_next_token(feishu_url, check_token, min_points=min_points, ttl=600)
26
27
  logger.debug(_)
@@ -28,8 +29,13 @@ async def get_valid_token(min_points=18000):
28
29
 
29
30
 
30
31
  # minimax-hailuo-02-6s-768p minimax-hailuo-02-6s-768p minimax-hailuo-02-6s-1080p
32
+
31
33
  async def create_task(request: VideoRequest, api_key: Optional[str] = None):
32
- api_key = api_key or await get_valid_token() # 轮询
34
+ api_key = api_key or await get_valid_token()
35
+
36
+ api_key="sk_4Ja29OIUBVwKo5GWx-PRTsRcTyxxRjZDpYxSdPg75QU"
37
+
38
+ path = "/async/minimax-hailuo-02"
33
39
 
34
40
  payload = {
35
41
 
@@ -44,7 +50,7 @@ async def create_task(request: VideoRequest, api_key: Optional[str] = None):
44
50
  base_url=base_url,
45
51
  api_key=api_key,
46
52
 
47
- path="/async/minimax-hailuo-02",
53
+ path=path,
48
54
  payload=payload,
49
55
  )
50
56
 
@@ -148,12 +154,27 @@ if __name__ == '__main__':
148
154
  resolution="768P",
149
155
  )
150
156
  api_key = None
151
- # r = arun(create_task(request, api_key=api_key))
157
+ r = arun(create_task(request, api_key=api_key))
152
158
 
153
- # arun(get_task("d8b048d0-5c54-42ef-a691-3feab31693fe"))
159
+ # arun(get_task("d425c44f-da09-4cff-a471-f78757786046"))
154
160
 
155
161
  # print(request.model_dump_json(exclude_none=True))
156
162
 
157
163
  # arun(get_task("959d759e-da77-42f9-95c5-c29cccc6a894"))
158
164
 
159
- arun(get_valid_token())
165
+ # arun(get_valid_token())
166
+
167
+ # "0c830895-1933-4c41-a0cb-37b7387b643a"
168
+ """
169
+ curl \
170
+ -X POST https://api.ppinfra.com/v3/async/minimax-hailuo-02 \
171
+ -H "Authorization: Bearer sk_4Ja29OIUBVwKo5GWx-PRTsRcTyxxRjZDpYxSdPg75QU" \
172
+ -H "Content-Type: application/json" \
173
+ -d '{
174
+ "image_url": "https://static.ppinfra.com/docs/assets/minimax-hailuo-video-02-input-image.jpg",
175
+ "prompt": "戴着太阳镜的毛茸茸的熊猫在日出时的雪山顶上跳舞,左移运镜",
176
+ "duration": 6,
177
+ "resolution": "1080P",
178
+ "enable_prompt_expansion": true
179
+ }'
180
+ """
@@ -202,7 +202,7 @@ if __name__ == "__main__":
202
202
  prompt="无人机以极快速度穿越复杂障碍或自然奇观,带来沉浸式飞行体验",
203
203
  duration=10
204
204
  )
205
- r = arun(create_task(request))
205
+ # r = arun(create_task(request))
206
206
  # r = {'id': 'cgt-20250612172542-6nbt2'}
207
207
 
208
208
  # arun(get_task(r.get('id')))
@@ -211,7 +211,7 @@ if __name__ == "__main__":
211
211
 
212
212
  # arun(get_task("cgt-20250707160713-j8kll"))
213
213
 
214
- # arun(get_valid_token())
214
+ arun(get_valid_token())
215
215
 
216
216
  """
217
217
  {'id': 'cgt-20250613160030-2dvd7',
meutils/data/VERSION CHANGED
@@ -1 +1 @@
1
- 2025.08.07.20.31.52
1
+ 2025.08.11.16.30.21
@@ -13,6 +13,7 @@
13
13
  AttributeError: 'str' object has no attribute 'choices'
14
14
 
15
15
  """
16
+ import time
16
17
 
17
18
  from openai import AsyncOpenAI
18
19
 
@@ -31,6 +32,7 @@ from meutils.schemas.openai_types import chat_completion, chat_completion_chunk,
31
32
  FEISHU_URL = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?sheet=PP1PGr"
32
33
 
33
34
  base_url = "https://chat.qwen.ai/api"
35
+ DEFAUL_MODEL = "qwen3-235b-a22b"
34
36
 
35
37
  from fake_useragent import UserAgent
36
38
 
@@ -47,6 +49,28 @@ cna=KP9DIEqqyjUCATrw/+LjJV8F; _bl_uid=LXmp28z7dwezpmyejeXL9wh6U1Rb; cnaui=310cbd
47
49
  """.strip()
48
50
 
49
51
 
52
+ @retrying()
53
+ async def create_new_chat(api_key, cookie: Optional[str] = None):
54
+ qwen_client = AsyncOpenAI(
55
+ base_url=base_url,
56
+ api_key=api_key,
57
+ default_headers={
58
+ 'User-Agent': ua.random,
59
+ 'Cookie': cookie or COOKIE
60
+ }
61
+ )
62
+ payload = {
63
+ "title": "新建对话",
64
+ "models": [DEFAUL_MODEL],
65
+ "chat_mode": "normal",
66
+ "chat_type": "t2i",
67
+ "timestamp": time.time() * 1000 // 1
68
+ }
69
+ resp = await qwen_client.post('/v2/chats/new', body=payload, cast_to=object)
70
+ logger.debug(resp)
71
+ return resp['data']['id']
72
+
73
+
50
74
  @retrying()
51
75
  async def to_file(file, api_key, cookie: Optional[str] = None):
52
76
  qwen_client = AsyncOpenAI(
@@ -65,8 +89,6 @@ async def to_file(file, api_key, cookie: Optional[str] = None):
65
89
  logger.debug(file_object)
66
90
  return file_object
67
91
 
68
- # todo
69
- # oss
70
92
 
71
93
  async def create(request: CompletionRequest, token: Optional[str] = None, cookie: Optional[str] = None):
72
94
  cookie = cookie or COOKIE
@@ -78,25 +100,38 @@ async def create(request: CompletionRequest, token: Optional[str] = None, cookie
78
100
 
79
101
  logger.debug(token)
80
102
 
103
+ default_query = None
104
+ if 'image' in request.model:
105
+ chat_id = await create_new_chat(token, cookie)
106
+ default_query = {'chat_id': chat_id}
107
+
81
108
  client = AsyncOpenAI(
82
109
  base_url=base_url,
83
110
  api_key=token,
84
111
  default_headers={
85
112
  'User-Agent': ua.random,
86
113
  'Cookie': cookie,
87
- }
114
+ },
115
+
116
+ default_query=default_query
88
117
  )
89
118
  # qwen结构
90
119
  model = request.model.lower()
91
120
  if any(i in model for i in ("research",)): # 遇到错误 任意切换
92
- request.model = np.random.choice({""})
121
+ request.model = DEFAUL_MODEL
93
122
  request.messages[-1]['chat_type'] = "deep_research"
94
123
 
95
- # request.messages["extra"] = {
96
- # "meta": {
97
- # "subChatType": "deep_thinking"
98
- # }
99
- # }
124
+ elif any(i in model for i in ("image",)):
125
+ request.model = DEFAUL_MODEL
126
+ request.chat_id = default_query['chat_id']
127
+ request.size = "1:1"
128
+
129
+ request.messages[-1]['chat_type'] = "t2i"
130
+ request.messages[-1]['feature_config'] = {
131
+ "thinking_enabled": False,
132
+ "output_schema": "phase"
133
+ }
134
+
100
135
 
101
136
  elif any(i in model for i in ("search",)):
102
137
  request.model = "qwen-max-latest"
@@ -105,7 +140,7 @@ async def create(request: CompletionRequest, token: Optional[str] = None, cookie
105
140
  # 混合推理
106
141
  if (request.reasoning_effort
107
142
  or request.last_user_content.startswith("/think")
108
- or hasattr(request, "enable_thinking")
143
+ or request.enable_thinking
109
144
  or hasattr(request, "thinking_budget")
110
145
  ):
111
146
  feature_config = {"thinking_enabled": True, "output_schema": "phase"}
@@ -168,6 +203,8 @@ async def create(request: CompletionRequest, token: Optional[str] = None, cookie
168
203
  request.incremental_output = True # 增量输出
169
204
  data = to_openai_params(request)
170
205
 
206
+ logger.debug(data)
207
+
171
208
  # 流式转非流
172
209
  data['stream'] = True
173
210
  chunks = await client.chat.completions.create(**data)
@@ -226,7 +263,7 @@ if __name__ == '__main__':
226
263
  user_content = [
227
264
  {
228
265
  "type": "text",
229
- "text": "一句话总结"
266
+ "text": "主体文字'诸事皆顺',超粗笔画、流畅飘逸、有飞白效果的狂野奔放草书字体,鎏金质感且有熔金流动感和泼溅金箔效果,黑色带细微噪点肌理背景,英文'GOOD LUCK'浅金色或灰白色,有淡淡的道家符文点缀,书法字体海报场景,传统书法与现代设计融合风格,特写,神秘奢华充满能量,焦点清晰,对比强烈"
230
267
  },
231
268
  # {
232
269
  # "type": "image_url",
@@ -236,7 +273,15 @@ if __name__ == '__main__':
236
273
  # }
237
274
  ]
238
275
 
239
- user_content = "1+1"
276
+ user_content = "主体文字'诸事皆顺',超粗笔画、流畅飘逸、有飞白效果的狂野奔放草书字体,鎏金质感且有熔金流动感和泼溅金箔效果,黑色带细微噪点肌理背景,英文'GOOD LUCK'浅金色或灰白色,有淡淡的道家符文点缀,书法字体海报场景,传统书法与现代设计融合风格,特写,神秘奢华充满能量,焦点清晰,对比强烈"
277
+ # {
278
+ # "type": "image_url",
279
+ # "image_url": {
280
+ # "url": "https://fyb-pc-static.cdn.bcebos.com/static/asset/homepage@2x_daaf4f0f6cf971ed6d9329b30afdf438.png"
281
+ # }
282
+ # }
283
+
284
+ # user_content = "1+1"
240
285
  # user_content = "/think 1+1"
241
286
 
242
287
  # user_content = [
@@ -270,11 +315,13 @@ if __name__ == '__main__':
270
315
  # ]
271
316
 
272
317
  request = CompletionRequest(
318
+ # model="qwen3-235b-a22b",
273
319
  # model="qwen-turbo-2024-11-01",
274
320
  # model="qwen-max-latest",
275
321
  # model="qvq-max-2025-03-25",
276
322
  # model="qvq-72b-preview-0310",
277
- model="qwen2.5-omni-7b",
323
+ # model="qwen2.5-omni-7b",
324
+ model="qwen-image",
278
325
  # model="qwen-plus",
279
326
 
280
327
  # model="qwen-max-latest-search",
@@ -361,15 +408,17 @@ if __name__ == '__main__':
361
408
  # stream=True,
362
409
 
363
410
  # reasoning_effort="low",
364
- enable_thinking=True,
365
- thinking_budget=1024,
411
+ # enable_thinking=True,
412
+ # thinking_budget=1024,
366
413
  # stream_options={"include_usage": True},
367
414
 
368
415
  )
369
416
  token = None
370
417
 
371
- # token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMxMGNiZGFmLTM3NTQtNDYxYy1hM2ZmLTllYzgwMDUzMjljOSIsImV4cCI6MTc0ODQ3OTE0M30.oAIE1K0XA0YYqlxB8Su-u0UJbY_BBZa4_tvZpFJKxGY"
418
+ token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMxMGNiZGFmLTM3NTQtNDYxYy1hM2ZmLTllYzgwMDUzMjljOSIsImxhc3RfcGFzc3dvcmRfY2hhbmdlIjoxNzUwNjYwODczLCJleHAiOjE3NTc0ODczMDd9.7TQ9NicXYxghzI7EP3cPMFqa5j-09Sz1B9s3SnKZvkE"
372
419
 
373
420
  arun(create(request, token))
374
421
 
375
422
  # arun(to_file("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250211/tixcef/cherry.wav", token))
423
+
424
+ # arun(create_new_chat(token))