MeUtils 2025.1.29.10.0.47__py3-none-any.whl → 2025.2.6.13.5.49__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.1.29.10.0.47.dist-info → MeUtils-2025.2.6.13.5.49.dist-info}/METADATA +28 -28
- {MeUtils-2025.1.29.10.0.47.dist-info → MeUtils-2025.2.6.13.5.49.dist-info}/RECORD +36 -28
- examples/_openaisdk/openai_baichuan.py +2 -2
- examples/_openaisdk/openai_baidu.py +61 -0
- examples/_openaisdk/openai_chatfire.py +24 -13
- examples/_openaisdk/openai_dashscope.py +32 -0
- examples/_openaisdk/openai_deepseek.py +53 -3
- examples/_openaisdk/openai_ep.py +29 -0
- examples/_openaisdk/openai_gitee.py +23 -9
- examples/_openaisdk/openai_images.py +12 -9
- examples/_openaisdk/openai_luchentech.py +60 -0
- examples/_openaisdk/openai_moderations.py +56 -0
- examples/_openaisdk/openai_siliconflow.py +5 -4
- examples/xxx.py +0 -0
- meutils/apis/chatglm/glm_video_api.py +4 -2
- meutils/apis/hailuoai/videos.py +18 -37
- meutils/apis/images/recraft.py +10 -5
- meutils/apis/jimeng/images.py +21 -8
- meutils/apis/search/metaso.py +34 -3
- meutils/apis/vidu/vidu_video.py +1 -1
- meutils/caches/acache.py +32 -11
- meutils/caches/demo.py +28 -0
- meutils/data/VERSION +1 -1
- meutils/data/oneapi/NOTICE.md +3 -17
- meutils/llm/clients.py +3 -0
- meutils/llm/completions/agents/search.py +28 -6
- meutils/llm/completions/qwenllm.py +12 -3
- meutils/llm/completions/reasoner.py +87 -0
- meutils/llm/openai_utils/common.py +2 -0
- meutils/schemas/metaso_types.py +7 -1
- meutils/schemas/oneapi/common.py +38 -7
- meutils/schemas/vidu_types.py +1 -1
- {MeUtils-2025.1.29.10.0.47.dist-info → MeUtils-2025.2.6.13.5.49.dist-info}/LICENSE +0 -0
- {MeUtils-2025.1.29.10.0.47.dist-info → MeUtils-2025.2.6.13.5.49.dist-info}/WHEEL +0 -0
- {MeUtils-2025.1.29.10.0.47.dist-info → MeUtils-2025.2.6.13.5.49.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.1.29.10.0.47.dist-info → MeUtils-2025.2.6.13.5.49.dist-info}/top_level.txt +0 -0
meutils/llm/clients.py
CHANGED
@@ -14,6 +14,9 @@ from meutils.pipe import *
|
|
14
14
|
OpenAI = lru_cache(Client)
|
15
15
|
AsyncOpenAI = lru_cache(AsyncClient)
|
16
16
|
|
17
|
+
|
18
|
+
chatfire_client = AsyncOpenAI()
|
19
|
+
|
17
20
|
moonshot_client = AsyncOpenAI(
|
18
21
|
api_key=os.getenv("MOONSHOT_API_KEY"),
|
19
22
|
base_url=os.getenv("MOONSHOT_BASE_URL")
|
@@ -9,7 +9,7 @@
|
|
9
9
|
# @Description : todo: 格式匹配
|
10
10
|
|
11
11
|
from meutils.pipe import *
|
12
|
-
from meutils.llm.clients import AsyncOpenAI, zhipuai_client, moonshot_client
|
12
|
+
from meutils.llm.clients import AsyncOpenAI, chatfire_client, zhipuai_client, moonshot_client
|
13
13
|
from meutils.llm.openai_utils import to_openai_params
|
14
14
|
from meutils.schemas.openai_types import chat_completion, chat_completion_chunk, ChatCompletionRequest, CompletionUsage
|
15
15
|
|
@@ -90,18 +90,33 @@ class Completions(object):
|
|
90
90
|
completion = await client.chat.completions.create(**data)
|
91
91
|
return completion
|
92
92
|
|
93
|
-
else:
|
94
|
-
|
93
|
+
else:
|
94
|
+
# 搜索
|
95
95
|
data = to_openai_params(request)
|
96
|
-
|
97
|
-
|
96
|
+
data['model'] = "web-search-pro"
|
97
|
+
data['stream'] = False
|
98
|
+
search_completion = await zhipuai_client.chat.completions.create(**data)
|
99
|
+
logger.debug(search_completion)
|
100
|
+
|
101
|
+
# 大模型
|
102
|
+
request.messages.append({
|
103
|
+
"role": "user",
|
104
|
+
"content": search_completion.model_dump_json(indent=4),
|
105
|
+
})
|
106
|
+
|
107
|
+
data = to_openai_params(request)
|
108
|
+
|
109
|
+
completion = await chatfire_client.chat.completions.create(**data)
|
98
110
|
return completion
|
99
111
|
|
100
112
|
|
101
113
|
if __name__ == '__main__':
|
102
114
|
request = ChatCompletionRequest(
|
103
115
|
# model="baichuan4-turbo",
|
104
|
-
model="xx",
|
116
|
+
# model="xx",
|
117
|
+
# model="deepseek-r1",
|
118
|
+
model="deepseek-r1:1.5b",
|
119
|
+
|
105
120
|
# model="moonshot-v1-8k",
|
106
121
|
# model="doubao",
|
107
122
|
|
@@ -113,3 +128,10 @@ if __name__ == '__main__':
|
|
113
128
|
)
|
114
129
|
|
115
130
|
arun(Completions().create(request))
|
131
|
+
|
132
|
+
# async def test():
|
133
|
+
# for i in await Completions().create(request):
|
134
|
+
# print(i)
|
135
|
+
#
|
136
|
+
#
|
137
|
+
# arun(test())
|
@@ -8,8 +8,9 @@
|
|
8
8
|
# @Software : PyCharm
|
9
9
|
# @Description :
|
10
10
|
|
11
|
+
from openai import AsyncOpenAI
|
12
|
+
|
11
13
|
from meutils.pipe import *
|
12
|
-
from meutils.llm.clients import AsyncOpenAI
|
13
14
|
from meutils.llm.openai_utils import to_openai_params
|
14
15
|
|
15
16
|
from meutils.config_utils.lark_utils import get_next_token_for_polling
|
@@ -19,11 +20,18 @@ FEISHU_URL = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?shee
|
|
19
20
|
|
20
21
|
base_url = "https://chat.qwenlm.ai/api"
|
21
22
|
|
23
|
+
from fake_useragent import UserAgent
|
24
|
+
|
25
|
+
ua = UserAgent()
|
26
|
+
|
22
27
|
|
23
28
|
async def create(request: ChatCompletionRequest):
|
24
29
|
token = await get_next_token_for_polling(feishu_url=FEISHU_URL)
|
25
30
|
|
26
|
-
client = AsyncOpenAI(
|
31
|
+
client = AsyncOpenAI(
|
32
|
+
base_url=base_url, api_key=token,
|
33
|
+
default_headers={'User-Agent': ua.random}
|
34
|
+
)
|
27
35
|
data = to_openai_params(request)
|
28
36
|
|
29
37
|
if request.stream:
|
@@ -35,6 +43,7 @@ async def create(request: ChatCompletionRequest):
|
|
35
43
|
|
36
44
|
else:
|
37
45
|
response = await client.chat.completions.create(**data)
|
46
|
+
# logger.info(response)
|
38
47
|
yield response.choices[0].message.content
|
39
48
|
|
40
49
|
|
@@ -51,7 +60,7 @@ if __name__ == '__main__':
|
|
51
60
|
# ]
|
52
61
|
request = ChatCompletionRequest(
|
53
62
|
# model="qwen-turbo-2024-11-01",
|
54
|
-
model="qwen-
|
63
|
+
model="qwen-max-latest",
|
55
64
|
# model="qwen-plus-latest",
|
56
65
|
|
57
66
|
messages=[
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : reasoner
|
5
|
+
# @Time : 2025/2/6 08:35
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
|
12
|
+
from openai import AsyncOpenAI
|
13
|
+
|
14
|
+
from meutils.pipe import *
|
15
|
+
from meutils.llm.clients import chatfire_client, AsyncOpenAI
|
16
|
+
from meutils.llm.openai_utils import to_openai_params
|
17
|
+
|
18
|
+
from meutils.schemas.openai_types import chat_completion, chat_completion_chunk, ChatCompletionRequest, CompletionUsage
|
19
|
+
|
20
|
+
|
21
|
+
class Completions(object):
|
22
|
+
|
23
|
+
def __init__(self, api_key: Optional[str] = None, base_url: Optional[str] = None):
|
24
|
+
self.api_key = api_key
|
25
|
+
self.base_url = base_url
|
26
|
+
|
27
|
+
self.client = AsyncOpenAI(
|
28
|
+
base_url=self.base_url, api_key=self.api_key,
|
29
|
+
)
|
30
|
+
|
31
|
+
async def create(self, request: ChatCompletionRequest):
|
32
|
+
data = to_openai_params(request)
|
33
|
+
|
34
|
+
if request.stream:
|
35
|
+
_chunk = ""
|
36
|
+
async for chunk in await self.client.chat.completions.create(**data):
|
37
|
+
delta = chunk.choices[0].delta
|
38
|
+
|
39
|
+
reasoning_content = "> Reasoning\n" # "> Reasoning\n" # 前缀 "> 思考中\n"
|
40
|
+
if hasattr(delta, 'reasoning_content'):
|
41
|
+
if reasoning_content:
|
42
|
+
reasoning_content += delta.reasoning_content
|
43
|
+
yield reasoning_content
|
44
|
+
reasoning_content = ''
|
45
|
+
else:
|
46
|
+
yield '\n'
|
47
|
+
|
48
|
+
yield delta.content
|
49
|
+
|
50
|
+
else:
|
51
|
+
completions = await self.client.chat.completions.create(**data)
|
52
|
+
yield completions
|
53
|
+
|
54
|
+
|
55
|
+
if __name__ == '__main__':
|
56
|
+
# [
|
57
|
+
# "qwen-plus-latest",
|
58
|
+
# "qvq-72b-preview",
|
59
|
+
# "qwq-32b-preview",
|
60
|
+
# "qwen2.5-coder-32b-instruct",
|
61
|
+
# "qwen-vl-max-latest",
|
62
|
+
# "qwen-turbo-latest",
|
63
|
+
# "qwen2.5-72b-instruct",
|
64
|
+
# "qwen2.5-32b-instruct"
|
65
|
+
# ]
|
66
|
+
request = ChatCompletionRequest(
|
67
|
+
# model="qwen-turbo-2024-11-01",
|
68
|
+
# model="qwen-max-latest",
|
69
|
+
# model="qwen-plus-latest",
|
70
|
+
|
71
|
+
model="deepseek-r1:1.5b",
|
72
|
+
# model="deepseek-r1",
|
73
|
+
|
74
|
+
messages=[
|
75
|
+
{
|
76
|
+
'role': 'system',
|
77
|
+
'content': '每次回答前务必思考之后m,回答问题'
|
78
|
+
},
|
79
|
+
{
|
80
|
+
'role': 'user',
|
81
|
+
'content': '你好'
|
82
|
+
},
|
83
|
+
|
84
|
+
],
|
85
|
+
stream=True,
|
86
|
+
)
|
87
|
+
arun(Completions().create(request))
|
meutils/schemas/metaso_types.py
CHANGED
@@ -15,11 +15,13 @@ FEISHU_URL = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?shee
|
|
15
15
|
|
16
16
|
|
17
17
|
class MetasoRequest(BaseModel):
|
18
|
-
|
18
|
+
model: Optional[Literal["ds-r1",]] = None
|
19
19
|
|
20
20
|
"""search-mini search search-pro"""
|
21
21
|
mode: Literal["concise", "detail", "research"] = "detail" # concise detail research
|
22
22
|
|
23
|
+
question: str = "Chatfire"
|
24
|
+
|
23
25
|
"""全网 文库 学术 图片 播客"""
|
24
26
|
engineType: str = "" # scholar
|
25
27
|
|
@@ -28,6 +30,10 @@ class MetasoRequest(BaseModel):
|
|
28
30
|
searchTopicId: Optional[str] = None
|
29
31
|
searchTopicName: Optional[str] = None
|
30
32
|
|
33
|
+
enableMix: bool = True
|
34
|
+
newEngine: bool = True
|
35
|
+
enableImage: bool = True
|
36
|
+
|
31
37
|
# 自定义字段
|
32
38
|
response_format: Optional[str] = None # 原生内容
|
33
39
|
|
meutils/schemas/oneapi/common.py
CHANGED
@@ -61,7 +61,7 @@ MODEL_PRICE = {
|
|
61
61
|
|
62
62
|
"official-api-vidu": 0.5,
|
63
63
|
|
64
|
-
"official-api-hailuo-video": 0.
|
64
|
+
"official-api-hailuo-video": 0.5,
|
65
65
|
"api-hailuo-video": 0.3,
|
66
66
|
|
67
67
|
# delle3
|
@@ -107,6 +107,8 @@ MODEL_PRICE = {
|
|
107
107
|
|
108
108
|
"api-hunyuan-video": 0.1,
|
109
109
|
|
110
|
+
"deepseek-ai/Janus-Pro-7B": 0.01,
|
111
|
+
|
110
112
|
# replicate
|
111
113
|
"api-replicate-flux-1.1-pro": 0.040,
|
112
114
|
"api-replicate-flux-1.1-pro-ultra": 0.060,
|
@@ -215,6 +217,9 @@ MODEL_PRICE = {
|
|
215
217
|
"o1-mini-all": 0.2,
|
216
218
|
"o1-preview-all": 0.6,
|
217
219
|
|
220
|
+
"o3-mini": 0.05,
|
221
|
+
"o3-mini-high": 0.1,
|
222
|
+
|
218
223
|
"gpt-4-all": 0.1,
|
219
224
|
"gpt-4o-all": 0.1,
|
220
225
|
|
@@ -377,16 +382,17 @@ MODEL_RATIO = {
|
|
377
382
|
"qwen-max": 10,
|
378
383
|
"qwen-max-longcontext": 20,
|
379
384
|
"qwen-turbo-2024-11-01": 0.15,
|
385
|
+
"qwen-max-latest":0.01,
|
380
386
|
|
381
387
|
"qwen-vl-max-latest": 1.5,
|
382
388
|
"qwen-vl-plus-latest": 0.75,
|
383
389
|
|
384
390
|
"qwen2.5-coder-7b-instruct": 0.05,
|
385
391
|
"qwen2.5-7b-instruct": 0.05,
|
386
|
-
"qwen2.5-14b-instruct": 0.
|
387
|
-
"qwen2.5-32b-instruct":
|
388
|
-
"qwen2.5-72b-instruct":
|
389
|
-
"qwen2.5-math-72b-instruct":
|
392
|
+
"qwen2.5-14b-instruct": 0.25,
|
393
|
+
"qwen2.5-32b-instruct": 0.5,
|
394
|
+
"qwen2.5-72b-instruct": 2,
|
395
|
+
"qwen2.5-math-72b-instruct": 2,
|
390
396
|
"qwen2.5-coder-32b-instruct": 0.5,
|
391
397
|
"qwen/qwq-32b-preview": 1,
|
392
398
|
"Qwen/QwQ-32B-Preview": 1,
|
@@ -455,7 +461,12 @@ MODEL_RATIO = {
|
|
455
461
|
|
456
462
|
# deepseek
|
457
463
|
"deepseek-chat": 0.5,
|
464
|
+
"deepseek-vl2": 0.5,
|
465
|
+
|
458
466
|
"deepseek-ai/deepseek-vl2": 0.5,
|
467
|
+
"deepseek-llm-67b-chat": 0.5,
|
468
|
+
|
469
|
+
"deepseek-chat:function": 4,
|
459
470
|
|
460
471
|
"deepseek-v3": 0.5,
|
461
472
|
"deepseek/deepseek-chat": 0.5,
|
@@ -464,10 +475,14 @@ MODEL_RATIO = {
|
|
464
475
|
|
465
476
|
"deepseek-r1:1.5b": 0.1,
|
466
477
|
"deepseek-r1:7b": 0.2,
|
478
|
+
"deepseek-r1:14b": 0.5,
|
479
|
+
"deepseek-r1:32b": 1,
|
467
480
|
'deepseek-r1': 2,
|
468
481
|
'deepseek-reasoner': 2,
|
469
482
|
'deepseek-think': 0.5,
|
470
483
|
"deepseek-search": 0.5,
|
484
|
+
"deepseek-chat-64k": 5,
|
485
|
+
"deepseek-v3-128k": 5,
|
471
486
|
|
472
487
|
# 豆包
|
473
488
|
"doubao-lite-128k": 0.4,
|
@@ -618,6 +633,7 @@ MODEL_RATIO = {
|
|
618
633
|
"o1-preview": 7.5,
|
619
634
|
"o1-mini-2024-09-12": 1.5,
|
620
635
|
"o1-preview-2024-09-12": 7.5,
|
636
|
+
"o3-mini": 0.55,
|
621
637
|
|
622
638
|
# 硅基
|
623
639
|
"llama-3.1-8b-instruct": 0.01,
|
@@ -684,10 +700,13 @@ COMPLETION_RATIO = {
|
|
684
700
|
"gpt-4-all": 4,
|
685
701
|
"gpt-4-gizmo-*": 4,
|
686
702
|
"gpt-4o-all": 4,
|
703
|
+
|
687
704
|
"o1-mini": 4,
|
688
705
|
"o1-preview": 4,
|
689
706
|
"o1-mini-2024-09-12": 4,
|
690
707
|
"o1-preview-2024-09-12": 4,
|
708
|
+
"o3-mini": 4,
|
709
|
+
|
691
710
|
"gpt-4o-realtime-preview": 4,
|
692
711
|
"gpt-4o-realtime-preview-2024-10-01": 4,
|
693
712
|
"gpt-4o-2024-11-20": 4,
|
@@ -753,8 +772,16 @@ COMPLETION_RATIO = {
|
|
753
772
|
"qwen-vl-plus-latest": 3,
|
754
773
|
"qwen2-vl-7b-instruct": 5,
|
755
774
|
"qwen2-vl-72b-instruct": 5,
|
775
|
+
"qwen-max-latest": 5,
|
776
|
+
|
777
|
+
"qwen2.5-7b-instruct": 4,
|
778
|
+
"qwen2.5-14b-instruct": 4,
|
779
|
+
"qwen2.5-32b-instruct": 4,
|
780
|
+
"qwen2.5-72b-instruct": 4,
|
781
|
+
"qwen2.5-math-72b-instruct": 4,
|
756
782
|
|
757
|
-
"deepseek-
|
783
|
+
"deepseek-vl2": 4,
|
784
|
+
"deepseek-ai/deepseek-vl2": 4,
|
758
785
|
|
759
786
|
# 豆包
|
760
787
|
"doubao-lite-128k": 3,
|
@@ -775,13 +802,17 @@ COMPLETION_RATIO = {
|
|
775
802
|
"doubao-vision-lite-32k": 3,
|
776
803
|
"doubao-vision-pro-32k": 3,
|
777
804
|
|
778
|
-
"deepseek-v3":
|
805
|
+
"deepseek-v3": 4,
|
779
806
|
"deepseek-search": 1,
|
780
807
|
'deepseek-r1': 4,
|
781
808
|
'deepseek-reasoner': 4,
|
782
809
|
"deepseek/deepseek-chat": 1,
|
783
810
|
"deepseek-ai/DeepSeek-V3": 1,
|
784
811
|
"accounts/fireworks/models/deepseek-v3": 1,
|
812
|
+
"deepseek-chat:function": 4,
|
813
|
+
"deepseek-chat-64k": 5,
|
814
|
+
"deepseek-v3-128k": 5,
|
815
|
+
"deepseek-llm-67b-chat": 4,
|
785
816
|
|
786
817
|
"glm-zero": 5,
|
787
818
|
"glm-zero-preview": 5,
|
meutils/schemas/vidu_types.py
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|