MeUtils 2025.4.18.14.53.20__py3-none-any.whl → 2025.4.19.13.52.36__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.
@@ -7,6 +7,7 @@
7
7
  # @WeChat : meutils
8
8
  # @Software : PyCharm
9
9
  # @Description :
10
+ import streamlit
10
11
 
11
12
  from meutils.pipe import *
12
13
  from meutils.io.files_utils import to_base64
@@ -34,12 +35,15 @@ class Completions(object):
34
35
  async def create(self, request: CompletionRequest):
35
36
 
36
37
  ###########################################################################
37
-
38
38
  # 开启视觉模型
39
39
  if not any(i in request.model for i in ["vl", 'vision']) and (urls := request.last_urls.get("image_url")):
40
40
  # logger.debug(request)
41
- if request.model.startswith(("gemini",)): # 仅支持base64
42
- base64_list = await to_base64(urls, content_type="image/png") ######## todo: tokens怎么计算的
41
+ if request.model.startswith(("gemini",)):
42
+ if urls[-1].startswith("http"):
43
+ base64_list = await to_base64(urls, content_type="image/png")
44
+ else:
45
+ base64_list = urls # 仅支持base64 todo: tokens怎么计算的
46
+
43
47
  request.messages = [
44
48
  {
45
49
  'role': 'user',
@@ -62,8 +66,8 @@ class Completions(object):
62
66
  }
63
67
  ]
64
68
  else:
65
- # logger.debug('xxxxxxxx')
66
69
  request.model = "glm-4v-flash"
70
+ request.max_tokens = None
67
71
  self.client = zhipuai_client
68
72
  ###########################################################################
69
73
 
@@ -102,7 +106,7 @@ if __name__ == '__main__':
102
106
  },
103
107
  {
104
108
  "image_url": {
105
- "detail": "auto",
109
+ # "detail": "auto",
106
110
  "url": "https://osshk.share704.com/file/upload/2025/04/14/1911575959253815296.jpg"
107
111
  },
108
112
  "type": "image_url"
@@ -110,6 +114,38 @@ if __name__ == '__main__':
110
114
  ]}
111
115
  ],
112
116
  stream=False,
113
- max_tokens=8000,
117
+ max_tokens=None,
114
118
  )
115
- arun(Completions().create(request))
119
+ # arun(Completions().create(request))
120
+ d = {
121
+ "model": "gemini-2.5-pro-exp-03-25",
122
+ "messages": [
123
+ {
124
+ "content": [
125
+ {
126
+ "text": "The following is an open-ended problem from an International Math competition. Please calculate the answer according to the given requirements and the information provided. Please use LaTeX format to represent the variables and formulas used in the solution process and results. Please end your solution with \"So the final answer is \boxed{multiple answers connected with commas}(unit).\" and give the result explicitly, note that the unit of the answer should not be included in \boxed{}.\nConsider the following system of equations in which all logarithms have base 10:\n\n$$\n\begin{aligned}\n(\log x)(\log y)-3 \log 5 y-\log 8 x & =a \\n(\log y)(\log z)-4 \log 5 y-\log 16 z & =b \\n(\log z)(\log x)-4 \log 8 x-3 \log 625 z & =c\n\end{aligned}\n$$\nIf $a=-4, b=4$, and $c=-18$, solve the system of equations.",
127
+ "type": "text"
128
+ },
129
+ {
130
+ "image_url": {
131
+ "detail": "low",
132
+ "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABAAEADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//2Q=="
133
+ },
134
+ "type": "image_url"
135
+ }
136
+ ],
137
+ "role": "user"
138
+ }
139
+ ],
140
+ "stream": False,
141
+ "top_p": 0.7,
142
+ "temperature": 0.7,
143
+ "n": 1
144
+ }
145
+
146
+ # request = request.construct(**d)
147
+ from meutils.io.files_utils import to_url
148
+
149
+ # arun(to_url(request.last_urls.get("image_url")[-1], filename='x.jpeg'))
150
+
151
+ arun(Completions().create(request.construct(**d)))
meutils/notice/feishu.py CHANGED
@@ -31,18 +31,18 @@ def send_message(
31
31
  url: str = DEFAULT,
32
32
  n: int = 1,
33
33
  ):
34
- if any(i in str(content).lower() for i in {'重定向', 'pass'}):
35
- return
34
+ logger.debug(f"数据类型:{type(content)}")
35
+ logger.debug(content)
36
36
 
37
37
  if any((content, title)):
38
38
 
39
39
  if isinstance(content, str): # todo: post_process
40
40
  content = content.replace("<", "【").replace(">", "】")
