aient 1.1.49__py3-none-any.whl → 1.1.51__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.
aient/core/request.py CHANGED
@@ -239,26 +239,50 @@ async def get_gemini_payload(request, engine, provider, api_key=None):
239
239
  ]
240
240
 
241
241
  if "gemini-2.5" in original_model:
242
- payload["generationConfig"]["thinkingConfig"] = {
243
- "includeThoughts": True,
244
- }
242
+ generation_config = payload.get("generationConfig", {})
245
243
  # 从请求模型名中检测思考预算设置
246
244
  m = re.match(r".*-think-(-?\d+)", request.model)
247
245
  if m:
248
246
  try:
249
247
  val = int(m.group(1))
250
- if val > 32768 and "gemini-2.5-pro" in original_model:
251
- val = 32768
252
- elif val < 128 and "gemini-2.5-pro" in original_model:
253
- val = 128
254
- elif val <= 0:
255
- val = 0
256
- elif val > 24576:
257
- val = 24576
258
- payload["generationConfig"]["thinkingConfig"]["thinkingBudget"] = val
248
+ budget = None
249
+ # gemini-2.5-pro: [128, 32768]
250
+ if "gemini-2.5-pro" in original_model:
251
+ if val < 128:
252
+ budget = 128
253
+ elif val > 32768:
254
+ budget = 32768
255
+ else: # 128 <= val <= 32768
256
+ budget = val
257
+
258
+ # gemini-2.5-flash-lite: [0] or [512, 24576]
259
+ elif "gemini-2.5-flash-lite" in original_model:
260
+ if val > 0 and val < 512:
261
+ budget = 512
262
+ elif val > 24576:
263
+ budget = 24576
264
+ else: # Includes 0 and valid range, and clamps invalid negatives
265
+ budget = val if val >= 0 else 0
266
+
267
+ # gemini-2.5-flash (and other gemini-2.5 models as a fallback): [0, 24576]
268
+ else:
269
+ if val > 24576:
270
+ budget = 24576
271
+ else: # Includes 0 and valid range, and clamps invalid negatives
272
+ budget = val if val >= 0 else 0
273
+
274
+ payload["generationConfig"]["thinkingConfig"] = {
275
+ "includeThoughts": True,
276
+ "thinkingBudget": budget
277
+ }
259
278
  except ValueError:
260
279
  # 如果转换为整数失败,忽略思考预算设置
261
280
  pass
281
+ else:
282
+ payload["generationConfig"]["thinkingConfig"] = {
283
+ "includeThoughts": True,
284
+ }
285
+ payload["generationConfig"] = generation_config
262
286
 
263
287
  # # 检测search标签
264
288
  # if request.model.endswith("-search"):
@@ -535,26 +559,48 @@ async def get_vertex_gemini_payload(request, engine, provider, api_key=None):
535
559
  payload["generationConfig"]["max_output_tokens"] = 8192
536
560
 
537
561
  if "gemini-2.5" in original_model:
538
- payload["generationConfig"]["thinkingConfig"] = {
539
- "includeThoughts": True,
540
- }
541
562
  # 从请求模型名中检测思考预算设置
542
563
  m = re.match(r".*-think-(-?\d+)", request.model)
543
564
  if m:
544
565
  try:
545
566
  val = int(m.group(1))
546
- if val > 32768 and "gemini-2.5-pro" in original_model:
547
- val = 32768
548
- elif val < 128 and "gemini-2.5-pro" in original_model:
549
- val = 128
550
- elif val <= 0:
551
- val = 0
552
- elif val > 24576:
553
- val = 24576
554
- payload["generationConfig"]["thinkingConfig"]["thinkingBudget"] = val
567
+ budget = None
568
+ # gemini-2.5-pro: [128, 32768]
569
+ if "gemini-2.5-pro" in original_model:
570
+ if val < 128:
571
+ budget = 128
572
+ elif val > 32768:
573
+ budget = 32768
574
+ else: # 128 <= val <= 32768
575
+ budget = val
576
+
577
+ # gemini-2.5-flash-lite: [0] or [512, 24576]
578
+ elif "gemini-2.5-flash-lite" in original_model:
579
+ if val > 0 and val < 512:
580
+ budget = 512
581
+ elif val > 24576:
582
+ budget = 24576
583
+ else: # Includes 0 and valid range, and clamps invalid negatives
584
+ budget = val if val >= 0 else 0
585
+
586
+ # gemini-2.5-flash (and other gemini-2.5 models as a fallback): [0, 24576]
587
+ else:
588
+ if val > 24576:
589
+ budget = 24576
590
+ else: # Includes 0 and valid range, and clamps invalid negatives
591
+ budget = val if val >= 0 else 0
592
+
593
+ payload["generationConfig"]["thinkingConfig"] = {
594
+ "includeThoughts": True,
595
+ "thinkingBudget": budget
596
+ }
555
597
  except ValueError:
