MeUtils 2025.2.6.20.41.23__py3-none-any.whl → 2025.2.13.20.50.5__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.2.6.20.41.23.dist-info → MeUtils-2025.2.13.20.50.5.dist-info}/METADATA +25 -25
- {MeUtils-2025.2.6.20.41.23.dist-info → MeUtils-2025.2.13.20.50.5.dist-info}/RECORD +37 -31
- examples/_openaisdk/openai_chatfire.py +20 -8
- examples/_openaisdk/openai_kindo.py +32 -0
- examples/_openaisdk/openai_modelscope.py +1 -1
- examples/_openaisdk/openai_v.py +38 -0
- examples/_openaisdk/openai_x.py +22 -1
- examples/_openaisdk/testDeepseek.py +67 -0
- meutils/apis/images/edits.py +6 -5
- meutils/apis/jimeng/images.py +8 -8
- meutils/apis/search/metaso.py +6 -19
- meutils/apis/vidu/vidu_video.py +5 -7
- meutils/caches/acache.py +10 -10
- meutils/caches/c.py +29 -0
- meutils/caches/redis_.py +26 -0
- meutils/caches/redis_cache.py +0 -2
- meutils/caches/redis_mulit.py +30 -0
- meutils/data/VERSION +1 -1
- meutils/data/oneapi/NOTICE.md +11 -1
- meutils/hash_utils.py +4 -0
- meutils/llm/clients.py +19 -7
- meutils/llm/completions/agents/search.py +18 -7
- meutils/llm/completions/reasoner.py +20 -11
- meutils/llm/completions/yuanbao.py +37 -28
- meutils/llm/openai_utils/common.py +2 -2
- meutils/oss/minio_oss.py +2 -0
- meutils/schemas/image_types.py +1 -1
- meutils/schemas/metaso_types.py +16 -5
- meutils/schemas/oneapi/common.py +102 -25
- meutils/schemas/openai_types.py +19 -15
- meutils/schemas/vidu_types.py +2 -1
- meutils/schemas/yuanbao_types.py +8 -0
- meutils/serving/fastapi/exceptions/http_error.py +2 -2
- {MeUtils-2025.2.6.20.41.23.dist-info → MeUtils-2025.2.13.20.50.5.dist-info}/LICENSE +0 -0
- {MeUtils-2025.2.6.20.41.23.dist-info → MeUtils-2025.2.13.20.50.5.dist-info}/WHEEL +0 -0
- {MeUtils-2025.2.6.20.41.23.dist-info → MeUtils-2025.2.13.20.50.5.dist-info}/entry_points.txt +0 -0
- {MeUtils-2025.2.6.20.41.23.dist-info → MeUtils-2025.2.13.20.50.5.dist-info}/top_level.txt +0 -0
meutils/apis/search/metaso.py
CHANGED
@@ -97,8 +97,7 @@ async def create(request: ChatCompletionRequest, response_format: Optional[str]
|
|
97
97
|
|
98
98
|
request = MetasoRequest(
|
99
99
|
model=model,
|
100
|
-
mode=MODELS.get(request.model, "
|
101
|
-
engineType=engine_type,
|
100
|
+
mode=MODELS.get(request.model, "detail"),
|
102
101
|
question=request.last_content,
|
103
102
|
response_format=response_format
|
104
103
|
)
|
@@ -124,22 +123,9 @@ async def create(request: ChatCompletionRequest, response_format: Optional[str]
|
|
124
123
|
session_id = await get_session_id(request, headers=headers, proxy=proxy)
|
125
124
|
|
126
125
|
token = await get_access_token(session_id)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
'question': request.question,
|
131
|
-
'mode': request.mode,
|
132
|
-
'engineType': request.engineType,
|
133
|
-
|
134
|
-
"sessionId": session_id,
|
135
|
-
'lang': 'zh',
|
136
|
-
# 'url': f'https://metaso.cn/search/{sessionId}?q={q}',
|
137
|
-
'enableMix': 'true',
|
138
|
-
'scholarSearchDomain': 'all',
|
139
|
-
'expectedCurrentSessionSearchCount': '1',
|
140
|
-
'newEngine': 'true',
|
141
|
-
'enableImage': 'true',
|
142
|
-
}
|
126
|
+
|
127
|
+
params = request.model_dump(exclude_none=True)
|
128
|
+
params['token'] = token
|
143
129
|
|
144
130
|
pattern = re.compile('\[\[(\d+)\]\]')
|
145
131
|
async with httpx.AsyncClient(base_url=BASE_URL, headers=headers, params=params, proxy=proxy) as client:
|
@@ -235,7 +221,8 @@ if __name__ == '__main__':
|
|
235
221
|
|
236
222
|
# model="search-pro",
|
237
223
|
|
238
|
-
messages=[{'role': 'user', 'content': '今天南京天气怎么样'}]
|
224
|
+
# messages=[{'role': 'user', 'content': '今天南京天气怎么样'}]
|
225
|
+
messages=[{'role': 'user', 'content': 'hi'}]
|
239
226
|
|
240
227
|
)
|
241
228
|
|
meutils/apis/vidu/vidu_video.py
CHANGED
@@ -32,12 +32,7 @@ send_message = partial(
|
|
32
32
|
|
33
33
|
|
34
34
|
async def upload(file, token: Optional[str] = None, vip: bool = False): # todo: 统一到 file object
|
35
|
-
token = token or await get_next_token_for_polling(
|
36
|
-
FEISHU_URL_VIP if vip else FEISHU_URL,
|
37
|
-
check_token=check_token,
|
38
|
-
from_redis=True,
|
39
|
-
min_points=4 # 最小消耗
|
40
|
-
)
|
35
|
+
token = token or await get_next_token_for_polling(FEISHU_URL_VIP)
|
41
36
|
|
42
37
|
token = token.strip(";Shunt=").strip("; Shunt=")
|
43
38
|
logger.debug(token)
|
@@ -80,6 +75,9 @@ async def create_task(request: ViduRequest, token: Optional[str] = None, vip: bo
|
|
80
75
|
token = token.strip(";Shunt=").strip("; Shunt=")
|
81
76
|
|
82
77
|
task_type = TaskType.vidu_vip if vip else TaskType.vidu
|
78
|
+
if vip:
|
79
|
+
request.payload['settings']['schedule_mode'] = "nopeak"
|
80
|
+
request.payload['settings']['resolution'] = "720p"
|
83
81
|
|
84
82
|
headers = {
|
85
83
|
"Cookie": token
|
@@ -214,7 +212,7 @@ if __name__ == '__main__':
|
|
214
212
|
}
|
215
213
|
token = None
|
216
214
|
# print(bjson(ViduRequest(**d).payload))
|
217
|
-
arun(create_task(ViduRequest(**d)))
|
215
|
+
arun(create_task(ViduRequest(**d), vip=True))
|
218
216
|
# arun(create_task(ViduRequest(**d), vip=False))
|
219
217
|
# # pass
|
220
218
|
# token = "sensorsdata2015jssdkcross=dfm-enc-%7B%22Va28a6y8_aV%22%3A%22sSsAAnHAInAGEtIG%22%2C%22gae28_aV%22%3A%22EGEuAnststSEirt-ARSAigSVHIiHVs-EtHsHnIR-sARInAA-EGEuAnststHsIti%22%2C%22OemO2%22%3A%7B%22%24ki8r28_8eiggay_2mbeyr_8cOr%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24ki8r28_2rieyz_lrcMmeV%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24ki8r28_ergreere%22%3A%22%22%7D%2C%22aVr68a8ar2%22%3A%22rc3liZ7ku67OV5kgPsGCiskkDskl3qmawFlJPq0swqfcpXNJPZKSBF0IQXLzWq7lQFQzQZNcBF1SQF3EQqwIBF3MQhwswX08wFlJPq0swqfcpXKcwhzz3aMax9klWZHAiD7HDsJCWskbDskl3qmawqNcwX0sQF0hQq0HwFfhp4xG%22%2C%22za28mec_kmfa6_aV%22%3A%7B%226ior%22%3A%22%24aVr68a8c_kmfa6_aV%22%2C%22Cikbr%22%3A%22sSsAAnHAInAGEtIG%22%7D%7D;_ga=GA1.1.2058758439.1724312077;_ga_ZJBV7VYP55=GS1.1.1727080335.38.1.1727080510.0.0.0;JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjgzNTAzODAsImlhdCI6MTcyNzA1NDM4MCwiaXNzIjoiaWFtIiwic3ViIjoiMjQyMDA2NTAzNjA5MTgzOSJ9.PkjQqjYB56vYetYwmlagnWn_6bSCwoxCjI7BjfelBOU;Shunt="
|
meutils/caches/acache.py
CHANGED
@@ -16,24 +16,24 @@ from aiocache import cached
|
|
16
16
|
from aiocache import cached, Cache, RedisCache, caches
|
17
17
|
from aiocache import multi_cached
|
18
18
|
|
19
|
+
|
20
|
+
|
21
|
+
@cached(ttl=60)
|
22
|
+
@cached(ttl=60)
|
23
|
+
async def cached_fc(user_id, **kwargs):
|
24
|
+
logger.debug(user_id)
|
25
|
+
return False
|
26
|
+
#
|
19
27
|
rcache = RedisCache(
|
20
28
|
endpoint="127.0.0.1", port=6379, namespace="me" # 缓存键前缀
|
21
29
|
)
|
22
|
-
|
23
|
-
|
24
|
-
# @cached(ttl=60)
|
25
|
-
# async def cached_fc(user_id, **kwargs):
|
26
|
-
# logger.debug(user_id)
|
27
|
-
# return False
|
28
|
-
|
29
|
-
|
30
30
|
@cached(ttl=60, cache=rcache)
|
31
31
|
async def redis_fc(user_id, **kwargs):
|
32
32
|
logger.debug(user_id)
|
33
33
|
return False
|
34
34
|
|
35
35
|
|
36
|
-
# @multi_cached(ttl=60
|
36
|
+
# @multi_cached(ttl=60) # 多key缓存
|
37
37
|
# async def complex_function(user_id, **kwargs):
|
38
38
|
# logger.debug(user_id)
|
39
39
|
# return False
|
@@ -63,4 +63,4 @@ class A(BaseModel):
|
|
63
63
|
|
64
64
|
|
65
65
|
if __name__ == '__main__':
|
66
|
-
arun(
|
66
|
+
arun(cached_fc(A()))
|
meutils/caches/c.py
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
import asyncio
|
2
|
+
|
3
|
+
from collections import namedtuple
|
4
|
+
import redis.asyncio as redis
|
5
|
+
|
6
|
+
from aiocache import cached
|
7
|
+
from aiocache import RedisCache
|
8
|
+
from aiocache.serializers import PickleSerializer
|
9
|
+
|
10
|
+
Result = namedtuple('Result', "content, status")
|
11
|
+
|
12
|
+
cache = RedisCache(namespace="main", client=redis.Redis(), serializer=PickleSerializer())
|
13
|
+
|
14
|
+
|
15
|
+
@cached(cache, ttl=10, key_builder=lambda *args, **kw: "key")
|
16
|
+
async def cached_call():
|
17
|
+
return Result("content", 200)
|
18
|
+
|
19
|
+
|
20
|
+
async def test_cached():
|
21
|
+
async with cache:
|
22
|
+
await cached_call()
|
23
|
+
exists = await cache.exists("key")
|
24
|
+
assert exists is True
|
25
|
+
await cache.delete("key")
|
26
|
+
|
27
|
+
|
28
|
+
if __name__ == "__main__":
|
29
|
+
asyncio.run(test_cached())
|
meutils/caches/redis_.py
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
import asyncio
|
2
|
+
|
3
|
+
from aiocache import Cache
|
4
|
+
|
5
|
+
|
6
|
+
cache = Cache(Cache.REDIS, endpoint="127.0.0.1", port=6379, namespace="main")
|
7
|
+
|
8
|
+
|
9
|
+
async def redis():
|
10
|
+
await cache.set("key", "value")
|
11
|
+
await cache.set("expire_me", "value", ttl=10)
|
12
|
+
|
13
|
+
assert await cache.get("key") == "value"
|
14
|
+
assert await cache.get("expire_me") == "value"
|
15
|
+
assert await cache.raw("ttl", "main:expire_me") > 0
|
16
|
+
|
17
|
+
|
18
|
+
async def test_redis():
|
19
|
+
await redis()
|
20
|
+
await cache.delete("key")
|
21
|
+
await cache.delete("expire_me")
|
22
|
+
await cache.close()
|
23
|
+
|
24
|
+
|
25
|
+
if __name__ == "__main__":
|
26
|
+
asyncio.run(test_redis())
|
meutils/caches/redis_cache.py
CHANGED
@@ -29,13 +29,11 @@ acache_inmemory = hermes.Hermes(
|
|
29
29
|
)
|
30
30
|
|
31
31
|
|
32
|
-
from aiocache import cached, Cache, RedisCache
|
33
32
|
|
34
33
|
|
35
34
|
if __name__ == '__main__':
|
36
35
|
from meutils.pipe import *
|
37
36
|
|
38
|
-
@cached(ttl=100)
|
39
37
|
@cache(tags=('test',))
|
40
38
|
async def foo(a, b):
|
41
39
|
time.sleep(3)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import asyncio
|
2
|
+
|
3
|
+
from aiocache import multi_cached, Cache
|
4
|
+
|
5
|
+
DICT = {
|
6
|
+
'a': "Z",
|
7
|
+
'b': "Y",
|
8
|
+
'c': "X",
|
9
|
+
'd': "W"
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
# @multi_cached("ids", cache=Cache.REDIS, namespace="main")
|
14
|
+
# async def multi_cached_ids(ids=None):
|
15
|
+
# return {id_: DICT[id_] for id_ in ids}
|
16
|
+
|
17
|
+
|
18
|
+
@multi_cached("keys", cache=Cache.REDIS, namespace="main")
|
19
|
+
async def multi_cached_keys(keys=None):
|
20
|
+
return keys
|
21
|
+
|
22
|
+
# cache = Cache(Cache.REDIS, endpoint="127.0.0.1", port=6379, namespace="main")
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
if __name__ == "__main__":
|
29
|
+
# test_multi_cached()
|
30
|
+
asyncio.run(multi_cached_keys('xxx'))
|
meutils/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2025.02.
|
1
|
+
2025.02.13.20.50.05
|
meutils/data/oneapi/NOTICE.md
CHANGED
@@ -35,7 +35,17 @@
|
|
35
35
|
<summary><b>大额对公,请联系客服</b></summary>
|
36
36
|
</details>
|
37
37
|
|
38
|
-
## 2025-02-
|
38
|
+
## 2025-02-10
|
39
|
+
### 上线新模型
|
40
|
+
- qwen2.5-max: 比deepseek-v3效果更好,更智能(权威排行榜更靠前)
|
41
|
+
|
42
|
+
## 2025-02-06
|
43
|
+
### 上线新模型
|
44
|
+
- deepseek-r1-think: 兼容任意客户端,再也不用担心看不到`深度思考`了
|
45
|
+
- deepseek-search: 搜索+深度思考
|
46
|
+
- deepseek-r1-search: 搜索+深度思考
|
47
|
+
- deepseek-r1-metasearch: 秘塔搜索+深度思考
|
48
|
+
|
39
49
|
- deepseek-ai/deepseek-v3
|
40
50
|
- 即日起至北京时间 2025-02-09 00:00 同步官网倍率
|
41
51
|
|
meutils/hash_utils.py
CHANGED
meutils/llm/clients.py
CHANGED
@@ -26,6 +26,11 @@ zhipuai_client = AsyncOpenAI(
|
|
26
26
|
base_url=os.getenv("ZHIPUAI_BASE_URL")
|
27
27
|
)
|
28
28
|
|
29
|
+
# zhipuai_client = OpenAI(
|
30
|
+
# api_key=os.getenv("ZHIPUAI_API_KEY"),
|
31
|
+
# base_url=os.getenv("ZHIPUAI_BASE_URL")
|
32
|
+
# )
|
33
|
+
|
29
34
|
if __name__ == '__main__':
|
30
35
|
from meutils.pipe import *
|
31
36
|
|
@@ -34,11 +39,18 @@ if __name__ == '__main__':
|
|
34
39
|
# arun(zhipuai_client.chat.completions.create(messages=[{"role": "user", "content": "hi"}], model='glm-4-flash'))
|
35
40
|
|
36
41
|
# web-search-pro
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
)
|
42
|
-
|
43
|
-
r.
|
42
|
+
# s = zhipuai_client.chat.completions.create(
|
43
|
+
# messages=[{"role": "user", "content": "《哪吒之魔童闹海》现在的票房是多少"}],
|
44
|
+
# model='web-search-pro',
|
45
|
+
# stream=True
|
46
|
+
# )
|
47
|
+
#
|
48
|
+
# r = arun(zhipuai_client.chat.completions.create(
|
49
|
+
# messages=[{"role": "user", "content": "《哪吒之魔童闹海》现在的票房是多少"}],
|
50
|
+
# model='web-search-pro',
|
51
|
+
# stream=True
|
52
|
+
# )
|
53
|
+
# )
|
54
|
+
|
55
|
+
# r.model_dump_json()
|
44
56
|
|
@@ -90,19 +90,29 @@ class Completions(object):
|
|
90
90
|
completion = await client.chat.completions.create(**data)
|
91
91
|
return completion
|
92
92
|
|
93
|
+
elif request.model.startswith("search"): # 智谱
|
94
|
+
data = to_openai_params(request)
|
95
|
+
|
96
|
+
search_completion = await zhipuai_client.chat.completions.create(**data)
|
97
|
+
search_completion.model_dump_json(indent=4)
|
98
|
+
|
99
|
+
|
93
100
|
else:
|
94
101
|
# 搜索
|
95
102
|
data = to_openai_params(request)
|
96
103
|
data['model'] = "web-search-pro"
|
97
104
|
data['stream'] = False
|
98
105
|
search_completion = await zhipuai_client.chat.completions.create(**data)
|
99
|
-
logger.debug(search_completion) # todo: 返回详细信息
|
106
|
+
logger.debug(search_completion.model_dump_json(indent=4)) # todo: 返回详细信息
|
107
|
+
# todo: chat搜索接口 搜索内容重排序 搜索聚合
|
100
108
|
|
101
109
|
# 大模型
|
102
|
-
request.messages.append(
|
103
|
-
|
104
|
-
|
105
|
-
|
110
|
+
request.messages.append(
|
111
|
+
{
|
112
|
+
"role": "user",
|
113
|
+
"content": search_completion.model_dump_json(indent=4),
|
114
|
+
}
|
115
|
+
)
|
106
116
|
|
107
117
|
data = to_openai_params(request)
|
108
118
|
completion = await chatfire_client.chat.completions.create(**data)
|
@@ -114,13 +124,14 @@ if __name__ == '__main__':
|
|
114
124
|
# model="baichuan4-turbo",
|
115
125
|
# model="xx",
|
116
126
|
# model="deepseek-r1",
|
117
|
-
model="deepseek-r1:1.5b",
|
127
|
+
# model="deepseek-r1:1.5b",
|
128
|
+
model="deepseek-r1:32b",
|
118
129
|
|
119
130
|
# model="moonshot-v1-8k",
|
120
131
|
# model="doubao",
|
121
132
|
|
122
133
|
messages=[
|
123
|
-
{"role": "user", "content": "
|
134
|
+
{"role": "user", "content": "《哪吒之魔童闹海》现在的票房是多少"}
|
124
135
|
],
|
125
136
|
|
126
137
|
stream=False
|
@@ -44,9 +44,6 @@ def extract_think_content(content):
|
|
44
44
|
return "", content
|
45
45
|
|
46
46
|
|
47
|
-
reasoning = True
|
48
|
-
|
49
|
-
|
50
47
|
class Completions(object):
|
51
48
|
|
52
49
|
def __init__(self, api_key: Optional[str] = None, base_url: Optional[str] = None, reasoning_stream: bool = True):
|
@@ -68,15 +65,18 @@ class Completions(object):
|
|
68
65
|
completion_chunks = await self.client.chat.completions.create(**data)
|
69
66
|
|
70
67
|
is_reasoning_content = True
|
71
|
-
reasoning_prefix = "> Reasoning\n"
|
72
|
-
reasoning_suffix = "Reasoned for "
|
68
|
+
# reasoning_prefix = "> Reasoning\n"
|
69
|
+
# reasoning_suffix = "Reasoned for "
|
70
|
+
reasoning_prefix = "```reasoning\n"
|
71
|
+
reasoning_suffix = "\n```\n"
|
73
72
|
|
74
73
|
async for chunk in completion_chunks:
|
75
74
|
# chunk.model = "deepseek-reasoner"
|
76
75
|
message = chunk.choices[0].delta
|
77
|
-
message.content = message.content or ""
|
76
|
+
message.content = message.content or "" ########## 损失了?message chunk #########应该是很多值未带进chunk 中转站自定义渠道bug 参数放请求头吧
|
78
77
|
|
79
|
-
|
78
|
+
# logger.debug(message)
|
79
|
+
if not hasattr(message, 'reasoning_content'): # 标准化 finish_reason
|
80
80
|
message.reasoning_content = ""
|
81
81
|
if is_reasoning_content:
|
82
82
|
message.reasoning_content = (
|
@@ -84,7 +84,7 @@ class Completions(object):
|
|
84
84
|
.replace("</think>", "")
|
85
85
|
.replace("\n\n", "\n")
|
86
86
|
)
|
87
|
-
if
|
87
|
+
if "</think>" in message.content: # 思考结束
|
88
88
|
is_reasoning_content = False
|
89
89
|
message.content = ""
|
90
90
|
|
@@ -92,18 +92,22 @@ class Completions(object):
|
|
92
92
|
|
93
93
|
if self.reasoning_stream: # 适配任意客户端: 展示推理内容
|
94
94
|
|
95
|
-
if message.reasoning_content.strip(): # 思考开始
|
95
|
+
if message.reasoning_content and message.reasoning_content.strip(): # 思考开始
|
96
96
|
message.content = f"{reasoning_prefix}{message.reasoning_content}"
|
97
97
|
reasoning_prefix = ""
|
98
98
|
|
99
99
|
elif message.content: # 思考结束
|
100
100
|
if reasoning_suffix:
|
101
|
-
message.content = f"{
|
101
|
+
message.content = f"{message.content.rstrip()}{reasoning_suffix}"
|
102
|
+
# message.content = f"{reasoning_suffix} {time.perf_counter() - s:.0f} seconds.\n{message.content}"
|
102
103
|
reasoning_suffix = ""
|
103
104
|
|
104
105
|
yield chunk
|
106
|
+
# logger.debug(chunk)
|
105
107
|
else:
|
106
108
|
yield chunk
|
109
|
+
# logger.debug(chunk)
|
110
|
+
|
107
111
|
|
108
112
|
else: # 非流
|
109
113
|
completions = await self.client.chat.completions.create(**data)
|
@@ -114,6 +118,10 @@ class Completions(object):
|
|
114
118
|
if not hasattr(message, 'reasoning_content'):
|
115
119
|
reasoning_content, content = extract_think_content(message.content)
|
116
120
|
|
121
|
+
if content.strip().startswith("<think>"): # max tokens
|
122
|
+
reasoning_content = content.replace("<think>", "")
|
123
|
+
content = ""
|
124
|
+
|
117
125
|
completions.choices[0].message.reasoning_content = reasoning_content
|
118
126
|
completions.choices[0].message.content = content
|
119
127
|
|
@@ -137,9 +145,10 @@ if __name__ == '__main__':
|
|
137
145
|
# model="qwen-plus-latest",
|
138
146
|
|
139
147
|
# model="deepseek-r1:1.5b",
|
148
|
+
model="DeepSeek-R1-Distill-Qwen-1.5B",
|
140
149
|
# model="deepseek-r1:32b",
|
141
150
|
#
|
142
|
-
model="deepseek-r1",
|
151
|
+
# model="deepseek-r1",
|
143
152
|
# model
|
144
153
|
|
145
154
|
messages=[
|
@@ -43,6 +43,7 @@ class Completions(object):
|
|
43
43
|
self,
|
44
44
|
request: Optional[ChatCompletionRequest] = None,
|
45
45
|
image_request: Optional[HunyuanImageRequest] = None,
|
46
|
+
enable_search: bool = False,
|
46
47
|
token: Optional[str] = None
|
47
48
|
):
|
48
49
|
token = token or await get_next_token_for_polling(FEISHU_URL, check_token=check_token)
|
@@ -53,8 +54,9 @@ class Completions(object):
|
|
53
54
|
|
54
55
|
payload = {
|
55
56
|
"model": "gpt_175B_0404",
|
57
|
+
"chatModelId": "deep_seek",
|
56
58
|
"version": "v2",
|
57
|
-
"supportHint": 2,
|
59
|
+
"supportHint": 2, # 1
|
58
60
|
|
59
61
|
"prompt": prompt,
|
60
62
|
# "displayPrompt": "画条可爱的狗狗",
|
@@ -94,6 +96,11 @@ class Completions(object):
|
|
94
96
|
}
|
95
97
|
)
|
96
98
|
|
99
|
+
if enable_search:
|
100
|
+
payload['supportFunctions'] = [
|
101
|
+
"supportInternetSearch"
|
102
|
+
]
|
103
|
+
|
97
104
|
headers = {
|
98
105
|
'cookie': token
|
99
106
|
}
|
@@ -112,6 +119,7 @@ class Completions(object):
|
|
112
119
|
yield sse.image
|
113
120
|
|
114
121
|
if request:
|
122
|
+
|
115
123
|
yield sse.content
|
116
124
|
|
117
125
|
def generate_id(self, random: bool = True):
|
@@ -140,33 +148,34 @@ async def check_token(token):
|
|
140
148
|
|
141
149
|
|
142
150
|
if __name__ == '__main__':
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
151
|
+
# chatid = generate_id()
|
152
|
+
# print(chatid)
|
153
|
+
# print(delete_conv(chatid))
|
154
|
+
# payload = {
|
155
|
+
# # "model": "gpt_175B_0404",
|
156
|
+
# # "prompt": "1+1",
|
157
|
+
# "prompt": "错了",
|
158
|
+
#
|
159
|
+
# # "plugin": "Adaptive",
|
160
|
+
# # "displayPrompt": "1+1",
|
161
|
+
# # "displayPromptType": 1,
|
162
|
+
# # "options": {},
|
163
|
+
# # "multimedia": [],
|
164
|
+
# # "agentId": "naQivTmsDa",
|
165
|
+
# # "version": "v2"
|
166
|
+
# }
|
167
|
+
# chat(payload)
|
168
|
+
|
169
|
+
# async2sync_generator(Completions(api_key).achat('画条狗')) | xprint
|
170
|
+
# request = HunyuanImageRequest(prompt='画条狗', size='16:9')
|
171
|
+
|
172
|
+
arun(Completions().create(
|
173
|
+
ChatCompletionRequest(messages=[{'role': 'user', 'content': '南京天气如何'}]),
|
174
|
+
# image_request=request,
|
175
|
+
# token=token
|
176
|
+
enable_search=True
|
177
|
+
))
|
178
|
+
# arun(Completions.generate(request))
|
170
179
|
|
171
180
|
# df = arun(aget_spreadsheet_values(feishu_url=FEISHU__URL, to_dataframe=True))
|
172
181
|
#
|
@@ -207,7 +207,7 @@ async def create_chat_completion_chunk(
|
|
207
207
|
# logger.debug(type(completion_chunks))
|
208
208
|
|
209
209
|
chat_completion_chunk.id = chat_id or f"chatcmpl-{shortuuid.random()}"
|
210
|
-
chat_completion_chunk_stop.id = chat_completion_chunk.id
|
210
|
+
chat_completion_chunk_stop.id = chat_completion_chunk.id
|
211
211
|
async for completion_chunk in achain(completion_chunks):
|
212
212
|
|
213
213
|
# logger.debug(completion_chunk)
|
@@ -218,7 +218,7 @@ async def create_chat_completion_chunk(
|
|
218
218
|
yield chat_completion_chunk.model_dump_json()
|
219
219
|
else: # todo: AttributeError: 'tuple' object has no attribute 'model'
|
220
220
|
try:
|
221
|
-
chat_completion_chunk_stop.id =
|
221
|
+
chat_completion_chunk_stop.id = completion_chunk.id ##############
|
222
222
|
completion_chunk.model = redirect_model or completion_chunk.model
|
223
223
|
chat_completion_chunk_stop.usage = completion_chunk.usage ############## 需要判断 usage?
|
224
224
|
yield completion_chunk.model_dump_json()
|
meutils/oss/minio_oss.py
CHANGED
meutils/schemas/image_types.py
CHANGED
meutils/schemas/metaso_types.py
CHANGED
@@ -23,21 +23,32 @@ class MetasoRequest(BaseModel):
|
|
23
23
|
question: str = "Chatfire"
|
24
24
|
|
25
25
|
"""全网 文库 学术 图片 播客"""
|
26
|
-
engineType: str = "" # scholar
|
27
|
-
|
28
26
|
scholarSearchDomain: str = "all"
|
29
27
|
|
28
|
+
url: str = "https://metaso.cn/"
|
29
|
+
lang: str = "zh"
|
30
|
+
|
30
31
|
searchTopicId: Optional[str] = None
|
31
32
|
searchTopicName: Optional[str] = None
|
32
33
|
|
33
|
-
enableMix:
|
34
|
-
newEngine:
|
35
|
-
enableImage:
|
34
|
+
enableMix: str = 'true'
|
35
|
+
newEngine: str = 'true'
|
36
|
+
enableImage: str = 'true'
|
36
37
|
|
37
38
|
# 自定义字段
|
38
39
|
response_format: Optional[str] = None # 原生内容
|
39
40
|
|
40
41
|
|
42
|
+
# question: hi
|
43
|
+
# mode: detail
|
44
|
+
# scholarSearchDomain: all
|
45
|
+
# model: ds-r1
|
46
|
+
# url: https://metaso.cn/
|
47
|
+
# lang: zh
|
48
|
+
# enableMix: true
|
49
|
+
# newEngine: true
|
50
|
+
# enableImage: true
|
51
|
+
# metaso-pc: pc
|
41
52
|
class MetasoResponse(BaseModel): # sse
|
42
53
|
|
43
54
|
type: Optional[str] = None # query set-reference heartbeat append-text
|