41
41
  contents = [content]
42
- # contents = [{"a": 1}]*3
43
42
 
44
43
  elif isinstance(content, (list,)):
45
44
  contents = list(map(bjson, content))
45
+ # logger.debug(bjson(contents))
46
46
 
47
47
  elif isinstance(content, (dict,)):
48
48
  contents = [bjson(content)]
@@ -63,7 +63,7 @@ def send_message(
63
63
  "content": str(content),
64
64
  "tag": "lark_md"
65
65
  }
66
- } for content in contents if ";base64," not in (str(content)) # 忽略base64
66
+ } for content in contents # if ";base64," not in str(content) # 忽略base64
67
67
  ],
68
68
  "header": {
69
69
  "title": {
@@ -73,11 +73,14 @@ def send_message(
73
73
  }
74
74
  }
75
75
  }
76
- r = None
76
+
77
77
  for i in range(n):
78
78
  time.sleep(i ** 2)
79
- r = httpx.post(url, json=message)
80
- return r and r.text
79
+ r = httpx.post(url, json=message, timeout=30)
80
+ r.raise_for_status()
81
+
82
+ if r.status_code != 200 or r.json()['code'] != 0:
83
+ logger.debug(r.text)
81
84
 
82
85
 
83
86
  @decorator
@@ -118,8 +121,9 @@ if __name__ == '__main__':
118
121
  # send_message("xxx", title=None)
119
122
  send_message(None, title=None)
120
123
 
121
- send_message_for_images("xxxxxxxx", title=None)
124
+ # send_message_for_images("xxxxxxxx", title=None)
122
125
 
126
+ send_message_for_try_catch("xxxxxxxx")
123
127
  # @catch(task_name='这是一个任务名')
124
128
  # def f():
125
129
  # time.sleep(3)
@@ -99,6 +99,9 @@ MODEL_PRICE = {
99
99
  "api-images-recraftv3": 0.1,
100
100
  "api-images-seededit": 0.1,
101
101
 
102
+ "seedream-3.0": 0.05,
103
+ "chat-seedream-3.0": 0.05,
104
+
102
105
  "seededit": 0.1,
103
106
  "chat-seededit": 0.1,
104
107
 
@@ -250,7 +253,8 @@ MODEL_PRICE = {
250
253
 
251
254
  "gpt-4-all": 0.1,
252
255
  "gpt-4o-all": 0.1,
253
- "gpt-4o-image": 0.06,
256
+ "gpt-4o-image": 0.05,
257
+ "sora-image": 0.1,
254
258
 
255
259
  "gpt-4-gizmo-*": 0.1,
256
260
  "advanced-voice": 1,
@@ -616,6 +620,7 @@ MODEL_RATIO = {
616
620
  "doubao-1-5-thinking-pro-250415": 2,
617
621
  "doubao-1-5-thinking-pro-vision": 2,
618
622
  "doubao-1-5-thinking-pro-vision-250415": 2,
623
+ "doubao-1-5-thinking-pro-m-250415": 2,
619
624
 
620
625
  # 商汤 https://platform.sensenova.cn/pricing
621
626
  # https://platform.sensenova.cn/doc?path=/pricingdoc/pricing.md
@@ -1058,6 +1063,7 @@ COMPLETION_RATIO = {
1058
1063
  "doubao-1-5-thinking-pro-250415": 4,
1059
1064
  "doubao-1-5-thinking-pro-vision": 4,
1060
1065
  "doubao-1-5-thinking-pro-vision-250415": 4,
1066
+ "doubao-1-5-thinking-pro-m-250415": 4,
1061
1067
 
1062
1068
  "deepseek-r1:1.5b": 4,
1063
1069
  "deepseek-r1-distill-qwen-1.5b": 4,
@@ -1317,7 +1323,7 @@ if __name__ == '__main__':
1317
1323
 
1318
1324
  option()
1319
1325
  # #
1320
- # arun(channel.edit_channel(MODEL_PRICE))
1326
+ arun(channel.edit_channel(MODEL_PRICE))
1321
1327
 
1322
1328
  print(bjson({k: v * 6 for k, v in MODEL_RATIO.items() if k.startswith('claude')}))
1323
1329
  print([k for k in MODEL_RATIO if k.startswith('gpt-4.1')] | xjoin(","))
@@ -18,7 +18,7 @@ from typing import Dict, Optional
18
18
  # return dict(request.headers)
19
19
 
20
20
  def get_headers(request: Request):
21
- return request.headers
21
+ return dict(request.headers)
22
22
 
23
23
  # lambda request: dict(request.headers)
24
24
  # @app.get("/headers/")