556
598
  # 如果转换为整数失败,忽略思考预算设置
557
599
  pass
600
+ else:
601
+ payload["generationConfig"]["thinkingConfig"] = {
602
+ "includeThoughts": True,
603
+ }
558
604
 
559
605
  # if request.model.endswith("-search"):
560
606
  # payload["tools"] = [search_tool]
@@ -44,6 +44,8 @@ def url_to_markdown(url):
44
44
  body = body[0]
45
45
  body = Cleaner(javascript=True, style=True).clean_html(body)
46
46
  return ''.join(lxml.html.tostring(c, encoding='unicode') for c in body)
47
+ except ImportError as e:
48
+ raise e
47
49
  except Exception as e:
48
50
  # print('\033[31m')
49
51
  # print("error: url_to_markdown url", url)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.49
3
+ Version: 1.1.51
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ aient/core/.gitignore,sha256=5JRRlYYsqt_yt6iFvvzhbqh2FTUQMqwo6WwIuFzlGR8,13
4
4
  aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
5
5
  aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
6
6
  aient/core/models.py,sha256=d4MISNezTSe0ls0-fjuToI2SoT-sk5fWqAJuKVinIlo,7502
7
- aient/core/request.py,sha256=8HlSFaBhWMs5thhL4C5qj-hvuDZWUXCYWwVShFR99QU,72263
7
+ aient/core/request.py,sha256=7KpHHDyu0t2g4IQGqlV_UxK0zAAjN_-CZpyd7S5pxS0,74263
8
8
  aient/core/response.py,sha256=-28HYKuzgfC1y7VOrYLk75_QH5yh6c1IS024yoQM0mg,35671
9
9
  aient/core/utils.py,sha256=NcXdb8zBN0GE01OGaUzg8U34RaraoFf2MaLDDGFvvC4,27492
10
10
  aient/core/test/test_base_api.py,sha256=pWnycRJbuPSXKKU9AQjWrMAX1wiLC_014Qc9hh5C2Pw,524
@@ -32,13 +32,13 @@ aient/plugins/read_image.py,sha256=4FbIiMNVFUQpNyiH5ApGSRvOD9ujcXGyuqlGTJMd7ac,4
32
32
  aient/plugins/readonly.py,sha256=qK5-kBM3NDH1b-otFxFHpAjV5BXEY_e7cTWBcpP7G5k,710
33
33
  aient/plugins/registry.py,sha256=YknzhieU_8nQ3oKlUSSWDB4X7t2Jx0JnqT2Jd9Xsvfk,3574
34
34
  aient/plugins/run_python.py,sha256=MohvdtZUTDLrHBDtJ9L2_Qu1pWAGrkbzsGmmn5tMN20,4614
35
- aient/plugins/websearch.py,sha256=LPS5NmHrY-Rc0FCPlhHrUWE90XJmXF_AvShLHTV_Zqc,15285
35
+ aient/plugins/websearch.py,sha256=9yImBa1s5V7Djqzx6L4naDyIsGIcf_js1LOyLX0aNHw,15338
36
36
  aient/plugins/write_file.py,sha256=hExFLuoNPtjYxJI3pVbofZRpokvUabpXdEkd3mZJPPc,3778
37
37
  aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
38
  aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
39
39
  aient/utils/scripts.py,sha256=h7EA2xBydUF_wdZLsPgjCq4Egdycx1gf2qrdrm0I7y0,40909
40
- aient-1.1.49.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
41
- aient-1.1.49.dist-info/METADATA,sha256=Rh9kejUXQzYWIdZ5WkPCWUeeXP8CJdf-U_sbzHVBzVk,4968
42
- aient-1.1.49.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
- aient-1.1.49.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
44
- aient-1.1.49.dist-info/RECORD,,
40
+ aient-1.1.51.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
41
+ aient-1.1.51.dist-info/METADATA,sha256=A95Z-MfIht74gmYiyPeTwtx9BdiuxrDbXIfhfUHBc08,4968
42
+ aient-1.1.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ aient-1.1.51.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
44
+ aient-1.1.51.dist-info/RECORD,,
File without changes