MeUtils 2025.3.14.8.41.43__py3-none-any.whl → 2025.3.19.18.18.56__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.3.14.8.41.43.dist-info → MeUtils-2025.3.19.18.18.56.dist-info}/METADATA +263 -263
- {MeUtils-2025.3.14.8.41.43.dist-info → MeUtils-2025.3.19.18.18.56.dist-info}/RECORD +43 -45
- apps/xfPPT_demo.py +251 -0
- examples/_openaisdk/4v.py +11 -6
- examples/_openaisdk/openai_chatfire.py +4 -3
- examples/_openaisdk/openai_embeddings.py +25 -7
- examples/_openaisdk/openai_siliconflow.py +1 -1
- examples/_openaisdk/zhipu_/346/231/272/350/203/275/344/275/223.py +76 -13
- meutils/apis/jimeng/common.py +2 -0
- meutils/apis/jimeng/images.py +7 -7
- meutils/apis/jina/__init__.py +11 -0
- meutils/apis/jina/common.py +43 -0
- meutils/apis/oneapi/channel.py +3 -2
- meutils/apis/oneapi/user.py +1 -1
- meutils/apis/search/_web_search.py +87 -0
- meutils/apis/search/metaso.py +9 -2
- meutils/apis/search/web_search.py +132 -0
- meutils/apis/siliconflow/image_to_image.py +3 -3
- meutils/apis/siliconflow/images.py +4 -2
- meutils/apis/siliconflow/text_to_image.py +1 -1
- meutils/apis/siliconflow/utils.py +1 -1
- meutils/config_utils/lark_utils/common.py +6 -2
- meutils/data/VERSION +1 -1
- meutils/data/oneapi/index.html +9 -0
- meutils/io/files_utils.py +12 -1
- meutils/io/openai_files.py +26 -1
- meutils/llm/check_api.py +1 -1
- meutils/llm/check_utils.py +13 -4
- meutils/llm/clients.py +23 -0
- meutils/llm/completions/{oi.py → assistants/__init__.py} +2 -7
- meutils/llm/completions/assistants/ppt.py +11 -0
- meutils/llm/completions/chat_gemini.py +1 -0
- meutils/llm/completions/chat_plus.py +159 -49
- meutils/llm/completions/chat_spark.py +3 -10
- meutils/llm/completions/qwenllm.py +11 -6
- meutils/request_utils/crawler.py +11 -11
- meutils/schemas/oneapi/common.py +9 -1
- meutils/schemas/openai_types.py +26 -4
- meutils/schemas/siliconflow_types.py +1 -1
- meutils/apis/search/zhipu.py +0 -80
- meutils/llm/completions/qwen_demo.py +0 -26
- meutils/other/aiomultiprocess/__init__.py +0 -14
- meutils/other/aiomultiprocess/__version__.py +0 -1
- meutils/other/aiomultiprocess/core.py +0 -241
- meutils/other/aiomultiprocess/pool.py +0 -379
- meutils/other/aiomultiprocess/scheduler.py +0 -83
- meutils/other/aiomultiprocess/types.py +0 -48
- {MeUtils-2025.3.14.8.41.43.dist-info → MeUtils-2025.3.19.18.18.56.dist-info}/LICENSE +0 -0
- {MeUtils-2025.3.14.8.41.43.dist-info → MeUtils-2025.3.19.18.18.56.dist-info}/WHEEL +0 -0
- {MeUtils-2025.3.14.8.41.43.dist-info → MeUtils-2025.3.19.18.18.56.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.3.14.8.41.43.dist-info → MeUtils-2025.3.19.18.18.56.dist-info}/top_level.txt +0 -0
meutils/apis/search/zhipu.py
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
# @Project : AI. @by PyCharm
|
4
|
-
# @File : zhipu
|
5
|
-
# @Time : 2025/2/19 20:42
|
6
|
-
# @Author : betterme
|
7
|
-
# @WeChat : meutils
|
8
|
-
# @Software : PyCharm
|
9
|
-
# @Description :
|
10
|
-
|
11
|
-
from meutils.pipe import *
|
12
|
-
from meutils.str_utils.json_utils import json_path
|
13
|
-
from meutils.llm.clients import AsyncOpenAI, chatfire_client, zhipuai_client, moonshot_client
|
14
|
-
from meutils.llm.openai_utils import to_openai_params
|
15
|
-
from meutils.schemas.openai_types import chat_completion, chat_completion_chunk, ChatCompletionRequest, CompletionUsage
|
16
|
-
|
17
|
-
|
18
|
-
class Completions(object):
|
19
|
-
|
20
|
-
def __init__(self, api_key: Optional[str] = None):
|
21
|
-
self.api_key = api_key
|
22
|
-
|
23
|
-
async def create(self, request: ChatCompletionRequest, search_result2md: bool = False):
|
24
|
-
request.stream = False
|
25
|
-
request.model = "web-search-pro"
|
26
|
-
request.messages = [{
|
27
|
-
"role": "user",
|
28
|
-
"content": request.last_content,
|
29
|
-
}]
|
30
|
-
data = to_openai_params(request)
|
31
|
-
|
32
|
-
search_completion = await zhipuai_client.chat.completions.create(**data)
|
33
|
-
logger.debug(search_completion.model_dump_json(indent=4))
|
34
|
-
|
35
|
-
if results := json_path(search_completion, '$..[keywords,query,search_result]'):
|
36
|
-
data = dict(zip(["keywords", "query", "search_result"], results))
|
37
|
-
if search_result2md:
|
38
|
-
global df
|
39
|
-
|
40
|
-
df = pd.DataFrame(data["search_result"])
|
41
|
-
|
42
|
-
df['title'] = [f"[{k}]({v})" for k, v in zip(df['title'], df['link'])]
|
43
|
-
df['media'] = [f"" for k, v in zip(df['media'], df['icon'])]
|
44
|
-
|
45
|
-
df = df[['title', 'media']]
|
46
|
-
df.index += 1
|
47
|
-
# {df_.to_markdown(index=False).replace('|:-', '|-').replace('-:|', '-|')}
|
48
|
-
data["search_result"] = df.to_markdown()
|
49
|
-
return data
|
50
|
-
|
51
|
-
async def query(self, q: str):
|
52
|
-
pass
|
53
|
-
|
54
|
-
# {
|
55
|
-
# "role": "user",
|
56
|
-
# "content": search_completion.model_dump_json(indent=4),
|
57
|
-
# }
|
58
|
-
|
59
|
-
|
60
|
-
if __name__ == '__main__':
|
61
|
-
model = "web-search-pro"
|
62
|
-
# model = "tencent-search"
|
63
|
-
|
64
|
-
request = ChatCompletionRequest(
|
65
|
-
# model="baichuan4-turbo",
|
66
|
-
# model="xx",
|
67
|
-
# model="deepseek-r1",
|
68
|
-
# model="deepseek-r1:1.5b",
|
69
|
-
model=model,
|
70
|
-
|
71
|
-
# model="moonshot-v1-8k",
|
72
|
-
# model="doubao",
|
73
|
-
|
74
|
-
messages=[
|
75
|
-
{"role": "user", "content": "《哪吒之魔童闹海》现在的票房是多少"}
|
76
|
-
],
|
77
|
-
|
78
|
-
stream=True
|
79
|
-
)
|
80
|
-
arun(Completions().create(request, search_result2md=True))
|
@@ -1,26 +0,0 @@
|
|
1
|
-
|
2
|
-
from openai import OpenAI
|
3
|
-
cookies={'ssxmod_itna': 'euitD57IejxAo=DhODcmmv30j=DKDODl4BtGRDeq7tDRDFqAPiDHA17P5DU2OY2MGXxGDaieAqzRxGXxaexiNDAxq0iDCbeQ5ou2ivv3e3nemU4qRhnub1G7NQgR3+H3utAR5RMFgYDHxi8DBF4wCGYDenaDCeDQxirDD4DADibq4D1IDDkD0+m7UovW4GWDmbADYHGf78fDGpobRAfbDDCbPYDwEbpzDDzzQj5PmAqPm3DePAfIjkIoAQxb4G1fD0HaG65bzk9kMxA3d=xvUewDlFSDCKvu+gUuWEA1zSrtjeYtY+sYFrT+0x3GqliqB5Y7Di7i4nhhlwNf0xWA5DTttRPa4DG35zY=eBY3E5QiefL1XdWqbz+DreA=dh=2WeKR58GYxEwgG5/DYMADaA5+A4PADN0=a7eziDD',
|
4
|
-
'ssxmod_itna2': 'euitD57IejxAo=DhODcmmv30j=DKDODl4BtGRDeq7tDRDFqAPiDHA17P5DU2OY2MGXxGDaieAqzexD3raKY3rh4DFxnDKW1Bh0xDlxkDasWVgcuBepTBPecj=tk1QFgt3HxjB3pxx9=sdl5aSW9DG1yipgx+wgIO0mcDAoYQfrF4/xT++xEk02A7+4mHPbOA+oTOQBaahcHEWZfG3bok7rP8PcI8uRYYIUAHo0yE6aPp54bX0EQ8rUIHKYdC/1pjy6d0WqM90CG0PoMmhv3xrXwjP37hf4EgwgGqSxAhSaPAVxzGQUop4MXgBE+OX0DUmE5/no9eKynE/hjA6ECEP=oKnQo1DIjDq/YN00voKx0nLPbb3SG4DI4ZA/25ynwKc2a6rOEIQrN3+u0AiDbI5O2MCTK+LFfvq40LOQOALmFP0=bdo3w8onWpA+dhzA0C51ahgZjkR3y7olY=k8XW1ugrtAOIxC57jtViIOUdBtt7=D/0NE1oTf0k/d5aircE6f056c4rUy=c4wrh9XnhL1bIL9XZxdAcj8/YK4cRQN7Cc=XH6BTNFiFbTaOLxhrim5Q8p40K5fPAD4Ke+CYKKim2WDyieFrU3AqcDjfiGyUvmkP10CsY=3ZeLCx6YpkcELdkcAwlitYm6sFGq1tRkPRQewwrUYKiBh42Dzlpu=EuoV4aD2w24mPiDu1DZ51o3DA9ZW3h5leHGnB5Crc1KTbP03C2qlGQBezsq0xiHBeHDxncUxHTANQktHZ1KkxS6Hy4qQklKcxsKrxAqr2rmq32tnqViiY1spUPPi2mAw5hDD'}
|
5
|
-
cookie = '; '.join([f'{i}={j}' for i,j in cookies.items()])
|
6
|
-
|
7
|
-
headers = {
|
8
|
-
# 'authorization':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjIxZDJiMjhmLWZmMTctNGQ2MS1hYmI0LWM2NzJhZWNjMTQ5ZCIsImV4cCI6MTc0MzkzNTk1OX0.y3oSO7aOwmzuE3GI3_aSxd9c5iXz9Krw0zJDG1FCLBQ',
|
9
|
-
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
|
10
|
-
'cookie':cookie
|
11
|
-
}
|
12
|
-
client=OpenAI(base_url='https://chat.qwen.ai/api',
|
13
|
-
api_key='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjIxZDJiMjhmLWZmMTctNGQ2MS1hYmI0LWM2NzJhZWNjMTQ5ZCIsImV4cCI6MTc0MzkzNTk1OX0.y3oSO7aOwmzuE3GI3_aSxd9c5iXz9Krw0zJDG1FCLBQ',
|
14
|
-
# default_headers=headers
|
15
|
-
)
|
16
|
-
|
17
|
-
comp=client.chat.completions.create(
|
18
|
-
model="qwen-max-latest",
|
19
|
-
messages=[{"role": "user", "content": "你好"}],
|
20
|
-
max_tokens=2,
|
21
|
-
# extra_headers=headers, # 放在这里也可以
|
22
|
-
extra_body={'chat_type':'t2t'},
|
23
|
-
stream=False
|
24
|
-
)
|
25
|
-
print(comp.choices[0].message.content)
|
26
|
-
# comp
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Copyright 2018 John Reese
|
2
|
-
# Licensed under the MIT license
|
3
|
-
|
4
|
-
"""
|
5
|
-
AsyncIO version of the standard multiprocessing module
|
6
|
-
"""
|
7
|
-
|
8
|
-
__author__ = "John Reese" # https://github.com/omnilib/aiomultiprocess
|
9
|
-
|
10
|
-
from .__version__ import __version__
|
11
|
-
from .core import Process, Worker, set_context, set_start_method
|
12
|
-
from .pool import Pool, PoolResult
|
13
|
-
from .scheduler import RoundRobin, Scheduler
|
14
|
-
from .types import QueueID, TaskID
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "0.9.0"
|
@@ -1,241 +0,0 @@
|
|
1
|
-
# Copyright 2018 John Reese
|
2
|
-
# Licensed under the MIT license
|
3
|
-
|
4
|
-
import asyncio
|
5
|
-
import logging
|
6
|
-
import multiprocessing
|
7
|
-
import multiprocessing.managers
|
8
|
-
import os
|
9
|
-
import sys
|
10
|
-
from typing import Any, Callable, Dict, Optional, Sequence
|
11
|
-
|
12
|
-
from .types import Context, R, Unit
|
13
|
-
|
14
|
-
DEFAULT_START_METHOD = "spawn"
|
15
|
-
|
16
|
-
# shared context for all multiprocessing primitives, for platform compatibility
|
17
|
-
# "spawn" is default/required on windows and mac, but can't execute non-global functions
|
18
|
-
# see https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
|
19
|
-
context = multiprocessing.get_context(DEFAULT_START_METHOD)
|
20
|
-
_manager = None
|
21
|
-
|
22
|
-
log = logging.getLogger(__name__)
|
23
|
-
|
24
|
-
|
25
|
-
def get_manager() -> multiprocessing.managers.SyncManager:
|
26
|
-
"""Return a singleton shared manager."""
|
27
|
-
global _manager
|
28
|
-
if _manager is None:
|
29
|
-
_manager = context.Manager()
|
30
|
-
|
31
|
-
return _manager
|
32
|
-
|
33
|
-
|
34
|
-
def set_start_method(method: Optional[str] = DEFAULT_START_METHOD) -> None:
|
35
|
-
"""
|
36
|
-
Set the start method and context used for future processes/pools.
|
37
|
-
|
38
|
-
When given no parameters (`set_context()`), will default to using the "spawn" method
|
39
|
-
as this provides a predictable set of features and compatibility across all major
|
40
|
-
platforms, and trades a small cost on process startup for potentially large savings
|
41
|
-
on memory usage of child processes.
|
42
|
-
|
43
|
-
Passing an explicit string (eg, "fork") will force aiomultiprocess to use the given
|
44
|
-
start method instead of "spawn".
|
45
|
-
|
46
|
-
Passing an explicit `None` value will force aiomultiprocess to use CPython's default
|
47
|
-
start method for the current platform rather than defaulting to "spawn".
|
48
|
-
|
49
|
-
See the official multiprocessing documentation for details on start methods:
|
50
|
-
https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
|
51
|
-
"""
|
52
|
-
global context
|
53
|
-
context = multiprocessing.get_context(method)
|
54
|
-
|
55
|
-
|
56
|
-
def get_context() -> Context:
|
57
|
-
"""Get the current active global context."""
|
58
|
-
global context
|
59
|
-
return context
|
60
|
-
|
61
|
-
|
62
|
-
def set_context(method: Optional[str] = None) -> None:
|
63
|
-
"""
|
64
|
-
Set the start method and context used for future processes/pools. [DEPRECATED]
|
65
|
-
|
66
|
-
Retained for backwards compatibility, and to retain prior behavior of "no parameter"
|
67
|
-
resulting in selection of the platform's default start method.
|
68
|
-
"""
|
69
|
-
return set_start_method(method)
|
70
|
-
|
71
|
-
|
72
|
-
async def not_implemented(*args: Any, **kwargs: Any) -> None:
|
73
|
-
"""Default function to call when none given."""
|
74
|
-
raise NotImplementedError()
|
75
|
-
|
76
|
-
|
77
|
-
class Process:
|
78
|
-
"""Execute a coroutine on a separate process."""
|
79
|
-
|
80
|
-
def __init__(
|
81
|
-
self,
|
82
|
-
group: None = None,
|
83
|
-
target: Callable = None,
|
84
|
-
name: str = None,
|
85
|
-
args: Sequence[Any] = None,
|
86
|
-
kwargs: Dict[str, Any] = None,
|
87
|
-
*,
|
88
|
-
daemon: bool = None,
|
89
|
-
initializer: Optional[Callable] = None,
|
90
|
-
initargs: Sequence[Any] = (),
|
91
|
-
loop_initializer: Optional[Callable] = None,
|
92
|
-
process_target: Optional[Callable] = None,
|
93
|
-
) -> None:
|
94
|
-
if target is not None and not asyncio.iscoroutinefunction(target):
|
95
|
-
raise ValueError("target must be coroutine function")
|
96
|
-
|
97
|
-
if initializer is not None and asyncio.iscoroutinefunction(initializer):
|
98
|
-
raise ValueError("initializer must be synchronous function")
|
99
|
-
|
100
|
-
if loop_initializer is not None and asyncio.iscoroutinefunction(
|
101
|
-
loop_initializer
|
102
|
-
):
|
103
|
-
raise ValueError("loop_initializer must be synchronous function")
|
104
|
-
|
105
|
-
self.unit = Unit(
|
106
|
-
target=target or not_implemented,
|
107
|
-
args=args or (),
|
108
|
-
kwargs=kwargs or {},
|
109
|
-
namespace=get_manager().Namespace(),
|
110
|
-
initializer=initializer,
|
111
|
-
initargs=initargs,
|
112
|
-
loop_initializer=loop_initializer,
|
113
|
-
)
|
114
|
-
self.aio_process = context.Process(
|
115
|
-
group=group,
|
116
|
-
target=process_target or Process.run_async,
|
117
|
-
args=(self.unit,),
|
118
|
-
name=name,
|
119
|
-
daemon=daemon,
|
120
|
-
)
|
121
|
-
|
122
|
-
def __await__(self) -> Any:
|
123
|
-
"""Enable awaiting of the process result by chaining to `start()` & `join()`."""
|
124
|
-
if not self.is_alive() and self.exitcode is None:
|
125
|
-
self.start()
|
126
|
-
|
127
|
-
return self.join().__await__()
|
128
|
-
|
129
|
-
@staticmethod
|
130
|
-
def run_async(unit: Unit) -> R:
|
131
|
-
"""Initialize the child process and event loop, then execute the coroutine."""
|
132
|
-
try:
|
133
|
-
if unit.loop_initializer is None:
|
134
|
-
loop = asyncio.new_event_loop()
|
135
|
-
else:
|
136
|
-
loop = unit.loop_initializer()
|
137
|
-
|
138
|
-
asyncio.set_event_loop(loop)
|
139
|
-
|
140
|
-
if unit.initializer:
|
141
|
-
unit.initializer(*unit.initargs)
|
142
|
-
|
143
|
-
result: R = loop.run_until_complete(unit.target(*unit.args, **unit.kwargs))
|
144
|
-
|
145
|
-
return result
|
146
|
-
|
147
|
-
except BaseException:
|
148
|
-
log.exception(f"aio process {os.getpid()} failed")
|
149
|
-
raise
|
150
|
-
|
151
|
-
def start(self) -> None:
|
152
|
-
"""Start the child process."""
|
153
|
-
return self.aio_process.start()
|
154
|
-
|
155
|
-
async def join(self, timeout: int = None) -> None:
|
156
|
-
"""Wait for the process to finish execution without blocking the main thread."""
|
157
|
-
if not self.is_alive() and self.exitcode is None:
|
158
|
-
raise ValueError("must start process before joining it")
|
159
|
-
|
160
|
-
if timeout is not None:
|
161
|
-
return await asyncio.wait_for(self.join(), timeout)
|
162
|
-
|
163
|
-
while self.exitcode is None:
|
164
|
-
await asyncio.sleep(0.005)
|
165
|
-
|
166
|
-
@property
|
167
|
-
def name(self) -> str:
|
168
|
-
"""Child process name."""
|
169
|
-
return self.aio_process.name
|
170
|
-
|
171
|
-
def is_alive(self) -> bool:
|
172
|
-
"""Is child process running."""
|
173
|
-
return self.aio_process.is_alive()
|
174
|
-
|
175
|
-
@property
|
176
|
-
def daemon(self) -> bool:
|
177
|
-
"""Should child process be daemon."""
|
178
|
-
return self.aio_process.daemon
|
179
|
-
|
180
|
-
@daemon.setter
|
181
|
-
def daemon(self, value: bool) -> None:
|
182
|
-
"""Should child process be daemon."""
|
183
|
-
self.aio_process.daemon = value
|
184
|
-
|
185
|
-
@property
|
186
|
-
def pid(self) -> Optional[int]:
|
187
|
-
"""Process ID of child, or None if not started."""
|
188
|
-
return self.aio_process.pid
|
189
|
-
|
190
|
-
@property
|
191
|
-
def exitcode(self) -> Optional[int]:
|
192
|
-
"""Exit code from child process, or None if still running."""
|
193
|
-
return self.aio_process.exitcode
|
194
|
-
|
195
|
-
def terminate(self) -> None:
|
196
|
-
"""Send SIGTERM to child process."""
|
197
|
-
return self.aio_process.terminate()
|
198
|
-
|
199
|
-
# multiprocessing.Process methods added in 3.7
|
200
|
-
if sys.version_info >= (3, 7):
|
201
|
-
|
202
|
-
def kill(self) -> None:
|
203
|
-
"""Send SIGKILL to child process."""
|
204
|
-
return self.aio_process.kill()
|
205
|
-
|
206
|
-
def close(self) -> None:
|
207
|
-
"""Clean up child process once finished."""
|
208
|
-
return self.aio_process.close()
|
209
|
-
|
210
|
-
|
211
|
-
class Worker(Process):
|
212
|
-
"""Execute a coroutine on a separate process and return the result."""
|
213
|
-
|
214
|
-
def __init__(self, *args, **kwargs) -> None:
|
215
|
-
super().__init__(*args, process_target=Worker.run_async, **kwargs)
|
216
|
-
self.unit.namespace.result = None
|
217
|
-
|
218
|
-
@staticmethod
|
219
|
-
def run_async(unit: Unit) -> R:
|
220
|
-
"""Initialize the child process and event loop, then execute the coroutine."""
|
221
|
-
try:
|
222
|
-
result: R = Process.run_async(unit)
|
223
|
-
unit.namespace.result = result
|
224
|
-
return result
|
225
|
-
|
226
|
-
except BaseException as e:
|
227
|
-
unit.namespace.result = e
|
228
|
-
raise
|
229
|
-
|
230
|
-
async def join(self, timeout: int = None) -> Any:
|
231
|
-
"""Wait for the worker to finish, and return the final result."""
|
232
|
-
await super().join(timeout)
|
233
|
-
return self.result
|
234
|
-
|
235
|
-
@property
|
236
|
-
def result(self) -> R:
|
237
|
-
"""Easy access to the resulting value from the coroutine."""
|
238
|
-
if self.exitcode is None:
|
239
|
-
raise ValueError("coroutine not completed")
|
240
|
-
|
241
|
-
return self.unit.namespace.result
|