MeUtils 2025.5.15.14.3.22__py3-none-any.whl → 2025.5.29.18.12.8__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.5.15.14.3.22.dist-info → MeUtils-2025.5.29.18.12.8.dist-info}/METADATA +262 -262
- {MeUtils-2025.5.15.14.3.22.dist-info → MeUtils-2025.5.29.18.12.8.dist-info}/RECORD +44 -37
- examples/_openaisdk/openai_audio.py +5 -3
- examples/_openaisdk/openai_chatfire.py +5 -0
- examples/_openaisdk/openai_sophnet.py +47 -0
- meutils/ai_audio/asr/openai_asr.py +5 -5
- meutils/apis/audio/minimax.py +202 -0
- meutils/apis/dreamfaceapp/__init__.py +11 -0
- meutils/apis/dreamfaceapp/audios.py +31 -0
- meutils/apis/dreamfaceapp/images.py +110 -0
- meutils/apis/dreamfaceapp/videos.py +115 -0
- meutils/apis/fal/videos.py +1 -0
- meutils/apis/google/chat.py +3 -0
- meutils/apis/google/gemini_sdk.py +34 -0
- meutils/apis/images/recraft.py +11 -8
- meutils/apis/jimeng/audio.py +1 -1
- meutils/apis/jimeng/doubao_images.py +70 -0
- meutils/apis/jimeng/doubao_utils.py +4 -4
- meutils/apis/jimeng/videos.py +8 -3
- meutils/apis/oneapi/channel.py +11 -7
- meutils/apis/oneapi/user.py +1 -1
- meutils/apis/search/metaso.py +26 -8
- meutils/apis/siliconflow/videos.py +9 -16
- meutils/apis/volcengine_apis/__init__.py +0 -1
- meutils/apis/volcengine_apis/images.py +5 -4
- meutils/apis/volcengine_apis/tasks.py +74 -8
- meutils/config_utils/lark_utils/common.py +5 -5
- meutils/data/VERSION +1 -1
- meutils/io/files_utils.py +5 -3
- meutils/io/openai_files.py +3 -2
- meutils/llm/check_utils.py +35 -3
- meutils/llm/completions/chat_spark.py +31 -13
- meutils/llm/completions/qwenllm.py +25 -18
- meutils/llm/openai_polling/chat.py +2 -2
- meutils/office_automation/pdf.py +38 -2
- meutils/pipe.py +4 -1
- meutils/schemas/dreamfaceapp_types.py +12 -0
- meutils/schemas/metaso_types.py +9 -3
- meutils/schemas/oneapi/common.py +59 -21
- meutils/schemas/openai_types.py +5 -2
- meutils/apis/jimeng/doubao.py +0 -68
- {MeUtils-2025.5.15.14.3.22.dist-info → MeUtils-2025.5.29.18.12.8.dist-info}/LICENSE +0 -0
- {MeUtils-2025.5.15.14.3.22.dist-info → MeUtils-2025.5.29.18.12.8.dist-info}/WHEEL +0 -0
- {MeUtils-2025.5.15.14.3.22.dist-info → MeUtils-2025.5.29.18.12.8.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.5.15.14.3.22.dist-info → MeUtils-2025.5.29.18.12.8.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : images
|
5
|
+
# @Time : 2025/5/23 13:44
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
from meutils.pipe import *
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
import requests
|
16
|
+
import json
|
17
|
+
|
18
|
+
url = "https://tools.dreamfaceapp.com/dw-server/face/animate_image_web"
|
19
|
+
|
20
|
+
payload = json.dumps({
|
21
|
+
"aigc_img_no_save_flag": False,
|
22
|
+
"template_id": "6606889f54e4e700070db4b1",
|
23
|
+
"app_version": "4.7.1",
|
24
|
+
"timestamp": 1747978119668,
|
25
|
+
"user_id": "d7668b9337aa943709a4387101583ab1",
|
26
|
+
"no_water_mark": 0,
|
27
|
+
"merge_by_server": False,
|
28
|
+
"account_id": "67fcdea4ae936300076d8d89",
|
29
|
+
"pt_infos": [
|
30
|
+
{
|
31
|
+
"lan": "en",
|
32
|
+
"audio_id": "6d770a8819e946a797aec5bb43547142",
|
33
|
+
"context": "a dog",
|
34
|
+
"voice_engine_id": "prompt_97f7a53122124635be47b3a773c061e6",
|
35
|
+
"video_url": "https://cdns3.dreamfaceapp.com/web/common/material/219e971f53e54f3bb8fe9d55e12a1688.mp4"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"work_type": "AVATAR_VIDEO",
|
39
|
+
"santa_info": {
|
40
|
+
"email": "",
|
41
|
+
"signature": ""
|
42
|
+
},
|
43
|
+
"photo_info_list": [
|
44
|
+
{
|
45
|
+
"photo_path": "",
|
46
|
+
"origin_face_locations": [
|
47
|
+
{
|
48
|
+
"left_upper_x": 0,
|
49
|
+
"left_upper_y": 0,
|
50
|
+
"right_width": 1,
|
51
|
+
"down_high": 1
|
52
|
+
}
|
53
|
+
],
|
54
|
+
"square_face_locations": [
|
55
|
+
{
|
56
|
+
"left_upper_x": 0,
|
57
|
+
"left_upper_y": 0,
|
58
|
+
"down_high": 1,
|
59
|
+
"right_width": 1
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"five_lands": [
|
63
|
+
[
|
64
|
+
[
|
65
|
+
1,
|
66
|
+
1
|
67
|
+
],
|
68
|
+
[
|
69
|
+
1,
|
70
|
+
1
|
71
|
+
],
|
72
|
+
[
|
73
|
+
1,
|
74
|
+
1
|
75
|
+
],
|
76
|
+
[
|
77
|
+
1,
|
78
|
+
1
|
79
|
+
],
|
80
|
+
[
|
81
|
+
1,
|
82
|
+
1
|
83
|
+
]
|
84
|
+
]
|
85
|
+
],
|
86
|
+
"face_nums": 1,
|
87
|
+
"mask_path": ""
|
88
|
+
}
|
89
|
+
],
|
90
|
+
"play_types": [
|
91
|
+
"VIDEO",
|
92
|
+
"PT"
|
93
|
+
],
|
94
|
+
"ext": {
|
95
|
+
"track_info": "{}",
|
96
|
+
"sing_title": "a dog",
|
97
|
+
"animate_channel": "dynamic"
|
98
|
+
}
|
99
|
+
})
|
100
|
+
headers = {
|
101
|
+
'dream-face-web': 'dream-face-web',
|
102
|
+
'priority': 'u=1, i',
|
103
|
+
'token': 'eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDQ2NTQxMTYsInBheWxvYWQiOnsiaWQiOiI2N2ZjZGVhNGFlOTM2MzAwMDc2ZDhkODkiLCJ0aGlyZFBsYXRmb3JtIjoiR09PR0xFIiwidGhpcmRJZCI6IjExMTQ5Nzk1NTUyNjQxMTE4MjUwNiIsInBhc3N3b3JkIjpudWxsLCJ0aGlyZEV4dCI6eyJlbWFpbCI6ImFpY2hhdGZpcmVAZ21haWwuY29tIiwibmFtZSI6Im1lIGJldHRlciIsImdlbmRlciI6bnVsbCwiYmlydGhkYXkiOm51bGwsIm5pY2tOYW1lIjpudWxsLCJnaXZlbk5hbWUiOiJtZSIsImZhbWlseU5hbWUiOiJiZXR0ZXIiLCJwcm9maWxlUGljdHVyZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FDZzhvY0lnU1NDaHMxRDRzVGoxU1RrN1BzVG03eTUzSkRYOTlvOEJ4cFpjVjY1NjBBSmJSZz1zOTYtYyJ9LCJjcmVhdGVUaW1lIjoxNzQ0NjI1MzE2MDIyLCJ1cGRhdGVUaW1lRm9ybWF0IjoiMjAyNS0wNC0xNCAxODowODozNi4wMjIiLCJkZWxldGUiOm51bGwsImNyZWF0ZVRpbWVGb3JtYXQiOiIyMDI1LTA0LTE0IDE4OjA4OjM2LjAyMiIsInVwZGF0ZVRpbWUiOjE3NDQ2MjUzMTYwMjIsInBsYXRmb3JtVHlwZSI6Mn19.Rxt41B__ExhAHdmCHMiDDOkFl8IddSena5lsxbnNEX0',
|
104
|
+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
105
|
+
'content-type': 'application/json'
|
106
|
+
}
|
107
|
+
|
108
|
+
response = requests.request("POST", url, headers=headers, data=payload)
|
109
|
+
|
110
|
+
print(response.text)
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : videos
|
5
|
+
# @Time : 2025/5/23 14:13
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
from meutils.pipe import *
|
12
|
+
|
13
|
+
import requests
|
14
|
+
import json
|
15
|
+
|
16
|
+
url = "https://tools.dreamfaceapp.com/dw-server/face/animate_image_web"
|
17
|
+
|
18
|
+
|
19
|
+
def create_task(token: Optional[str] = None):
|
20
|
+
headers = {
|
21
|
+
'dream-face-web': 'dream-face-web',
|
22
|
+
'priority': 'u=1, i',
|
23
|
+
'token': 'eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDgwMDg1NDMsInBheWxvYWQiOnsiaWQiOiI2ODMwMDdhNDI2YmNjZDAwMDhlYjMxMjIiLCJ0aGlyZFBsYXRmb3JtIjoiR09PR0xFIiwidGhpcmRJZCI6IjEwMjg2OTM5NzI4OTkyMjc5NTE5MyIsInBhc3N3b3JkIjpudWxsLCJ0aGlyZEV4dCI6eyJlbWFpbCI6ImpyMTU5NjIyOTQ5ODBAZGp2Yy51ayIsIm5hbWUiOiJ6enkzMDIwOCB5a2Z3eDEyMjgxIiwiZ2VuZGVyIjpudWxsLCJiaXJ0aGRheSI6bnVsbCwibmlja05hbWUiOm51bGwsImdpdmVuTmFtZSI6Inp6eTMwMjA4IiwiZmFtaWx5TmFtZSI6InlrZnd4MTIyODEiLCJwcm9maWxlUGljdHVyZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FDZzhvY0tGQXBqUjVZTVhqLXNEYWhWRGw5YVNQT0VuVGlSaXFlMUQ0RTNEU1J5Nno1Wk9FQT1zOTYtYyJ9LCJjcmVhdGVUaW1lIjoxNzQ3OTc4MTQ4NDU0LCJ1cGRhdGVUaW1lRm9ybWF0IjoiMjAyNS0wNS0yMyAxMzoyOTowOC40NTQiLCJkZWxldGUiOm51bGwsImNyZWF0ZVRpbWVGb3JtYXQiOiIyMDI1LTA1LTIzIDEzOjI5OjA4LjQ1NCIsInVwZGF0ZVRpbWUiOjE3NDc5NzgxNDg0NTQsInBsYXRmb3JtVHlwZSI6Mn19.aWdRtZhxch0iQ7xsmR-Im_MLEqgWy7dW8eRigUxz4es',
|
24
|
+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
25
|
+
'content-type': 'application/json'
|
26
|
+
}
|
27
|
+
|
28
|
+
payload = {
|
29
|
+
"aigc_img_no_save_flag": False,
|
30
|
+
"template_id": "6606889f54e4e700070db4b1",
|
31
|
+
"app_version": "4.7.1",
|
32
|
+
"timestamp": 1747980670819,
|
33
|
+
"user_id": "bda0f9897c2aa378c5230cff3418168a",
|
34
|
+
"no_water_mark": 1,
|
35
|
+
"merge_by_server": False,
|
36
|
+
"account_id": "683007a426bccd0008eb3122",
|
37
|
+
"pt_infos": [
|
38
|
+
{
|
39
|
+
"lan": "zh",
|
40
|
+
"audio_id": "6629c44502c44c00073515e1",
|
41
|
+
"context": "这个屌公司一群傻逼吧",
|
42
|
+
"voice_engine_id": "zh-CN-XiaomengNeural",
|
43
|
+
"video_url": "https://lmdbk.com/5.mp4"
|
44
|
+
}
|
45
|
+
],
|
46
|
+
"work_type": "AVATAR_VIDEO",
|
47
|
+
"santa_info": {
|
48
|
+
"email": "",
|
49
|
+
"signature": ""
|
50
|
+
},
|
51
|
+
"photo_info_list": [
|
52
|
+
{
|
53
|
+
"photo_path": "",
|
54
|
+
"origin_face_locations": [
|
55
|
+
{
|
56
|
+
"left_upper_x": 0,
|
57
|
+
"left_upper_y": 0,
|
58
|
+
"right_width": 1,
|
59
|
+
"down_high": 1
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"square_face_locations": [
|
63
|
+
{
|
64
|
+
"left_upper_x": 0,
|
65
|
+
"left_upper_y": 0,
|
66
|
+
"down_high": 1,
|
67
|
+
"right_width": 1
|
68
|
+
}
|
69
|
+
],
|
70
|
+
"five_lands": [
|
71
|
+
[
|
72
|
+
[
|
73
|
+
1,
|
74
|
+
1
|
75
|
+
],
|
76
|
+
[
|
77
|
+
1,
|
78
|
+
1
|
79
|
+
],
|
80
|
+
[
|
81
|
+
1,
|
82
|
+
1
|
83
|
+
],
|
84
|
+
[
|
85
|
+
1,
|
86
|
+
1
|
87
|
+
],
|
88
|
+
[
|
89
|
+
1,
|
90
|
+
1
|
91
|
+
]
|
92
|
+
]
|
93
|
+
],
|
94
|
+
"face_nums": 1,
|
95
|
+
"mask_path": ""
|
96
|
+
}
|
97
|
+
],
|
98
|
+
"play_types": [
|
99
|
+
"VIDEO",
|
100
|
+
"PT"
|
101
|
+
],
|
102
|
+
"ext": {
|
103
|
+
"track_info": "{}",
|
104
|
+
"sing_title": "这个屌公司一群傻逼吧",
|
105
|
+
"animate_channel": "dynamic"
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
response = requests.request("POST", url, headers=headers, data=payload)
|
110
|
+
|
111
|
+
print(response.text)
|
112
|
+
|
113
|
+
|
114
|
+
if __name__ == '__main__':
|
115
|
+
create_task()
|
meutils/apis/fal/videos.py
CHANGED
@@ -61,6 +61,7 @@ async def get_task(task_id: str, token: Optional[str] = None):
|
|
61
61
|
|
62
62
|
|
63
63
|
if __name__ == '__main__':
|
64
|
+
# https://fal.ai/models/fal-ai/tavus/hummingbird-lipsync/v0
|
64
65
|
model = "latentsync"
|
65
66
|
# model = "sync-lipsync"
|
66
67
|
audio_url = "https://oss.ffire.cc/files/lipsync.mp3"
|
meutils/apis/google/chat.py
CHANGED
@@ -122,6 +122,8 @@ class Completions(object):
|
|
122
122
|
yield f"```json\n{file_object.model_dump_json(indent=4)}\n```\n\n"
|
123
123
|
|
124
124
|
s = time.time()
|
125
|
+
|
126
|
+
yield "[Thinking]("
|
125
127
|
for i in range(100):
|
126
128
|
file_object = self.client.files.get(
|
127
129
|
name=file_object.name,
|
@@ -129,6 +131,7 @@ class Completions(object):
|
|
129
131
|
)
|
130
132
|
|
131
133
|
logger.debug(file_object)
|
134
|
+
|
132
135
|
if file_object.state.name in {"ACTIVE", }:
|
133
136
|
yield f"100%) ✅️✅️✅️{time.time() - s:.2f}s.\n\n"
|
134
137
|
break
|
@@ -35,6 +35,28 @@ client = genai.Client(
|
|
35
35
|
)
|
36
36
|
)
|
37
37
|
|
38
|
+
GOOGLE_CREDENTIALS_JSON="""{
|
39
|
+
"type": "service_account",
|
40
|
+
"project_id": "mystic-gradient-460414-s3",
|
41
|
+
"private_key_id": "074dc3f29316a8d663c6af1eb3e9b60f9c440230",
|
42
|
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCtAW0wwjk0GheH\nF1PEps5Q+smR9Fc9lBcK6R5cTpJo0aNC/9xvz6yqFXYpTjTqwUYK8EH62RFP4K9g\neZRTAQdF4qXP7S1cPsyeBEtk2whsjUIThS0dK1FZzOM3CLM+JRUU9AJdkQWuY4pT\ngfcZ+x5KtfbbTZQ3rf91ZPbaJID/cEd1yjiquhSWG6UGYxN09YPEmPOMAUSBmphI\nWhPdMLih3lghxHRbIhXF2y8uTAIVifyT4xFb7C9IT4NphMt/Ee5hpN+GzlveNsPK\n6UdO7XBgpWX+GjxCoxKgvuvpsJxBprv87BVar4jOFS8YaIMBaSKV37ZKDs1/JNaa\nYn0nCepJAgMBAAECggEABCMNOH3idoqbrqsqAYEwHItcq9DtD5/Fi8kehNxLn7ZI\nmkLqQ2GyyifkeREhzo3D1iHf4AbWBUQVCYBqwa/b+8mzR5UvMR4e0DX/1AfxTAA2\nOOeFuEV3hudRdRjQCW/DUOqTTme3/C8s6PmJ/jztIOH4Rs70eP7gBY9+ICIAlCsR\n258PYn3AkLq6u3f0lYVeafV2I52aX861FlQTGNfTg3Npixx0ygWKrppX67bhlzm8\nyedpkCc3S+ZIjfYAG8mO57vYWUi0oPA6TDbzAQBHqq1Su2+WvsCaqpJ3PtPVigSj\n/KSsUmCXGMXDl3/yRBvuzV6SMlpylBx72SJY8Pn0gQKBgQDz9f6+58l7BBG1fFKe\nYJdRViuGjNG6pKfXnPFaZEpwwgJx2C4chkEKBB6ge6hiIrk9CCE365xjVl82l99x\nqukOWf6dsW6nX7U4oMNQ53ZMPpCdHvaFI9E/B9Exl01GGx61Ajx88NMFVXDYbWa+\n+gKZ6DFeMukMwqWAPqRmMbp8gQKBgQC1iwn6mbsxiSteZ9SzfE+rPb9FkxC/W0VO\nQMBwTVD52M5STZbuXj+oRP1DXFEz1HWNWhrX2w92faLgaZQv5rbXXXkI5zD1Ymlo\n82yjxjoe2fs79GzuQjs5pVzr9Gd7qjqDiHQETV67uqkjjjrBDxtnh2pBJrQ7NAX4\nWQ5YvO2pyQKBgQDlWaLAftAf4ldzswlI863OPaB1wfV57koMnfMY86g4EWyS8pWH\nI4AJlo3kedx3RgW3pujz1YEUsqKYhHcAOZkYcOq5/ZD1sTiBoEF+0duZGkiCLhW8\nXUveYc79PCzdd6mKqiuLmiwIm6aXEWLCr++6GVwwHtSRtnw48KtFmAKmAQKBgEHn\n6AeCJ+Mj2Qq8xwsh5gpUsEuhyEKv78ko2LPsXalWfBCE+nYu4Q1Ffmwl55TZXJOk\nUnpqnIJ3udmeep2pNFebJ4WD6NIsl/fx507Nd+wbVom9go48nSOgVMuUPr02X2fA\n8d1d+TZN3Xl6+Pl9coVzM6/TTTrw9/ng2sR8UguBAoGBAJ6SMKAqa+yjZezDUkC3\nUkmywTRX9vfhH5mDv+kj1MHW++hLYhLE7WRNtMhgf9idLEQBbw7jzoS4wmx9jtPu\nP0mUh67fjctbtR6uxbuZl5sY3eMx03hmv5H33aazhMA7mQXjMPS7gXTIxMoE2Wmw\nFpJyddFAuwMDZecDr74xNU9b\n-----END PRIVATE KEY-----\n",
|
43
|
+
"client_email": "xxxxx-350@mystic-gradient-460414-s3.iam.gserviceaccount.com",
|
44
|
+
"client_id": "115968049812880579488",
|
45
|
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
46
|
+
"token_uri": "https://oauth2.googleapis.com/token",
|
47
|
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
48
|
+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxxxx-350%40mystic-gradient-460414-s3.iam.gserviceaccount.com",
|
49
|
+
"universe_domain": "googleapis.com"
|
50
|
+
}"""
|
51
|
+
|
52
|
+
|
53
|
+
client = genai.Client(
|
54
|
+
vertexai=True,
|
55
|
+
credentials=GOOGLE_CREDENTIALS_JSON,
|
56
|
+
http_options=HttpOptions(
|
57
|
+
base_url="https://all.chatfire.cc/genai"
|
58
|
+
)
|
59
|
+
)
|
38
60
|
if __name__ == '__main__':
|
39
61
|
model = "gemini-2.0-flash-exp-image-generation"
|
40
62
|
model = "gemini-2.5-flash-preview-04-17"
|
@@ -192,3 +214,15 @@ curl "https://all.chatfire.cc/genai/v1beta/models/gemini-2.5-flash-preview-04-17
|
|
192
214
|
}
|
193
215
|
}'
|
194
216
|
"""
|
217
|
+
|
218
|
+
from litellm import completion
|
219
|
+
import os
|
220
|
+
|
221
|
+
# auth: run 'gcloud auth application-default'
|
222
|
+
os.environ["VERTEXAI_PROJECT"] = "hardy-device-386718"
|
223
|
+
os.environ["VERTEXAI_LOCATION"] = "us-central1"
|
224
|
+
|
225
|
+
response = completion(
|
226
|
+
model="vertex_ai/gemini-1.5-pro",
|
227
|
+
messages=[{ "content": "Hello, how are you?","role": "user"}]
|
228
|
+
)
|
meutils/apis/images/recraft.py
CHANGED
@@ -41,8 +41,10 @@ async def get_access_token(token: str):
|
|
41
41
|
logger.debug(response.json())
|
42
42
|
return response.json()["accessToken"]
|
43
43
|
|
44
|
+
|
44
45
|
@retrying()
|
45
|
-
async def edit_image(image, task: Literal["vectorize", "super_resolution",] = "super_resolution",
|
46
|
+
async def edit_image(image, task: Literal["vectorize", "super_resolution",] = "super_resolution",
|
47
|
+
response_format: Literal["url", "base64"] = "url"):
|
46
48
|
token = await get_next_token_for_polling(
|
47
49
|
feishu_url=FEISHU_URL,
|
48
50
|
check_token=check_token,
|
@@ -141,14 +143,17 @@ async def generate(request: RecraftImageRequest, token: Optional[str] = None):
|
|
141
143
|
|
142
144
|
# eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDY5MjY2MjQsInVzZXIiOnsiaWQiOiIzNjIzNjMwNDU2OTAxNTkxMDciLCJuYW1lIjoibWtybiBhbmJ2IiwiYXZhdGFyIjoiIiwiZGV2aWNlSUQiOiIzMjg2MDA4MzYzNzEwMzQxMTgiLCJpc0Fub255bW91cyI6ZmFsc2V9fQ.JyCL0Be9YsEBlLVIeSpqDv3bTKAlU9Jsds3y5cJKXa4
|
143
145
|
async def check_token(token, threshold: float = 1):
|
144
|
-
if
|
146
|
+
if isinstance(token, list):
|
145
147
|
tokens = token
|
146
148
|
r = []
|
149
|
+
logger.debug(tokens)
|
147
150
|
for batch in tqdm(tokens | xgroup(32)):
|
148
151
|
bools = await asyncio.gather(*map(check_token, batch))
|
149
152
|
r += list(itertools.compress(batch, bools))
|
150
153
|
return r
|
154
|
+
|
151
155
|
try:
|
156
|
+
|
152
157
|
access_token = await get_access_token(token)
|
153
158
|
headers = {"Authorization": f"Bearer {access_token}"}
|
154
159
|
|
@@ -200,10 +205,8 @@ if __name__ == '__main__':
|
|
200
205
|
# with timer():
|
201
206
|
# arun(generate(request, token=token))
|
202
207
|
|
203
|
-
with timer():
|
204
|
-
|
208
|
+
# with timer():
|
209
|
+
# arun(edit_image("https://oss.ffire.cc/files/kling_watermark.png"))
|
205
210
|
# tokens = [token]
|
206
|
-
|
207
|
-
|
208
|
-
# #
|
209
|
-
# r = arun(check_token(tokens[:5]))
|
211
|
+
tokens = list(arun(aget_spreadsheet_values(feishu_url=FEISHU_URL, to_dataframe=True))[0]) | xfilter_
|
212
|
+
r = arun(check_token(tokens))
|
meutils/apis/jimeng/audio.py
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : images
|
5
|
+
# @Time : 2024/12/16 17:46
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
from openai import AsyncClient
|
12
|
+
from meutils.pipe import *
|
13
|
+
from meutils.apis.jimeng.doubao_utils import generate_cookie, generate_params
|
14
|
+
|
15
|
+
from meutils.schemas.image_types import ImageRequest
|
16
|
+
|
17
|
+
from meutils.schemas.jimeng_types import BASE_URL, MODELS_MAP, FEISHU_URL
|
18
|
+
from meutils.config_utils.lark_utils import get_next_token_for_polling
|
19
|
+
|
20
|
+
|
21
|
+
async def create(token: Optional[str] = None):
|
22
|
+
token = token or "712a47e7eec7c03b4cc7229775e06841"
|
23
|
+
cookie = generate_cookie(token)
|
24
|
+
params = generate_params()
|
25
|
+
|
26
|
+
headers = {
|
27
|
+
'Cookie': cookie,
|
28
|
+
'agw-js-conv': 'str',
|
29
|
+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
30
|
+
'content-type': 'application/json'
|
31
|
+
}
|
32
|
+
payload = {
|
33
|
+
"messages": [
|
34
|
+
{
|
35
|
+
"content": "{\"text\":\"一只猫\"}",
|
36
|
+
"content_type": 2009,
|
37
|
+
"attachments": [
|
38
|
+
|
39
|
+
]
|
40
|
+
}
|
41
|
+
],
|
42
|
+
"completion_option": {
|
43
|
+
"is_regen": False,
|
44
|
+
"with_suggest": False,
|
45
|
+
"need_create_conversation": False,
|
46
|
+
"launch_stage": 1,
|
47
|
+
"is_replace": False,
|
48
|
+
"is_delete": False,
|
49
|
+
"message_from": 0,
|
50
|
+
"event_id": "0"
|
51
|
+
},
|
52
|
+
"section_id": "6287920686327298",
|
53
|
+
"conversation_id": "6287920686327042",
|
54
|
+
"local_message_id": "936eee40-354d-11f0-83df-6b1810ffef8a"
|
55
|
+
|
56
|
+
# "local_message_id": str(uuid.uuid4())
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
client = AsyncClient(base_url="https://www.doubao.com/samantha", default_headers=headers, api_key='xx',
|
61
|
+
)
|
62
|
+
response = await client.post("/chat/completion", body=payload, cast_to=object, stream=True,
|
63
|
+
options=dict(params=params))
|
64
|
+
async for i in response:
|
65
|
+
print(i)
|
66
|
+
# return response
|
67
|
+
|
68
|
+
|
69
|
+
if __name__ == '__main__':
|
70
|
+
arun(create())
|
@@ -132,7 +132,7 @@ def generate_cookie(refresh_token: str, ms_token: Optional[str] = None) -> str:
|
|
132
132
|
return "; ".join(cookie_parts)
|
133
133
|
|
134
134
|
|
135
|
-
async def get_upload_token(): # 3600过期
|
135
|
+
async def get_upload_token(refresh_token): # 3600过期
|
136
136
|
"""
|
137
137
|
|
138
138
|
{'code': 0,
|
@@ -148,7 +148,7 @@ async def get_upload_token(): # 3600过期
|
|
148
148
|
|
149
149
|
:return:
|
150
150
|
"""
|
151
|
-
cookie = generate_cookie(
|
151
|
+
cookie = generate_cookie(refresh_token)
|
152
152
|
url = "https://www.doubao.com/alice/upload/auth_token"
|
153
153
|
|
154
154
|
headers = {
|
@@ -170,6 +170,6 @@ async def get_upload_token(): # 3600过期
|
|
170
170
|
if __name__ == '__main__':
|
171
171
|
# generate_cookie("")
|
172
172
|
|
173
|
-
|
174
|
-
print(generate_params())
|
173
|
+
arun(get_upload_token("712a47e7eec7c03b4cc7229775e06841"))
|
174
|
+
# print(generate_params())
|
175
175
|
# print(get_signing_key('xW9YbDhTlWsXdaN7O2g1lfcyePxf5kJyg/r2mwSZG/iuSmbvVgToO6LVCLmUjVJ3'))
|
meutils/apis/jimeng/videos.py
CHANGED
@@ -36,6 +36,8 @@ async def get_task(task_id: str, token: str = "916fed81175f5186a2c05375699ea40d"
|
|
36
36
|
$..image_to_avatar 成功: 先检测图片or视频
|
37
37
|
:param task_ids:
|
38
38
|
:return:
|
39
|
+
|
40
|
+
todo: fail_code
|
39
41
|
"""
|
40
42
|
task_ids = task_id.split()
|
41
43
|
|
@@ -154,9 +156,12 @@ if __name__ == '__main__':
|
|
154
156
|
image_url="https://oss.ffire.cc/files/kling_watermark.png", # 图生有问题
|
155
157
|
)
|
156
158
|
|
157
|
-
with timer():
|
158
|
-
|
159
|
-
|
159
|
+
# with timer():
|
160
|
+
# r = arun(create_task(request, token))
|
161
|
+
# print(r)
|
160
162
|
|
161
163
|
# arun(get_task(r.task_id))
|
162
164
|
# arun(get_task(r.task_id, "d2d142fc877e696484cc2fc521127b36"))
|
165
|
+
task_id = "4620067333122"
|
166
|
+
|
167
|
+
arun(get_task(task_id, token))
|
meutils/apis/oneapi/channel.py
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
# @Description :
|
10
10
|
|
11
11
|
from meutils.pipe import *
|
12
|
+
from meutils.hash_utils import murmurhash
|
12
13
|
from meutils.schemas.oneapi import BASE_URL, GROUP_RATIO
|
13
14
|
|
14
15
|
headers = {
|
@@ -72,24 +73,27 @@ async def edit_channel(models, token: Optional[str] = None):
|
|
72
73
|
|
73
74
|
|
74
75
|
# todo: 分批
|
76
|
+
|
75
77
|
async def create_or_update_channel(api_key, base_url: Optional[str] = "https://api.ffire.cc"):
|
76
78
|
if isinstance(api_key, list):
|
77
79
|
api_keys = api_key | xgroup(128) # [[],]
|
78
80
|
else:
|
79
81
|
api_keys = [[api_key]]
|
80
82
|
|
81
|
-
models = "gemini-
|
82
|
-
nothinking_models = 'gemini-2.5-
|
83
|
+
models = "gemini-2.5-flash-preview-05-20,gemini-1.5-flash-latest,gemini-1.5-flash-001,gemini-1.5-flash-001-tuning,gemini-1.5-flash,gemini-1.5-flash-002,gemini-1.5-flash-8b,gemini-1.5-flash-8b-001,gemini-1.5-flash-8b-latest,gemini-1.5-flash-8b-exp-0827,gemini-1.5-flash-8b-exp-0924,gemini-2.5-flash-preview-04-17,gemini-2.0-flash-exp,gemini-2.0-flash,gemini-2.0-flash-001,gemini-2.0-flash-exp-image-generation,gemini-2.0-flash-lite-001,gemini-2.0-flash-lite,gemini-2.0-flash-lite-preview-02-05,gemini-2.0-flash-lite-preview,gemini-2.0-flash-thinking-exp-01-21,gemini-2.0-flash-thinking-exp,gemini-2.0-flash-thinking-exp-1219,learnlm-2.0-flash-experimental,gemma-3-1b-it,gemma-3-4b-it,gemma-3-12b-it,gemma-3-27b-it,gemini-2.0-flash-live-001"
|
84
|
+
nothinking_models = 'gemini-2.5-flash-preview-05-20-nothinking,gemini-2.5-flash-preview-04-17-nothinking,gemini-2.0-flash-thinking-exp-01-21-nothinking,gemini-2.0-flash-thinking-exp-nothinking,gemini-2.0-flash-thinking-exp-1219-nothinking'
|
83
85
|
models = f"{models},{nothinking_models}"
|
84
86
|
|
85
87
|
payload = {
|
86
88
|
# "id": 7493,
|
87
|
-
"type": 24
|
89
|
+
"type": 24, # gemini
|
88
90
|
# "key": "AIzaSyCXWV19FRM4XX0KHmpR9lYUz9i1wxQTYUg",
|
89
91
|
"openai_organization": "",
|
90
92
|
"test_model": "",
|
91
93
|
"status": 1,
|
92
94
|
"name": "gemini",
|
95
|
+
|
96
|
+
"priority": murmurhash(api_key, bins=3),
|
93
97
|
"weight": 0,
|
94
98
|
# "created_time": 1745554162,
|
95
99
|
# "test_time": 1745554168,
|
@@ -102,7 +106,6 @@ async def create_or_update_channel(api_key, base_url: Optional[str] = "https://a
|
|
102
106
|
# "used_quota": 0,
|
103
107
|
"model_mapping": """{"gemini-2.5-pro-preview-03-25": "gemini-2.5-pro-exp-03-25"}""",
|
104
108
|
# "status_code_mapping": "",
|
105
|
-
# "priority": 0,
|
106
109
|
# "auto_ban": 1,
|
107
110
|
# "other_info": "",
|
108
111
|
# "settings": "",
|
@@ -154,12 +157,11 @@ if __name__ == '__main__':
|
|
154
157
|
# base_url = "https://api.ffire.cc"
|
155
158
|
base_url = "https://usa.chatfire.cn"
|
156
159
|
#
|
157
|
-
tokens = arun(get_series(FEISHU_URL))
|
160
|
+
tokens = arun(get_series(FEISHU_URL)) # [:5]
|
158
161
|
arun(create_or_update_channel(tokens, base_url))
|
159
162
|
# arun(create_or_update_channel(tokens))
|
160
163
|
# # arun(delete_channel(range(10000, 20000)))
|
161
164
|
|
162
|
-
|
163
165
|
"""
|
164
166
|
API_KEY=6c255307-7b4d-4be8-984b-5440a3e867eb
|
165
167
|
curl --location --request POST 'https://api.ffire.cc/api/channel/' \
|
@@ -200,4 +202,6 @@ curl --location --request POST 'https://api.ffire.cc/api/channel/' \
|
|
200
202
|
"volcengine"
|
201
203
|
]
|
202
204
|
}'
|
203
|
-
"""
|
205
|
+
"""
|
206
|
+
|
207
|
+
|
meutils/apis/oneapi/user.py
CHANGED
@@ -113,4 +113,4 @@ if __name__ == '__main__':
|
|
113
113
|
|
114
114
|
# arun(get_api_key_log('sk-gpoH1z3G6nHovD8MY40i6xx5tsC1vbh7B3Aao2jmejYNoKhv'))
|
115
115
|
# arun(get_user_money("sk-LlB4W38z9kv5Wy1c3ceeu4PHeIWs6bbWsjr8Om31jYvsucRv"))
|
116
|
-
arun(get_user_from_api_key('sk-
|
116
|
+
arun(get_user_from_api_key('sk-4mQ0TUJtKfBF7iLcSmVlMCFgeV1gFxs3aPJRI6uBcojPoEBy'))
|
meutils/apis/search/metaso.py
CHANGED
@@ -30,12 +30,20 @@ MODELS = {
|
|
30
30
|
|
31
31
|
"deepseek-r1-metasearch": "strong-research",
|
32
32
|
|
33
|
+
"deepseek-r1-metaresearch": "strong-research",
|
34
|
+
|
33
35
|
"meta-research": "strong-research",
|
36
|
+
|
37
|
+
"meta-search": "detail",
|
38
|
+
"meta-deepsearch": "strong-research",
|
34
39
|
"meta-deepresearch": "strong-research",
|
35
|
-
|
40
|
+
|
41
|
+
"meta-search:scholar": "detail",
|
42
|
+
"meta-deepsearch:scholar": "strong-research",
|
43
|
+
"meta-deepresearch:scholar": "strong-research",
|
44
|
+
|
36
45
|
}
|
37
46
|
|
38
|
-
""
|
39
47
|
# pattern = re.compile('\[\[(\d+)\]\]')
|
40
48
|
pattern = re.compile(r'\[\[(\d+)\]\]')
|
41
49
|
|
@@ -105,18 +113,18 @@ async def create(request: Union[ChatCompletionRequest, CompletionRequest]):
|
|
105
113
|
|
106
114
|
system_fingerprint = request.system_fingerprint
|
107
115
|
|
108
|
-
engine_type =
|
116
|
+
engine_type = None
|
109
117
|
if ":" in request.model:
|
110
118
|
_, engine_type = request.model.split(':')
|
111
119
|
|
112
120
|
model = None
|
113
|
-
if request.model
|
114
|
-
model = "
|
115
|
-
system_fingerprint = "deepseek-r1"
|
121
|
+
if any(i in request.model for i in {"deep", "thinking"}):
|
122
|
+
model = system_fingerprint = "fast_thinking"
|
116
123
|
|
117
124
|
request = MetasoRequest(
|
118
125
|
model=model,
|
119
126
|
mode=MODELS.get(request.model, "detail"),
|
127
|
+
engineType=engine_type,
|
120
128
|
question=request.last_content,
|
121
129
|
)
|
122
130
|
|
@@ -190,13 +198,23 @@ if __name__ == '__main__':
|
|
190
198
|
# arun(get_access_token(request))
|
191
199
|
"""
|
192
200
|
metasearch-
|
201
|
+
|
202
|
+
model-mode
|
193
203
|
"""
|
194
204
|
|
195
205
|
request = ChatCompletionRequest(
|
206
|
+
|
207
|
+
# model="meta-search",
|
208
|
+
# model="meta-deepsearch",
|
209
|
+
# model="meta-deepresearch",
|
210
|
+
|
211
|
+
model="meta-search:video",
|
212
|
+
|
213
|
+
# model="deepseek-r1-metasearch",
|
214
|
+
|
196
215
|
# model="deepseek-search",
|
197
216
|
# model="deepseek-r1-search",
|
198
217
|
# model="11meta-deepresearch",
|
199
|
-
model="meta-search",
|
200
218
|
|
201
219
|
# model="ai-search",
|
202
220
|
# model="ai-search:scholar",
|
@@ -206,7 +224,7 @@ if __name__ == '__main__':
|
|
206
224
|
|
207
225
|
# messages=[{'role': 'user', 'content': '今天南京天气怎么样'}]
|
208
226
|
# messages=[{'role': 'user', 'content': '1+1'}]
|
209
|
-
messages=[{'role': 'user', 'content': '
|
227
|
+
messages=[{'role': 'user', 'content': '周杰伦是谁'}]
|
210
228
|
|
211
229
|
)
|
212
230
|
|