MeUtils 2024.12.13.15.39.7__py3-none-any.whl → 2024.12.19.11.21.54__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-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/METADATA +26 -26
- {MeUtils-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/RECORD +30 -21
- examples/_openaisdk/4v.py +2 -1
- examples/_openaisdk/gpt4all.py +0 -5
- examples/_openaisdk/open_router.py +5 -2
- examples/_openaisdk/openai_chatfire.py +8 -2
- examples/_openaisdk/openai_images.py +8 -6
- examples/caches/llmcache.py +18 -0
- meutils/apis/hailuoai/videos.py +1 -1
- meutils/apis/images/fal/files.py +4 -1
- meutils/apis/jimeng/__init__.py +11 -0
- meutils/apis/jimeng/common.py +253 -0
- meutils/apis/jimeng/files.py +180 -0
- meutils/apis/jimeng/images.py +105 -0
- meutils/apis/jimeng/sig.py +92 -0
- meutils/apis/jimeng/utils.py +177 -0
- meutils/apis/siliconflow/videos.py +38 -9
- meutils/data/VERSION +1 -1
- meutils/data/oneapi/NOTICE.md +12 -29
- meutils/io/files_utils.py +34 -3
- meutils/llm/completions/rag/fire.py +2 -1
- meutils/llm/mappers.py +15 -0
- meutils/office_automation/pdf.py +5 -1
- meutils/schemas/jimeng_types.py +28 -0
- meutils/schemas/oneapi/common.py +13 -0
- meutils/schemas/task_types.py +1 -1
- {MeUtils-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/LICENSE +0 -0
- {MeUtils-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/WHEEL +0 -0
- {MeUtils-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/entry_points.txt +0 -0
- {MeUtils-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : utils
|
5
|
+
# @Time : 2024/12/18 11:03
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
import httpx
|
11
|
+
|
12
|
+
from meutils.pipe import *
|
13
|
+
import random
|
14
|
+
import base64
|
15
|
+
import time
|
16
|
+
import uuid
|
17
|
+
import secrets
|
18
|
+
import string
|
19
|
+
import hmac
|
20
|
+
import hashlib
|
21
|
+
|
22
|
+
# 常量定义
|
23
|
+
MODEL_NAME = "doubao"
|
24
|
+
DEFAULT_ASSISTANT_ID = "497858"
|
25
|
+
VERSION_CODE = "20800"
|
26
|
+
DEVICE_ID = random.random() * 999999999999999999 + 7000000000000000000
|
27
|
+
WEB_ID = random.random() * 999999999999999999 + 7000000000000000000
|
28
|
+
USER_ID = str(uuid.uuid4()).replace('-', '')
|
29
|
+
MAX_RETRY_COUNT = 3
|
30
|
+
RETRY_DELAY = 5000
|
31
|
+
FILE_MAX_SIZE = 100 * 1024 * 1024
|
32
|
+
|
33
|
+
# 伪装headers
|
34
|
+
FAKE_HEADERS = {
|
35
|
+
"Accept": "*/*",
|
36
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
37
|
+
"Accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
38
|
+
"Cache-control": "no-cache",
|
39
|
+
"Last-event-id": "undefined",
|
40
|
+
"Origin": "https://www.doubao.com",
|
41
|
+
"Pragma": "no-cache",
|
42
|
+
"Priority": "u=1, i",
|
43
|
+
"Referer": "https://www.doubao.com",
|
44
|
+
"Sec-Ch-Ua": '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
|
45
|
+
"Sec-Ch-Ua-Mobile": "?0",
|
46
|
+
"Sec-Ch-Ua-Platform": '"Windows"',
|
47
|
+
"Sec-Fetch-Dest": "empty",
|
48
|
+
"Sec-Fetch-Mode": "cors",
|
49
|
+
"Sec-Fetch-Site": "same-origin",
|
50
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
async def acquire_token(refresh_token: str) -> str:
|
55
|
+
"""
|
56
|
+
获取缓存中的access_token
|
57
|
+
目前doubao的access_token是固定的,暂无刷新功能
|
58
|
+
|
59
|
+
Args:
|
60
|
+
refresh_token: 用于刷新access_token的refresh_token
|
61
|
+
|
62
|
+
Returns:
|
63
|
+
str: access_token
|
64
|
+
"""
|
65
|
+
return refresh_token
|
66
|
+
|
67
|
+
|
68
|
+
def generate_fake_ms_token() -> str:
|
69
|
+
"""
|
70
|
+
生成伪msToken
|
71
|
+
"""
|
72
|
+
# 生成96字节的随机数据
|
73
|
+
random_bytes = secrets.token_bytes(96)
|
74
|
+
# 转换为base64,并替换特殊字符
|
75
|
+
token = base64.b64encode(random_bytes).decode('utf-8')
|
76
|
+
return token.replace('+', '-').replace('/', '_').rstrip('=')
|
77
|
+
|
78
|
+
|
79
|
+
def generate_random_string(length: int) -> str:
|
80
|
+
"""
|
81
|
+
生成指定长度的随机字符串
|
82
|
+
"""
|
83
|
+
chars = string.ascii_letters + string.digits
|
84
|
+
return ''.join(random.choice(chars) for _ in range(length))
|
85
|
+
|
86
|
+
|
87
|
+
def generate_fake_a_bogus() -> str:
|
88
|
+
"""
|
89
|
+
生成伪a_bogus
|
90
|
+
"""
|
91
|
+
return f"mf-{generate_random_string(34)}-{generate_random_string(6)}"
|
92
|
+
|
93
|
+
|
94
|
+
def generate_cookie(refresh_token: str, ms_token: Optional[str] = None) -> str:
|
95
|
+
"""
|
96
|
+
生成cookie
|
97
|
+
"""
|
98
|
+
ms_token = ms_token or generate_fake_ms_token()
|
99
|
+
|
100
|
+
current_timestamp = int(time.time())
|
101
|
+
cookie_parts = [
|
102
|
+
f"is_staff_user=false",
|
103
|
+
f"store-region=cn-gd",
|
104
|
+
f"store-region-src=uid",
|
105
|
+
f"sid_guard={refresh_token}%7C{current_timestamp}%7C5184000%7CSun%2C+02-Feb-2025+04%3A17%3A20+GMT",
|
106
|
+
f"uid_tt={USER_ID}",
|
107
|
+
f"uid_tt_ss={USER_ID}",
|
108
|
+
f"sid_tt={refresh_token}",
|
109
|
+
f"sessionid={refresh_token}",
|
110
|
+
f"sessionid_ss={refresh_token}",
|
111
|
+
f"msToken={ms_token}",
|
112
|
+
]
|
113
|
+
return "; ".join(cookie_parts)
|
114
|
+
|
115
|
+
|
116
|
+
async def get_upload_token(): # 3600过期
|
117
|
+
"""
|
118
|
+
|
119
|
+
{'code': 0,
|
120
|
+
'data': {'auth': {'access_key_id': 'AKTPYzNkMjJlNTNjMWE1NDJiN2E5MWFkOTYxMWViYzQxYTM',
|
121
|
+
'current_time': '2024-12-18T11:17:22+08:00',
|
122
|
+
'expired_time': '2024-12-18T12:17:22+08:00',
|
123
|
+
'secret_access_key': 'HFFTkEFKf+0DVpUrYy2yMzvgnkxLMU6+qydnGUSaDmd0vSRedpIi0qmeWSVElyOU',
|
124
|
+
'session_token': 'STS2eyJMVEFjY2Vzc0tleUlkIjoiQUtMVFlUZGhPR0ptWVRNNFl6ZG1OR1JoWVRoaE0yWTJPVFl5TW1SbU0yRmhNREEiLCJBY2Nlc3NLZXlJZCI6IkFLVFBZek5rTWpKbE5UTmpNV0UxTkRKaU4yRTVNV0ZrT1RZeE1XVmlZelF4WVRNIiwiU2lnbmVkU2VjcmV0QWNjZXNzS2V5IjoiTC9WZTVSMmt4N3dsY1kvS0E5alp1WVlpSlVFM0ZjdHMzQ2Q5QjJZMVE3NlRnUDVONWViMmpKQkRQMUdyUEtqeXNYNXRKVkJPdExvVjVNOGFyY24wQ2ZtdUZRRWMxMG8xMSs3UHdKdGY0LzQ9IiwiRXhwaXJlZFRpbWUiOjE3MzQ0OTU0NDIsIlBvbGljeVN0cmluZyI6IntcIlN0YXRlbWVudFwiOlt7XCJFZmZlY3RcIjpcIkFsbG93XCIsXCJBY3Rpb25cIjpbXCJJbWFnZVg6QXBwbHlJbWFnZVVwbG9hZFwiLFwiSW1hZ2VYOkNvbW1pdEltYWdlVXBsb2FkXCJdLFwiUmVzb3VyY2VcIjpbXCJ0cm46SW1hZ2VYOio6KjpTZXJ2aWNlSWQvYTlybnMycmw5OFwiXX0se1wiRWZmZWN0XCI6XCJBbGxvd1wiLFwiQWN0aW9uXCI6W1wiUFNNXCJdLFwiUmVzb3VyY2VcIjpbXCJmbG93LmFsaWNlLnJlc291cmNlX2FwaVwiXX1dfSIsIlNpZ25hdHVyZSI6ImI2MGUxNDZkZTU0Njg2NTdlYzVlZmFjZjJlOWNlOWE5YTdhY2UwNTFlZTdkYTJjZTRmNjdiYmRiM2U4MDQ3N2IifQ=='},
|
125
|
+
'service_id': 'a9rns2rl98',
|
126
|
+
'upload_host': 'imagex.bytedanceapi.com',
|
127
|
+
'upload_path_prefix': 'bot-chat-image'},
|
128
|
+
'msg': ''}
|
129
|
+
|
130
|
+
:return:
|
131
|
+
"""
|
132
|
+
cookie = generate_cookie('de2215a7bb8e442774cf388f03fac84c')
|
133
|
+
url = "https://www.doubao.com/alice/upload/auth_token"
|
134
|
+
|
135
|
+
headers = {
|
136
|
+
'priority': 'u=1, i',
|
137
|
+
'Cookie': cookie,
|
138
|
+
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
139
|
+
}
|
140
|
+
payload = {
|
141
|
+
"scene": "bot_chat",
|
142
|
+
"data_type": "image"
|
143
|
+
}
|
144
|
+
|
145
|
+
async with httpx.AsyncClient() as client:
|
146
|
+
response = await client.post(url, headers=headers, json=payload)
|
147
|
+
response.raise_for_status()
|
148
|
+
|
149
|
+
return response.json()
|
150
|
+
|
151
|
+
|
152
|
+
def hmac_hash256(key, msg):
|
153
|
+
if type(key) == str:
|
154
|
+
return hmac.new(key.encode('utf-8'), msg.encode('utf-8'), hashlib.sha256)
|
155
|
+
elif type(key) == hmac.HMAC:
|
156
|
+
return hmac.new(key.digest(), msg.encode('utf-8'), hashlib.sha256)
|
157
|
+
|
158
|
+
|
159
|
+
def get_signing_key(secret_access_key, r="cn-north-1", n="imagex"):
|
160
|
+
dt = str(datetime.datetime.now())[:10].replace('-', '')
|
161
|
+
o = hmac_hash256("AWS4" + secret_access_key, dt)
|
162
|
+
i = hmac_hash256(o, str(r))
|
163
|
+
s = hmac_hash256(i, str(n))
|
164
|
+
return hmac_hash256(s, "aws4_request")
|
165
|
+
|
166
|
+
def signature(secret_access_key):
|
167
|
+
r = get_signing_key(secret_access_key)
|
168
|
+
return hmac_hash256(r, self.stringToSign()).hexdigest()
|
169
|
+
|
170
|
+
# ccd4fef2cca1a114e776badad7f4b6e73f305a4dbb09e68f336759ddb6ac0025
|
171
|
+
|
172
|
+
if __name__ == '__main__':
|
173
|
+
# generate_cookie("")
|
174
|
+
|
175
|
+
# arun(get_upload_token())
|
176
|
+
|
177
|
+
print(get_signing_key('xW9YbDhTlWsXdaN7O2g1lfcyePxf5kJyg/r2mwSZG/iuSmbvVgToO6LVCLmUjVJ3'))
|
@@ -7,13 +7,16 @@
|
|
7
7
|
# @WeChat : meutils
|
8
8
|
# @Software : PyCharm
|
9
9
|
# @Description :
|
10
|
+
import asyncio
|
10
11
|
|
11
12
|
from meutils.pipe import *
|
12
13
|
from meutils.caches.redis_cache import cache
|
14
|
+
from meutils.io.files_utils import to_url, to_url_fal
|
13
15
|
from meutils.llm.check_utils import check_token_for_siliconflow
|
14
16
|
from meutils.schemas.task_types import TaskResponse
|
15
17
|
from meutils.schemas.siliconflow_types import BASE_URL, VideoRequest
|
16
18
|
from meutils.config_utils.lark_utils import get_next_token_for_polling
|
19
|
+
from meutils.apis.translator import deeplx
|
17
20
|
|
18
21
|
from openai import OpenAI, AsyncOpenAI
|
19
22
|
|
@@ -21,38 +24,54 @@ FEISHU_URL_FREE = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf
|
|
21
24
|
|
22
25
|
check_token = partial(check_token_for_siliconflow, threshold=0.01)
|
23
26
|
|
27
|
+
MODELS_MAP = {
|
28
|
+
"hunyuan-video": "tencent/HunyuanVideo",
|
29
|
+
"hunyuanvideo": "tencent/HunyuanVideo",
|
30
|
+
"mochi-1-preview": "genmo/mochi-1-preview",
|
31
|
+
"ltx-video": "Lightricks/LTX-Video",
|
32
|
+
}
|
33
|
+
|
24
34
|
|
25
35
|
@cache(ttl=7 * 24 * 3600)
|
26
36
|
async def create_task(request: VideoRequest, token: Optional[str] = None):
|
27
37
|
token = token or await get_next_token_for_polling(FEISHU_URL_FREE, check_token=check_token, from_redis=True)
|
28
38
|
|
29
39
|
payload = request.model_dump(exclude_none=True)
|
30
|
-
payload["model"] = "
|
40
|
+
payload["model"] = MODELS_MAP.get(request.model, "Lightricks/LTX-Video")
|
41
|
+
|
42
|
+
if payload["model"] in {"genmo/mochi-1-preview", "Lightricks/LTX-Video"}: # 中文不友好
|
43
|
+
payload['prompt'] = (
|
44
|
+
await deeplx.translate(deeplx.DeeplxRequest(text=request.prompt, target_lang="EN"))).get("data")
|
31
45
|
|
32
|
-
client =
|
46
|
+
client = AsyncOpenAI(
|
33
47
|
base_url=BASE_URL,
|
34
48
|
api_key=token
|
35
49
|
)
|
36
50
|
|
37
|
-
response = client.post("/video/submit",
|
51
|
+
response = await client.post("/video/submit", body=payload, cast_to=object)
|
38
52
|
logger.debug(response)
|
39
|
-
task_id = response.get('requestId')
|
40
53
|
|
54
|
+
task_id = response.get('requestId')
|
41
55
|
return TaskResponse(task_id=task_id, system_fingerprint=token)
|
42
56
|
|
43
57
|
|
44
58
|
async def get_task(task_id, token: str):
|
45
|
-
client =
|
59
|
+
client = AsyncOpenAI(
|
46
60
|
base_url=BASE_URL,
|
47
61
|
api_key=token
|
48
62
|
)
|
49
63
|
payload = {"requestId": task_id}
|
50
|
-
response = client.post(f"/video/status", cast_to=object, body=payload)
|
64
|
+
response = await client.post(f"/video/status", cast_to=object, body=payload)
|
51
65
|
logger.debug(response)
|
52
66
|
|
67
|
+
data = response.get("results") or {}
|
68
|
+
|
69
|
+
for video in data.get("videos", []):
|
70
|
+
video["url"] = await to_url_fal(video.get("url")) # 异步执行
|
71
|
+
|
53
72
|
return TaskResponse(
|
54
73
|
task_id=task_id,
|
55
|
-
data=
|
74
|
+
data=data,
|
56
75
|
status=response.get("status"),
|
57
76
|
message=response.get("reason"),
|
58
77
|
)
|
@@ -60,12 +79,22 @@ async def get_task(task_id, token: str):
|
|
60
79
|
|
61
80
|
if __name__ == '__main__':
|
62
81
|
token = None
|
82
|
+
token = "sk-raapiguffsnsxgkfiwfusjmbpcyqoxhcohhxaybflrnvpqjw"
|
83
|
+
|
84
|
+
request = VideoRequest(
|
85
|
+
model="Lightricks/LTX-Video",
|
86
|
+
prompt="这个女人笑起来",
|
87
|
+
image='https://oss.ffire.cc/files/kling_watermark.png' # 1148f2e4-0a62-4208-84de-0bf2c88f740d
|
88
|
+
)
|
63
89
|
# tokens = config_manager.text.split()
|
64
90
|
|
65
91
|
# tokens_ = arun(check_token_for_siliconflow(tokens, threshold=0.01))
|
66
92
|
|
67
|
-
token
|
68
|
-
|
93
|
+
# arun(create_task(request, token=token))
|
94
|
+
|
95
|
+
# arun(get_task("fa248aac-00ec-4b00-a2f8-3d6bf1cea6d3", token))
|
96
|
+
# arun(get_task("c716a328-438e-4612-aff2-a669034499cb", token))
|
97
|
+
arun(get_task("1148f2e4-0a62-4208-84de-0bf2c88f740d", token))
|
69
98
|
|
70
99
|
# token = "sk-oeptckzkhfzeidbtsqvbrvyrfdtyaaehubfwsxjytszbgohd"
|
71
100
|
# arun(get_task("5ea22f57-45f0-425c-9d1e-bf3dae7e1e81", token))
|
meutils/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2024.12.
|
1
|
+
2024.12.19.11.21.54
|
meutils/data/oneapi/NOTICE.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
---
|
4
4
|
<details markdown="1">
|
5
|
-
<summary><b
|
5
|
+
<summary><b>🔥业务经营范围</b></summary>
|
6
6
|
|
7
7
|
- api服务(没有的找企微客服增加)
|
8
8
|
- 提供主流大模型服务,gpt/claude/gemini/llama/国产大模型等等
|
@@ -31,6 +31,10 @@
|
|
31
31
|
|
32
32
|
</details>
|
33
33
|
|
34
|
+
## 2024-12-13
|
35
|
+
- 新增模型 混元视频(支持高并发,非逆向可商用,限时特价1毛)[接口文档](https://api.chatfire.cn/docs/api-244309840)
|
36
|
+
HunyuanVideo 是腾讯推出的开源视频生成基础模型,拥有超过 130 亿参数,是目前最大的开源视频生成模型。该模型采用统一的图像和视频生成架构,集成了数据整理、图像-视频联合模型训练和高效基础设施等关键技术。模型使用多模态大语言模型作为文本编码器,通过 3D VAE 进行空间-时间压缩,并提供提示词重写功能。根据专业人工评估结果,HunyuanVideo 在文本对齐、运动质量和视觉质量等方面的表现优于现有最先进的模型
|
37
|
+
|
34
38
|
## 2024-12-09
|
35
39
|
- 新增模型
|
36
40
|
- meta-llama/Llama-3.3-70B-Instruct: Llama 3.3 是 Llama 系列最先进的多语言开源大型语言模型,以极低成本体验媲美 405B 模型的性能。基于 Transformer 结构,并通过监督微调(SFT)和人类反馈强化学习(RLHF)提升有用性和安全性。其指令调优版本专为多语言对话优化,在多项行业基准上表现优于众多开源和封闭聊天模型。知识截止日期为 2023 年 12 月。
|
@@ -43,6 +47,13 @@
|
|
43
47
|
- o1-pro: (官网 200刀 plus 版本 `逆向工程`,有思考过程显示)o1-pro 是OpenAI针对复杂任务的新推理模型,该任务需要广泛的常识。该模型具有 200k 上下文,目前全球最强模型,支持图片识别
|
44
48
|
|
45
49
|
|
50
|
+
|
51
|
+
|
52
|
+
---
|
53
|
+
|
54
|
+
<details markdown="1">
|
55
|
+
<summary><b>历史更新</b></summary>
|
56
|
+
|
46
57
|
## 2024-12-05
|
47
58
|
- 新增模型gpt-4-plus/gpt-4o-plus按倍率计算
|
48
59
|
> OpenAI-plus会员 逆向工程
|
@@ -59,32 +70,4 @@
|
|
59
70
|
|
60
71
|
|
61
72
|
|
62
|
-
---
|
63
|
-
|
64
|
-
<details markdown="1">
|
65
|
-
<summary><b>历史更新</b></summary>
|
66
|
-
## 2024-11-20
|
67
|
-
|
68
|
-
### 支持ReplicateAPI,兼容goamz系统
|
69
|
-
|
70
|
-
- [支持的模型列表](https://api.chatfire.cn/docs/doc-5518412)
|
71
|
-
|
72
|
-
| 模型 | 每张图片单价 |
|
73
|
-
|------------------------------------------|----------------|
|
74
|
-
| black-forest-labs/flux-1.1-pro | $0.040 |
|
75
|
-
| black-forest-labs/flux-1.1-pro-ultra | $0.060 |
|
76
|
-
| black-forest-labs/flux-dev | $0.025 |
|
77
|
-
| black-forest-labs/flux-pro | $0.055 |
|
78
|
-
| black-forest-labs/flux-schnell | $0.003 |
|
79
|
-
| ideogram-ai/ideogram-v2 | $0.080 |
|
80
|
-
| ideogram-ai/ideogram-v2-turbo | $0.050 |
|
81
|
-
| recraft-ai/recraft-v3 | $0.040 |
|
82
|
-
| recraft-ai/recraft-v3-svg | $0.080 |
|
83
|
-
| stability-ai/stable-diffusion-3 | $0.035 |
|
84
|
-
| stability-ai/stable-diffusion-3.5-large | $0.065 |
|
85
|
-
| stability-ai/stable-diffusion-3.5-large-turbo | $0.040 |
|
86
|
-
| stability-ai/stable-diffusion-3.5-medium | $0.035 |
|
87
|
-
|
88
|
-
- [接口文档](https://api.chatfire.cn/docs/api-235361039)
|
89
|
-
|
90
73
|
</details>
|
meutils/io/files_utils.py
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
import mimetypes
|
12
12
|
from meutils.pipe import *
|
13
13
|
from meutils.decorators.retry import retrying
|
14
|
+
from meutils.caches.redis_cache import cache
|
15
|
+
|
14
16
|
# from fastapi import UploadFile 有点区别
|
15
17
|
from starlette.datastructures import UploadFile
|
16
18
|
from contextlib import asynccontextmanager
|
@@ -85,6 +87,33 @@ async def to_tempfile(file: Union[UploadFile, str]):
|
|
85
87
|
yield temp.name
|
86
88
|
|
87
89
|
|
90
|
+
@cache(ttl=7 * 24 * 3600)
|
91
|
+
async def to_url_fal(
|
92
|
+
file: Union[str, bytes],
|
93
|
+
filename: Optional[str] = None,
|
94
|
+
headers: Optional[dict] = None,
|
95
|
+
content_type: str = "application/octet-stream",
|
96
|
+
):
|
97
|
+
"""对象存储"""
|
98
|
+
if not file: return
|
99
|
+
|
100
|
+
if file.startswith("http"): # 转存: todo: base64
|
101
|
+
content_type = mimetypes.guess_type(file)[0] or content_type
|
102
|
+
|
103
|
+
file = await to_bytes(file, headers=headers)
|
104
|
+
|
105
|
+
content_type = (
|
106
|
+
mimetypes.guess_type(filename or '')[0]
|
107
|
+
or mimetypes.guess_type(f"x.{content_type}")[0] # format: image/png
|
108
|
+
or content_type
|
109
|
+
)
|
110
|
+
|
111
|
+
import fal_client
|
112
|
+
|
113
|
+
url = await fal_client.upload_async(data=file, content_type=content_type, file_name=filename)
|
114
|
+
return url
|
115
|
+
|
116
|
+
|
88
117
|
async def to_url(
|
89
118
|
file: Union[UploadFile, str, bytes],
|
90
119
|
filename: Optional[str] = None,
|
@@ -179,12 +208,14 @@ if __name__ == '__main__':
|
|
179
208
|
|
180
209
|
# arun(to_url(file, content_type=None))
|
181
210
|
|
182
|
-
print(mimetypes.guess_type("x.jpg"))
|
211
|
+
# print(mimetypes.guess_type("x.jpg"))
|
183
212
|
# print(mimetypes.guess_type("x.png"))
|
184
|
-
print(mimetypes.guess_type("x"))
|
213
|
+
# print(mimetypes.guess_type("x.jpg"))
|
185
214
|
|
186
|
-
print(mimetypes.guess_extension("x.mp4", False))
|
215
|
+
# print(mimetypes.guess_extension("x.mp4", False))
|
187
216
|
|
188
217
|
# arun(to_url(
|
189
218
|
# "https://cdn.hailuoai.video/moss/prod/2024-11-11-09/video/1731287464150180347-video_raw_8ba15c5c206f8d393a9248f4f9215ed8_312186282087260162.mp4",
|
190
219
|
# content_type=None))
|
220
|
+
|
221
|
+
arun(to_url_fal(url))
|
meutils/llm/mappers.py
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : mappers
|
5
|
+
# @Time : 2024/12/16 14:49
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
from meutils.pipe import *
|
12
|
+
|
13
|
+
|
14
|
+
def llm_mapper(model):
|
15
|
+
return
|
meutils/office_automation/pdf.py
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : jimeng_types
|
5
|
+
# @Time : 2024/12/16 18:20
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
import uuid
|
11
|
+
|
12
|
+
from meutils.pipe import *
|
13
|
+
|
14
|
+
BASE_URL = "https://jimeng.jianying.com"
|
15
|
+
FEISHU_URL = "https://xchatllm.feishu.cn/sheets/GYCHsvI4qhnDPNtI4VPcdw2knEd?sheet=zkPAHw"
|
16
|
+
|
17
|
+
MODELS_MAP = {
|
18
|
+
"jimeng-2.1": "high_aes_general_v21_L:general_v2.1_L",
|
19
|
+
|
20
|
+
"jimeng-2.0-pro": "high_aes_general_v20_L:general_v2.0_L",
|
21
|
+
"high_aes_general_v20_L:general_v2.0_L": "high_aes_general_v20_L:general_v2.0_L",
|
22
|
+
|
23
|
+
"jimeng-2.0": "high_aes_general_v20:general_v2.0",
|
24
|
+
"jimeng-1.4": "high_aes_general_v14:general_v1.4",
|
25
|
+
"jimeng-xl-pro": "text2img_xl_sft",
|
26
|
+
|
27
|
+
"default": "high_aes_general_v21_L:general_v2.1_L",
|
28
|
+
}
|
meutils/schemas/oneapi/common.py
CHANGED
@@ -63,6 +63,10 @@ MODEL_PRICE = {
|
|
63
63
|
"api-images-flux.1.1-pro": 0.1,
|
64
64
|
"api-images-recraftv3": 0.03,
|
65
65
|
|
66
|
+
"api-images-seededit": 0.1,
|
67
|
+
"seededit": 0.1,
|
68
|
+
"chat-seededit": 0.1,
|
69
|
+
|
66
70
|
"api-tripo3d": 0.1,
|
67
71
|
|
68
72
|
# 图片 音频 视频
|
@@ -83,6 +87,8 @@ MODEL_PRICE = {
|
|
83
87
|
|
84
88
|
"ideogram": 0.3,
|
85
89
|
|
90
|
+
"api-hunyuan-video": 0.1,
|
91
|
+
|
86
92
|
# replicate
|
87
93
|
"api-replicate-flux-1.1-pro": 0.040,
|
88
94
|
"api-replicate-flux-1.1-pro-ultra": 0.060,
|
@@ -197,7 +203,12 @@ MODEL_PRICE = {
|
|
197
203
|
"cogview-3-plus": 0.02,
|
198
204
|
|
199
205
|
"glm-4-all": 0.01,
|
206
|
+
|
200
207
|
"kimi-all": 0.01,
|
208
|
+
"kimi-math": 0.01,
|
209
|
+
"kimi-k1": 0.05,
|
210
|
+
"kimi-search": 0.01,
|
211
|
+
"kimi-research": 0.05,
|
201
212
|
|
202
213
|
"spark-all": 0.01,
|
203
214
|
"step-1-all": 0.01,
|
@@ -293,6 +304,7 @@ MODEL_RATIO = {
|
|
293
304
|
"glm-4v": 2.5,
|
294
305
|
"glm-4v-plus": 1, # 2.5
|
295
306
|
"glm-4v-flash": 0.1,
|
307
|
+
"glm-4-plus": 25,
|
296
308
|
|
297
309
|
# 月之暗面 https://platform.moonshot.cn/docs/price/chat#%E4%BA%A7%E5%93%81%E5%AE%9A%E4%BB%B7
|
298
310
|
"moonshot-v1-8k": 6 / 2, # 特价
|
@@ -500,6 +512,7 @@ MODEL_RATIO = {
|
|
500
512
|
"gpt-4o-2024-08-06": 1.25,
|
501
513
|
"gpt-4o-2024-11-20": 1.25,
|
502
514
|
|
515
|
+
"o1": 7.5,
|
503
516
|
"o1-mini": 1.5,
|
504
517
|
"o1-preview": 7.5,
|
505
518
|
"o1-mini-2024-09-12": 1.5,
|
meutils/schemas/task_types.py
CHANGED
@@ -63,7 +63,7 @@ class TaskResponse(BaseModel):
|
|
63
63
|
|
64
64
|
def __init__(self, /, **data: Any):
|
65
65
|
super().__init__(**data)
|
66
|
-
self.status = STATUSES.get(self.status.lower(), "UNKNOWN")
|
66
|
+
self.status = STATUSES.get((self.status or '').lower(), "UNKNOWN")
|
67
67
|
|
68
68
|
class Config:
|
69
69
|
# 允许额外字段,增加灵活性
|
File without changes
|
File without changes
|
{MeUtils-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/entry_points.txt
RENAMED
File without changes
|
{MeUtils-2024.12.13.15.39.7.dist-info → MeUtils-2024.12.19.11.21.54.dist-info}/top_level.txt
RENAMED
File without changes
|