MeUtils 2025.3.14.8.43.3__py3-none-any.whl → 2025.3.19.19.13.35__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.43.3.dist-info → MeUtils-2025.3.19.19.13.35.dist-info}/METADATA +264 -264
- {MeUtils-2025.3.14.8.43.3.dist-info → MeUtils-2025.3.19.19.13.35.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 +6 -6
- 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 +162 -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.43.3.dist-info → MeUtils-2025.3.19.19.13.35.dist-info}/LICENSE +0 -0
- {MeUtils-2025.3.14.8.43.3.dist-info → MeUtils-2025.3.19.19.13.35.dist-info}/WHEEL +0 -0
- {MeUtils-2025.3.14.8.43.3.dist-info → MeUtils-2025.3.19.19.13.35.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.3.14.8.43.3.dist-info → MeUtils-2025.3.19.19.13.35.dist-info}/top_level.txt +0 -0
@@ -9,21 +9,28 @@
|
|
9
9
|
# @Description : https://bigmodel.cn/dev/api/intelligent-agent-model/assistantapi
|
10
10
|
|
11
11
|
from meutils.pipe import *
|
12
|
+
from meutils.llm.clients import zhipuai_sdk_client
|
12
13
|
|
13
14
|
from zhipuai import ZhipuAI
|
14
|
-
api_key = "YOUR API KEY"
|
15
|
-
url = "https://open.bigmodel.cn/api/paas/v4"
|
16
|
-
client = ZhipuAI(
|
17
|
-
api_key="e21bd630f681c4d90b390cd609720483.WSFVgA3KkwNCX0mN",
|
18
|
-
base_url="https://open.bigmodel.cn/api/paas/v4/"
|
19
|
-
)
|
20
15
|
|
21
|
-
|
22
|
-
|
16
|
+
# api_key = "YOUR API KEY"
|
17
|
+
# url = "https://open.bigmodel.cn/api/paas/v4"
|
18
|
+
# client = ZhipuAI(
|
19
|
+
# api_key="e21bd630f681c4d90b390cd609720483.WSFVgA3KkwNCX0mN",
|
20
|
+
# base_url="https://open.bigmodel.cn/api/paas/v4/"
|
21
|
+
# )
|
22
|
+
|
23
|
+
|
24
|
+
#
|
25
|
+
#
|
26
|
+
# # print(bjson(client.assistant.query_support()))
|
27
|
+
generate = zhipuai_sdk_client.assistant.conversation(
|
23
28
|
# assistant_id="65a265419d72d299a9230616",
|
24
|
-
# assistant_id="
|
25
|
-
assistant_id="
|
26
|
-
|
29
|
+
# assistant_id="659d051a5f14eb8ce1235b96",
|
30
|
+
assistant_id="65d2f07bb2c10188f885bd89",
|
31
|
+
|
32
|
+
# assistant_id="659e54b1b8006379b4b2abd6",
|
33
|
+
conversation_id=None, # 多轮
|
27
34
|
model="glm-4-assistant",
|
28
35
|
messages=[
|
29
36
|
{
|
@@ -31,7 +38,8 @@ generate = client.assistant.conversation(
|
|
31
38
|
"content": [{
|
32
39
|
"type": "text",
|
33
40
|
# "text": "北京未来七天气温,做个折线图",
|
34
|
-
"text": "画条狗"
|
41
|
+
# "text": "画条狗"
|
42
|
+
"text": "周杰伦",
|
35
43
|
|
36
44
|
}]
|
37
45
|
}
|
@@ -42,4 +50,59 @@ generate = client.assistant.conversation(
|
|
42
50
|
)
|
43
51
|
|
44
52
|
for resp in generate:
|
45
|
-
|
53
|
+
delta = resp.choices[0].delta
|
54
|
+
if hasattr(delta, "tool_calls") and delta.tool_calls:
|
55
|
+
# print(delta)
|
56
|
+
|
57
|
+
print(delta.model_dump_json(indent=4, exclude_none=True))
|
58
|
+
|
59
|
+
# print(delta.model_dump_json(indent=4, exclude_none=True))
|
60
|
+
# for tc in delta.tool_calls:
|
61
|
+
# tc.web_browser
|
62
|
+
|
63
|
+
# print(resp.choices[0])
|
64
|
+
|
65
|
+
# if hasattr(delta, "content"):
|
66
|
+
# print(delta.content)
|
67
|
+
|
68
|
+
# 输入 输出
|
69
|
+
# input
|
70
|
+
# {
|
71
|
+
# "assistant_id": "65d2f07bb2c10188f885bd89",
|
72
|
+
# "conversation_id": "67d932d5e579c3ded42aa80e",
|
73
|
+
# "meta_data": {
|
74
|
+
# "if_plus_model": false,
|
75
|
+
# "is_test": false,
|
76
|
+
# "input_question_type": "xxxx",
|
77
|
+
# "channel": "",
|
78
|
+
# "draft_id": "",
|
79
|
+
# "quote_log_id": "",
|
80
|
+
# "platform": "pc"
|
81
|
+
# },
|
82
|
+
# "messages": [
|
83
|
+
# {
|
84
|
+
# "role": "user",
|
85
|
+
# "content": [
|
86
|
+
# {
|
87
|
+
# "type": "text",
|
88
|
+
# "text": "基于这个内容做个ppt"
|
89
|
+
# },
|
90
|
+
# {
|
91
|
+
# "type": "file",
|
92
|
+
# "file": [
|
93
|
+
# {
|
94
|
+
# "file_id": "chatglm4/3db10f79-a952-4987-83d2-cf0cfd5d5530.pdf",
|
95
|
+
# "file_url": "https://sfile.chatglm.cn/chatglm4/3db10f79-a952-4987-83d2-cf0cfd5d5530.pdf",
|
96
|
+
# "file_name": "附件.大模型在合规管理工作中的应用.pdf",
|
97
|
+
# "file_size": 2571523,
|
98
|
+
# "order": 0,
|
99
|
+
# "maxReadPercent": 0,
|
100
|
+
# "cover_images": [],
|
101
|
+
# "url": "https://sfile.chatglm.cn/chatglm4/3db10f79-a952-4987-83d2-cf0cfd5d5530.pdf"
|
102
|
+
# }
|
103
|
+
# ]
|
104
|
+
# }
|
105
|
+
# ]
|
106
|
+
# }
|
107
|
+
# ]
|
108
|
+
# }
|
meutils/apis/jimeng/common.py
CHANGED
@@ -180,6 +180,8 @@ if __name__ == '__main__':
|
|
180
180
|
token = "34438eb03d165737122180caf62a8058"
|
181
181
|
token = "ffeee346fbd19eceebb79a7bfbca4bfe"
|
182
182
|
token = "b8bb4cb67dba6c0d1048bdc0596bc461"
|
183
|
+
token = "34438eb03d165737122180caf62a8058"
|
184
|
+
token = "a521dd578adcfb191fad38dd4baab498"
|
183
185
|
arun(check_token(token))
|
184
186
|
|
185
187
|
# print(arun(aget_spreadsheet_values(feishu_url=FEISHU_URL, to_dataframe=True))[0].tolist())
|
meutils/apis/jimeng/images.py
CHANGED
@@ -272,8 +272,8 @@ async def get_task(task_id, token):
|
|
272
272
|
logger.debug(f"status: {status_code}")
|
273
273
|
|
274
274
|
# 敏感词存储
|
275
|
-
if status_code != 50:
|
276
|
-
|
275
|
+
# if status_code != 50:
|
276
|
+
# send_message_for_images(task_info, __name__)
|
277
277
|
|
278
278
|
"""
|
279
279
|
"status": 30, # 内容审核
|
@@ -376,10 +376,10 @@ if __name__ == '__main__':
|
|
376
376
|
# arun(generate(ImageRequest(**data)))
|
377
377
|
|
378
378
|
# arun(generate(ImageRequest(prompt="fuck you")))
|
379
|
-
|
380
|
-
|
381
|
-
task = arun(create_task(ImageRequest(**data), token=token))
|
379
|
+
prompt = "A plump Chinese beauty wearing a wedding dress revealing her skirt and underwear is swinging on the swing,Happy smile,cleavage,Exposed thighs,Spread your legs open,Extend your leg,panties,upskirt,Barefoot,sole"
|
380
|
+
request = ImageRequest(prompt=prompt)
|
381
|
+
# task = arun(create_task(ImageRequest(**data), token=token))
|
382
382
|
|
383
383
|
# arun(get_task(task.task_id, task.system_fingerprint))
|
384
384
|
|
385
|
-
|
385
|
+
arun(generate(request))
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : __init__.py
|
5
|
+
# @Time : 2025/3/17 18:30
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
from meutils.apis.jina.common import url_reader
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : common
|
5
|
+
# @Time : 2025/3/17 18:44
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
from httpx import AsyncClient
|
12
|
+
|
13
|
+
from meutils.pipe import *
|
14
|
+
from meutils.decorators.retry import retrying
|
15
|
+
from meutils.caches import cache, rcache
|
16
|
+
|
17
|
+
|
18
|
+
@retrying()
|
19
|
+
@rcache(ttl=300)
|
20
|
+
async def _url_reader(url: str):
|
21
|
+
"""markdown"""
|
22
|
+
|
23
|
+
async with AsyncClient(base_url="https://r.jina.ai", headers={}) as client:
|
24
|
+
response = await client.get(f"/{url}")
|
25
|
+
response.raise_for_status()
|
26
|
+
|
27
|
+
return response.text
|
28
|
+
|
29
|
+
|
30
|
+
async def url_reader(urls: Union[str, List[str]]):
|
31
|
+
if isinstance(urls, str):
|
32
|
+
return await _url_reader(urls)
|
33
|
+
|
34
|
+
tasks = [_url_reader(url) for url in urls]
|
35
|
+
return await asyncio.gather(*tasks)
|
36
|
+
|
37
|
+
|
38
|
+
if __name__ == '__main__':
|
39
|
+
url = "https://top.baidu.com/board?tab=realtime"
|
40
|
+
|
41
|
+
# print(arun(url_reader(url)))
|
42
|
+
|
43
|
+
print(arun(url_reader([url])))
|
meutils/apis/oneapi/channel.py
CHANGED
@@ -16,6 +16,7 @@ async def edit_channel(models, token: Optional[str] = None):
|
|
16
16
|
token = token or os.environ.get("CHATFIRE_ONEAPI_TOKEN")
|
17
17
|
|
18
18
|
models = ','.join(filter(lambda model: model.startswith(("api", "official-api", "ppu", "kling-v")), models))
|
19
|
+
models += ",suno-v3"
|
19
20
|
|
20
21
|
payload = {
|
21
22
|
"id": 289,
|
@@ -41,8 +42,8 @@ async def edit_channel(models, token: Optional[str] = None):
|
|
41
42
|
"auto_ban": 0,
|
42
43
|
"other_info": "",
|
43
44
|
|
44
|
-
"group": "default,
|
45
|
-
"groups": ['default'
|
45
|
+
"group": "default,china", # ','.join(GROUP_RATIO),
|
46
|
+
"groups": ['default']
|
46
47
|
}
|
47
48
|
headers = {
|
48
49
|
'authorization': f'Bearer {token}',
|
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-hXruPMHP0TnBpohQMJWBZILDVKugUmzQF0lwZTetDX7eHaAM'))
|
@@ -0,0 +1,87 @@
|
|
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 zhipuai_sdk_client, zhipuai_client
|
14
|
+
|
15
|
+
from meutils.llm.openai_utils import to_openai_params
|
16
|
+
from meutils.schemas.openai_types import chat_completion, chat_completion_chunk, CompletionRequest, \
|
17
|
+
ChatCompletionRequest
|
18
|
+
|
19
|
+
|
20
|
+
class Completions(object):
|
21
|
+
|
22
|
+
def __init__(self, api_key: Optional[str] = None):
|
23
|
+
self.api_key = api_key
|
24
|
+
|
25
|
+
async def create(self, request: ChatCompletionRequest, search_result2md: bool = False):
|
26
|
+
pass
|
27
|
+
|
28
|
+
# async def _create(self, request: ChatCompletionRequest, search_result2md: bool = False):
|
29
|
+
# request.stream = False
|
30
|
+
# request.model = "web-search-pro"
|
31
|
+
# request.messages = [{
|
32
|
+
# "role": "user",
|
33
|
+
# "content": request.last_content,
|
34
|
+
# }]
|
35
|
+
# data = to_openai_params(request)
|
36
|
+
#
|
37
|
+
# search_completion = await zhipuai_client.chat.completions.create(**data)
|
38
|
+
# logger.debug(search_completion.model_dump_json(indent=4))
|
39
|
+
#
|
40
|
+
# if results := json_path(search_completion, '$..[keywords,query,search_result]'):
|
41
|
+
# data = dict(zip(["keywords", "query", "search_result"], results))
|
42
|
+
# if search_result2md:
|
43
|
+
# global df
|
44
|
+
#
|
45
|
+
# df = pd.DataFrame(data["search_result"])
|
46
|
+
#
|
47
|
+
# df['title'] = [f"[{k}]({v})" for k, v in zip(df['title'], df['link'])]
|
48
|
+
# df['media'] = [f"" for k, v in zip(df['media'], df['icon'])]
|
49
|
+
#
|
50
|
+
# df = df[['title', 'media']]
|
51
|
+
# df.index += 1
|
52
|
+
# # {df_.to_markdown(index=False).replace('|:-', '|-').replace('-:|', '-|')}
|
53
|
+
# data["search_result"] = df.to_markdown()
|
54
|
+
# return data
|
55
|
+
|
56
|
+
async def search(self, q: str):
|
57
|
+
zhipuai_sdk_client.assistant.conversation(
|
58
|
+
model="web-search-pro",
|
59
|
+
)
|
60
|
+
|
61
|
+
# {
|
62
|
+
# "role": "user",
|
63
|
+
# "content": search_completion.model_dump_json(indent=4),
|
64
|
+
# }
|
65
|
+
|
66
|
+
|
67
|
+
if __name__ == '__main__':
|
68
|
+
model = "web-search-pro"
|
69
|
+
# model = "tencent-search"
|
70
|
+
|
71
|
+
request = ChatCompletionRequest(
|
72
|
+
# model="baichuan4-turbo",
|
73
|
+
# model="xx",
|
74
|
+
# model="deepseek-r1",
|
75
|
+
# model="deepseek-r1:1.5b",
|
76
|
+
model=model,
|
77
|
+
|
78
|
+
# model="moonshot-v1-8k",
|
79
|
+
# model="doubao",
|
80
|
+
|
81
|
+
messages=[
|
82
|
+
{"role": "user", "content": "《哪吒之魔童闹海》现在的票房是多少"}
|
83
|
+
],
|
84
|
+
|
85
|
+
stream=True
|
86
|
+
)
|
87
|
+
arun(Completions().create(request, search_result2md=True))
|
meutils/apis/search/metaso.py
CHANGED
@@ -13,7 +13,7 @@ from meutils.schemas.metaso_types import FEISHU_URL, BASE_URL, MetasoRequest, Me
|
|
13
13
|
from meutils.decorators.retry import retrying
|
14
14
|
from meutils.config_utils.lark_utils import get_next_token_for_polling
|
15
15
|
from meutils.apis.proxy.ips import FEISHU_URL_METASO, get_one_proxy, get_proxies
|
16
|
-
from meutils.schemas.openai_types import ChatCompletionRequest
|
16
|
+
from meutils.schemas.openai_types import ChatCompletionRequest, CompletionRequest
|
17
17
|
from meutils.notice.feishu import send_message
|
18
18
|
|
19
19
|
from urllib.parse import quote_plus
|
@@ -95,7 +95,14 @@ async def get_access_token(session_id: Optional[str] = None):
|
|
95
95
|
return tokens and tokens[0]
|
96
96
|
|
97
97
|
|
98
|
-
async def create(request: ChatCompletionRequest):
|
98
|
+
async def create(request: Union[ChatCompletionRequest, CompletionRequest]):
|
99
|
+
if isinstance(request, CompletionRequest):
|
100
|
+
request = ChatCompletionRequest(**request.model_dump())
|
101
|
+
|
102
|
+
if request.last_content == 'ping':
|
103
|
+
yield "pong"
|
104
|
+
return
|
105
|
+
|
99
106
|
system_fingerprint = request.system_fingerprint
|
100
107
|
|
101
108
|
engine_type = ''
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# @Project : AI. @by PyCharm
|
4
|
+
# @File : web_search
|
5
|
+
# @Time : 2025/3/18 20:15
|
6
|
+
# @Author : betterme
|
7
|
+
# @WeChat : meutils
|
8
|
+
# @Software : PyCharm
|
9
|
+
# @Description :
|
10
|
+
|
11
|
+
from aiostream import stream
|
12
|
+
from meutils.pipe import *
|
13
|
+
from meutils.async_utils import sync_to_async
|
14
|
+
|
15
|
+
from meutils.llm.clients import zhipuai_sdk_client
|
16
|
+
from meutils.schemas.openai_types import chat_completion, chat_completion_chunk, CompletionRequest, ChatCompletionChunk
|
17
|
+
|
18
|
+
|
19
|
+
def convert_citations(text):
|
20
|
+
"""
|
21
|
+
# 示例使用
|
22
|
+
text = "这是一段包含【1†source】和【2†source】的文本"
|
23
|
+
result = convert_citations(text)
|
24
|
+
print(result) # 输出: 这是一段包含[^1]和[^2]的文本
|
25
|
+
:param text:
|
26
|
+
:return:
|
27
|
+
"""
|
28
|
+
# 匹配【数字†source】格式的引用
|
29
|
+
pattern = r'【(\d+)†source】'
|
30
|
+
|
31
|
+
# 替换为[^数字]格式
|
32
|
+
converted = re.sub(pattern, r'[^\1]', text)
|
33
|
+
|
34
|
+
return converted
|
35
|
+
|
36
|
+
|
37
|
+
class Completions(object):
|
38
|
+
|
39
|
+
def __init__(self, api_key: Optional[str] = None):
|
40
|
+
self.api_key = api_key
|
41
|
+
|
42
|
+
@sync_to_async(thread_sensitive=False)
|
43
|
+
def create(self, request: CompletionRequest):
|
44
|
+
_ = self._create(request)
|
45
|
+
for i in _:
|
46
|
+
print(i)
|
47
|
+
# return _
|
48
|
+
|
49
|
+
async def search(self, q: str):
|
50
|
+
return list(self._create(q))
|
51
|
+
|
52
|
+
def _create(self, request: Union[CompletionRequest, str]):
|
53
|
+
chunks = zhipuai_sdk_client.assistant.conversation(
|
54
|
+
|
55
|
+
assistant_id="659e54b1b8006379b4b2abd6", # 搜索智能体
|
56
|
+
conversation_id=None,
|
57
|
+
model="glm-4-assistant", # assistant-ppt
|
58
|
+
messages=[
|
59
|
+
{
|
60
|
+
"role": "user",
|
61
|
+
"content": [{
|
62
|
+
"type": "text",
|
63
|
+
# "text": "北京未来七天气温,做个折线图",
|
64
|
+
# "text": "画条狗"
|
65
|
+
"text": request.last_user_content if isinstance(request, CompletionRequest) else request,
|
66
|
+
|
67
|
+
}]
|
68
|
+
}
|
69
|
+
],
|
70
|
+
stream=True,
|
71
|
+
attachments=None,
|
72
|
+
metadata=None
|
73
|
+
)
|
74
|
+
|
75
|
+
references = []
|
76
|
+
buffer = []
|
77
|
+
for chunk in chunks:
|
78
|
+
delta = chunk.choices[0].delta
|
79
|
+
if hasattr(delta, "tool_calls") and delta.tool_calls:
|
80
|
+
tool_call = delta.tool_calls[0].model_dump()
|
81
|
+
# logger.debug(tool_call)
|
82
|
+
tool_type = tool_call.get("type", "") # web_browser
|
83
|
+
references += tool_call.get(tool_type, {}).get("outputs") or [] # title link content
|
84
|
+
continue
|
85
|
+
|
86
|
+
if isinstance(request, CompletionRequest):
|
87
|
+
if references:
|
88
|
+
urls = [f"[^{i}]: [{ref['title']}]({ref['link']})\n" for i, ref in enumerate(references, 1)]
|
89
|
+
yield from urls
|
90
|
+
references = []
|
91
|
+
|
92
|
+
# logger.debug(delta)
|
93
|
+
# if delta.content.startswith('【') or buffer: # hasattr(delta, "content")
|
94
|
+
# buffer.append(delta.content)
|
95
|
+
# if len(buffer) < 20:
|
96
|
+
# continue
|
97
|
+
#
|
98
|
+
# if delta.content.endswith('】'):
|
99
|
+
# delta.content = convert_citations(''.join(buffer))
|
100
|
+
# if len(buffer) > 25: buffer = []
|
101
|
+
|
102
|
+
delta = chat_completion_chunk.choices[0].delta.model_construct(**delta.model_dump())
|
103
|
+
chat_completion_chunk.choices[0].delta = delta
|
104
|
+
yield chat_completion_chunk
|
105
|
+
|
106
|
+
else:
|
107
|
+
yield references
|
108
|
+
break
|
109
|
+
|
110
|
+
|
111
|
+
if __name__ == '__main__':
|
112
|
+
model = "web-search-pro"
|
113
|
+
# model = "tencent-search"
|
114
|
+
|
115
|
+
request = CompletionRequest(
|
116
|
+
# model="baichuan4-turbo",
|
117
|
+
# model="xx",
|
118
|
+
# model="deepseek-r1",
|
119
|
+
# model="deepseek-r1:1.5b",
|
120
|
+
model=model,
|
121
|
+
|
122
|
+
# model="moonshot-v1-8k",
|
123
|
+
# model="doubao",
|
124
|
+
|
125
|
+
messages=[
|
126
|
+
{"role": "user", "content": "《哪吒之魔童闹海》现在的票房是多少"}
|
127
|
+
],
|
128
|
+
|
129
|
+
stream=True
|
130
|
+
)
|
131
|
+
# arun(Completions().search('周杰伦'))
|
132
|
+
arun(Completions().create(request))
|
@@ -23,7 +23,7 @@ BASE_URL = "https://cloud.siliconflow.cn"
|
|
23
23
|
FEISHU_URL = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?sheet=InxiCF"
|
24
24
|
FEISHU_URL_TOKEN = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?sheet=xlvlrH"
|
25
25
|
|
26
|
-
url = "https://api.siliconflow.
|
26
|
+
url = "https://api.siliconflow.cn/v1/TencentARC/PhotoMaker/image-to-image"
|
27
27
|
|
28
28
|
PHOTOMAKER_STYLES = {
|
29
29
|
"Photographic (Default)",
|
@@ -83,8 +83,8 @@ async def create(request: ImageRequest, api_key: Optional[str] = None): # SD3
|
|
83
83
|
headers = {
|
84
84
|
"Authorization": f"Bearer {api_key}",
|
85
85
|
}
|
86
|
-
base_url = "https://api.siliconflow.
|
87
|
-
url = "https://api.siliconflow.
|
86
|
+
base_url = "https://api.siliconflow.cn/v1"
|
87
|
+
url = "https://api.siliconflow.cn/v1/TencentARC/PhotoMaker/image-to-image"
|
88
88
|
|
89
89
|
async with httpx.AsyncClient(base_url=base_url, headers=headers, timeout=100) as client:
|
90
90
|
response = await client.post(f"/{request.model}/image-to-image", json=payload)
|
@@ -75,7 +75,7 @@ async def generate(request: ImageRequest, api_key: Optional[str] = None):
|
|
75
75
|
# {'model': 'flux-schnell', 'messages': [{'role': 'user', 'content': '写一个10个字的冷笑话'}]}
|
76
76
|
return ImagesResponse(**request.model_dump())
|
77
77
|
|
78
|
-
if not request.model.startswith(("flux",)): # 自动翻译
|
78
|
+
if not request.model.startswith(("flux", "black-forest-labs")): # 自动翻译
|
79
79
|
request.prompt = (
|
80
80
|
await deeplx.translate(DeeplxRequest(text=request.prompt, target_lang="EN"))
|
81
81
|
).get("data", request.prompt)
|
@@ -161,6 +161,8 @@ if __name__ == '__main__':
|
|
161
161
|
|
162
162
|
# request = FluxImageRequest(model="flux", prompt="a dog", size="1024x1024", num_inference_steps=1)
|
163
163
|
# request = FluxImageRequest(model="flux-pro", prompt="a dog", size="10x10", num_inference_steps=1)
|
164
|
+
|
165
|
+
data = {'model': 'flux-schnell', 'prompt': '画一个2025年电脑如何一键重装系统win10教程详解的封面图', 'n': 1, 'size': '680x400'}
|
164
166
|
request = FluxImageRequest(**data)
|
165
167
|
|
166
168
|
print(request)
|
@@ -176,4 +178,4 @@ if __name__ == '__main__':
|
|
176
178
|
|
177
179
|
arun(generate(request))
|
178
180
|
|
179
|
-
# https://api.siliconflow.
|
181
|
+
# https://api.siliconflow.cn/v1
|
@@ -17,7 +17,7 @@ from meutils.schemas.translator_types import DeeplxRequest
|
|
17
17
|
from meutils.decorators.retry import retrying
|
18
18
|
from meutils.schemas.image_types import ASPECT_RATIOS
|
19
19
|
|
20
|
-
BASE_URL = "https://api.siliconflow.
|
20
|
+
BASE_URL = "https://api.siliconflow.cn/v1"
|
21
21
|
FEISHU_URL = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?sheet=InxiCF"
|
22
22
|
FEISHU_URL_TOKEN = "https://xchatllm.feishu.cn/sheets/Bmjtst2f6hfMqFttbhLcdfRJnNf?sheet=xlvlrH"
|
23
23
|
|
@@ -9,10 +9,13 @@
|
|
9
9
|
# @Description : httpx重试 transport = httpx.AsyncHTTPTransport(retries=3) # response.raise_for_status()
|
10
10
|
|
11
11
|
from meutils.pipe import *
|
12
|
+
from meutils.caches import rcache
|
13
|
+
|
12
14
|
from meutils.decorators.retry import retrying
|
13
15
|
from meutils.decorators.contextmanagers import try_catcher
|
14
16
|
from meutils.notice.feishu import send_message
|
15
17
|
from meutils.db.redis_db import redis_client, redis_aclient
|
18
|
+
from typing import Optional, Union
|
16
19
|
|
17
20
|
from urllib.parse import urlparse, parse_qs
|
18
21
|
|
@@ -73,6 +76,7 @@ def get_spreadsheet_values(
|
|
73
76
|
|
74
77
|
|
75
78
|
@alru_cache(ttl=600)
|
79
|
+
@rcache(ttl=600, serializer='pickle') # 缓存
|
76
80
|
async def aget_spreadsheet_values(
|
77
81
|
spreadsheet_token: Optional[str] = None,
|
78
82
|
sheet_id: Optional[str] = None,
|
@@ -381,5 +385,5 @@ if __name__ == '__main__':
|
|
381
385
|
# with timer():
|
382
386
|
# token = arun(get_next_token(feishu_url))
|
383
387
|
|
384
|
-
|
385
|
-
|
388
|
+
FEISHU_URL = "https://xchatllm.feishu.cn/sheets/XfjqszII3hZAEvtTOgecOgv2nye?sheet=c14b34"
|
389
|
+
print(arun(get_series(FEISHU_URL)))
|
meutils/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2025.03.
|
1
|
+
2025.03.19.19.13.35
|
meutils/data/oneapi/index.html
CHANGED
@@ -235,6 +235,15 @@
|
|
235
235
|
},
|
236
236
|
],
|
237
237
|
changeLogs: [
|
238
|
+
{
|
239
|
+
date: '2025.03.15',
|
240
|
+
title: '🔥🔥🔥 上线新模型',
|
241
|
+
content: [
|
242
|
+
'suno风控成本上涨,单价略微上涨,明日生效',
|
243
|
+
'google/gemma-3-27b-it:Gemma 3 引入了多模态性,支持视觉语言输入和文本输出。它可以处理多达 128k 个标记的上下文窗口,理解 140 多种语言,并提供改进的数学、推理和聊天功能,包括结构化输出和函数调用。Gemma 3 27B 是 Google 最新的开源模型,是 Gemma 2 的继任者',
|
244
|
+
|
245
|
+
],
|
246
|
+
},
|
238
247
|
{
|
239
248
|
date: '2025.03.06',
|
240
249
|
title: '🔥🔥🔥 上线新模型',
|
meutils/io/files_utils.py
CHANGED
@@ -224,7 +224,18 @@ if __name__ == '__main__':
|
|
224
224
|
|
225
225
|
file = Path("/Users/betterme/PycharmProjects/AI/MeUtils/meutils/io/x.py").read_bytes()
|
226
226
|
|
227
|
-
arun(to_url_fal([file] * 1))
|
227
|
+
# arun(to_url_fal([file] * 1))
|
228
|
+
|
229
|
+
print(mimetypes.guess_type("http://url"))
|
230
|
+
print(mimetypes.guess_type("http://url.pdf"))
|
231
|
+
print(mimetypes.guess_type("http://url.php"))
|
232
|
+
|
233
|
+
print(mimetypes.guess_type("xx.txt"))
|
234
|
+
print(mimetypes.guess_type("xx.html"))
|
235
|
+
print(mimetypes.guess_type("xx.mp3"))
|
236
|
+
print(mimetypes.guess_type("xx.mp4"))
|
237
|
+
|
238
|
+
# print(guess_mime_type("http://url")) # application # msword
|
228
239
|
|
229
240
|
# arun(to_bytes(None))
|
230
241
|
|
meutils/io/openai_files.py
CHANGED
@@ -17,6 +17,7 @@ from meutils.io.files_utils import to_bytes, guess_mime_type
|
|
17
17
|
from meutils.llm.clients import moonshot_client, zhipuai_client, APIStatusError
|
18
18
|
from meutils.notice.feishu import send_message as _send_message, FILES
|
19
19
|
from meutils.caches import cache, rcache
|
20
|
+
from meutils.apis.jina import url_reader
|
20
21
|
|
21
22
|
# from openai.types.file_object import FileObject
|
22
23
|
|
@@ -52,17 +53,28 @@ async def delete_files(client, threshold: int = 666):
|
|
52
53
|
await asyncio.gather(*tasks)
|
53
54
|
|
54
55
|
|
55
|
-
@rcache(ttl=
|
56
|
+
@rcache(ttl=7 * 24 * 3600)
|
56
57
|
async def _file_extract(file):
|
57
58
|
"""
|
58
59
|
|
59
60
|
:param file: url bytes path
|
60
61
|
:return:
|
61
62
|
"""
|
63
|
+
# url
|
62
64
|
|
63
65
|
filename = Path(file).name if isinstance(file, str) else 'untitled'
|
64
66
|
mime_type = guess_mime_type(file)
|
65
67
|
|
68
|
+
if str(file).startswith("http") and mime_type in {"application/octet-stream", "text/html"}:
|
69
|
+
logger.debug(f"jina reader")
|
70
|
+
markdown_content = await url_reader(file)
|
71
|
+
return {
|
72
|
+
'filename': filename,
|
73
|
+
'type': 'file',
|
74
|
+
'file_type': "text/plain",
|
75
|
+
'content': markdown_content,
|
76
|
+
}
|
77
|
+
|
66
78
|
file: bytes = await to_bytes(file)
|
67
79
|
|
68
80
|
for i, client in enumerate([moonshot_client, zhipuai_client]):
|
@@ -134,5 +146,18 @@ if __name__ == '__main__':
|
|
134
146
|
# with timer():
|
135
147
|
# r = arun(file_extract(file, provider='kimi'))
|
136
148
|
|
149
|
+
# with timer():
|
150
|
+
# arun(file_extract(file))
|
151
|
+
|
152
|
+
# with timer():
|
153
|
+
# arun(file_extract("https://top.baidu.com/board?tab=realtime"))
|
154
|
+
|
137
155
|
with timer():
|
156
|
+
file = "https://top.baidu.com/board?tab=realtime"
|
157
|
+
file = "https://oss.ffire.cc/files/百炼系列手机产品介绍.docx"
|
158
|
+
|
138
159
|
arun(file_extract(file))
|
160
|
+
|
161
|
+
# arun(file_extract("/Users/betterme/PycharmProjects/AI/data/041【精选】海门招商重工5G+智慧工厂解决方案.pptx"))
|
162
|
+
# arun(file_extract("/Users/betterme/PycharmProjects/AI/data/098【采集】基于室内定位导航的医院解决方案.pdf"))
|
163
|
+
# arun(file_extract("//Users/betterme/PycharmProjects/AI/data/《 纺织行业场景化解决方案-客户介绍材料》.pptx"))
|