MeUtils 2025.6.20.18.7.13__py3-none-any.whl → 2025.6.24.11.13.32__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.6.20.18.7.13.dist-info → MeUtils-2025.6.24.11.13.32.dist-info}/METADATA +263 -263
- {MeUtils-2025.6.20.18.7.13.dist-info → MeUtils-2025.6.24.11.13.32.dist-info}/RECORD +23 -21
- examples/_openaisdk/openai_edits.py +48 -0
- examples/_openaisdk/openai_images.py +10 -3
- examples/_openaisdk/openai_lingyi.py +44 -10
- examples/_openaisdk/openai_siliconflow.py +3 -3
- meutils/apis/hailuoai/images.py +2 -2
- meutils/apis/hailuoai/videos.py +4 -2
- meutils/apis/oneapi/user.py +3 -3
- meutils/apis/ppio/videos.py +1 -1
- meutils/apis/utils.py +7 -6
- meutils/data/VERSION +1 -1
- meutils/llm/check_utils.py +25 -13
- meutils/llm/completions/qwenllm.py +5 -4
- meutils/llm/openai_utils/usage_utils.py +19 -0
- meutils/llm/utils.py +1 -54
- meutils/schemas/image_types.py +1 -1
- meutils/schemas/oneapi/common.py +8 -7
- meutils/serving/fastapi/dependencies/headers.py +19 -15
- {MeUtils-2025.6.20.18.7.13.dist-info → MeUtils-2025.6.24.11.13.32.dist-info}/LICENSE +0 -0
- {MeUtils-2025.6.20.18.7.13.dist-info → MeUtils-2025.6.24.11.13.32.dist-info}/WHEEL +0 -0
- {MeUtils-2025.6.20.18.7.13.dist-info → MeUtils-2025.6.24.11.13.32.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.6.20.18.7.13.dist-info → MeUtils-2025.6.24.11.13.32.dist-info}/top_level.txt +0 -0
meutils/llm/utils.py
CHANGED
@@ -17,59 +17,6 @@ from meutils.notice.feishu import send_message
|
|
17
17
|
from meutils.apis.oneapi.utils import get_user_quota
|
18
18
|
|
19
19
|
|
20
|
-
async def ppu(
|
21
|
-
model: str = 'ppu',
|
22
|
-
api_key: Optional[str] = None,
|
23
|
-
base_url: Optional[str] = None,
|
24
|
-
):
|
25
|
-
if model not in MODEL_PRICE:
|
26
|
-
send_message(f"模型未找到{model},ppu-1默认", title=__name__)
|
27
|
-
model = "ppu-1"
|
28
|
-
|
29
|
-
client = AsyncOpenAI(api_key=api_key, base_url=base_url)
|
30
|
-
r = await client.chat.completions.create(messages=[{'role': 'user', 'content': 'hi'}], model=model)
|
31
|
-
|
32
|
-
|
33
|
-
@asynccontextmanager
|
34
|
-
async def ppu_flow(
|
35
|
-
api_key: str,
|
36
|
-
base_url: Optional[str] = None,
|
37
|
-
|
38
|
-
model: str = "ppu-1", # 后计费
|
39
|
-
|
40
|
-
n: float = 1, # 计费次数
|
41
|
-
|
42
|
-
**kwargs
|
43
|
-
):
|
44
|
-
"""
|
45
|
-
查余额
|
46
|
-
失败,先扣费
|
47
|
-
成功,充足,后扣费
|
48
|
-
成功,不足,报错
|
49
|
-
"""
|
50
|
-
n = int(np.ceil(n)) # 0 不计费
|
51
|
-
|
52
|
-
if n: # 计费
|
53
|
-
try:
|
54
|
-
money = await get_user_quota(api_key)
|
55
|
-
logger.debug(f"PREPAY: USER 余额 {money}")
|
56
|
-
except Exception as e:
|
57
|
-
logger.error(e)
|
58
|
-
money = None
|
59
|
-
|
60
|
-
if money and money > MODEL_PRICE.get(model, 0.1):
|
61
|
-
yield # 先执行
|
62
|
-
|
63
|
-
# 执行计费逻辑
|
64
|
-
await asyncio.gather(*[ppu(model, api_key=api_key, base_url=base_url) for _ in range(n)])
|
65
|
-
|
66
|
-
if money is None:
|
67
|
-
yield # 后执行
|
68
|
-
|
69
|
-
else: # 不计费
|
70
|
-
yield
|
71
|
-
|
72
|
-
|
73
20
|
def oneturn2multiturn(messages, template: Optional[str] = None, ignore_system: bool = True):
|
74
21
|
"""todo: https://github.com/hiyouga/LLaMA-Factory/blob/e898fabbe3efcd8b44d0e119e7afaed4542a9f39/src/llmtuner/data/template.py#L423-L427
|
75
22
|
|
@@ -162,4 +109,4 @@ if __name__ == '__main__':
|
|
162
109
|
|
163
110
|
]
|
164
111
|
|
165
|
-
print(oneturn2multiturn(messages,ignore_system=False))
|
112
|
+
print(oneturn2multiturn(messages, ignore_system=False))
|
meutils/schemas/image_types.py
CHANGED
meutils/schemas/oneapi/common.py
CHANGED
@@ -95,6 +95,8 @@ MODEL_PRICE = {
|
|
95
95
|
|
96
96
|
# veo
|
97
97
|
"veo3": 2,
|
98
|
+
"veo3-pro": 8,
|
99
|
+
"veo3-pro-frames": 8,
|
98
100
|
"api-veo3": 2,
|
99
101
|
"api-veo3-pro": 8,
|
100
102
|
"api-veo3-pro-frames": 8,
|
@@ -102,7 +104,7 @@ MODEL_PRICE = {
|
|
102
104
|
# hailuo
|
103
105
|
"api-minimax-hailuo-01-6s": 0.5,
|
104
106
|
"api-minimax-hailuo-02-6s-768p": 1,
|
105
|
-
"api-minimax-hailuo-02-10s-768p":
|
107
|
+
"api-minimax-hailuo-02-10s-768p": 2,
|
106
108
|
"api-minimax-hailuo-02-6s-1080p": 2,
|
107
109
|
|
108
110
|
# chatfire
|
@@ -136,8 +138,7 @@ MODEL_PRICE = {
|
|
136
138
|
"ppt-islide": 0.1,
|
137
139
|
|
138
140
|
# grok
|
139
|
-
"grok-3": 0.
|
140
|
-
"grok-3-image": 0.02,
|
141
|
+
"grok-3-image": 0.1,
|
141
142
|
|
142
143
|
# 虚拟换衣fish
|
143
144
|
"api-kolors-virtual-try-on": 0.1,
|
@@ -478,10 +479,10 @@ MODEL_RATIO = {
|
|
478
479
|
"grok-2": 1,
|
479
480
|
"grok-2-1212": 1,
|
480
481
|
"grok-2-vision-1212": 1,
|
481
|
-
"grok-3":
|
482
|
-
"grok-3-deepsearch":
|
483
|
-
"grok-3-reasoner":
|
484
|
-
"grok-3-deepersearch":
|
482
|
+
"grok-3": 1.5,
|
483
|
+
"grok-3-deepsearch": 1.5,
|
484
|
+
"grok-3-reasoner": 1.5,
|
485
|
+
"grok-3-deepersearch": 1.5,
|
485
486
|
|
486
487
|
"grok-3-beta": 1.5,
|
487
488
|
"grok-3-fast-beta": 2.5,
|
@@ -13,19 +13,23 @@ from fastapi import FastAPI, Request, Depends, HTTPException
|
|
13
13
|
from typing import Dict, Optional
|
14
14
|
|
15
15
|
|
16
|
-
# 定义一个依赖函数来获取所有请求头
|
17
|
-
# def get_headers(request: Request) -> Dict[str, str]:
|
18
|
-
# return dict(request.headers)
|
19
|
-
|
20
16
|
def get_headers(request: Request):
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
dic = dict(request.headers)
|
18
|
+
_dic = {k.replace('-', '_'): v for k, v in dic.items()}
|
19
|
+
|
20
|
+
return {**dic, **_dic}
|
21
|
+
|
22
|
+
|
23
|
+
if __name__ == '__main__':
|
24
|
+
def get_headers():
|
25
|
+
d = {"upstream-base-url": 'xx'}
|
26
|
+
d = {}
|
27
|
+
dic = {}
|
28
|
+
# upstream_base_url = headers.get('upstream-base-url')
|
29
|
+
if d:
|
30
|
+
dic = {k.replace('-', '_'): v for k, v in d.items()}
|
31
|
+
|
32
|
+
return {**d, **dic}
|
33
|
+
|
34
|
+
|
35
|
+
print(get_headers())
|
File without changes
|
File without changes
|
{MeUtils-2025.6.20.18.7.13.dist-info → MeUtils-2025.6.24.11.13.32.dist-info}/entry_points.txt
RENAMED
File without changes
|
File without changes
|