aient 1.1.53__py3-none-any.whl → 1.1.54__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
@@ -1354,7 +1354,8 @@ async def get_openrouter_payload(request, engine, provider, api_key=None):
1354
1354
 
1355
1355
  messages = []
1356
1356
  for msg in request.messages:
1357
- name = None
1357
+ tool_calls = None
1358
+ tool_call_id = None
1358
1359
  if isinstance(msg.content, list):
1359
1360
  content = []
1360
1361
  for item in msg.content:
@@ -1366,9 +1367,25 @@ async def get_openrouter_payload(request, engine, provider, api_key=None):
1366
1367
  content.append(image_message)
1367
1368
  else:
1368
1369
  content = msg.content
1369
- name = msg.name
1370
- if name:
1371
- messages.append({"role": msg.role, "name": name, "content": content})
1370
+ tool_calls = msg.tool_calls
1371
+ tool_call_id = msg.tool_call_id
1372
+
1373
+ if tool_calls:
1374
+ tool_calls_list = []
1375
+ for tool_call in tool_calls:
1376
+ tool_calls_list.append({
1377
+ "id": tool_call.id,
1378
+ "type": tool_call.type,
1379
+ "function": {
1380
+ "name": tool_call.function.name,
1381
+ "arguments": tool_call.function.arguments
1382
+ }
1383
+ })
1384
+ if provider.get("tools"):
1385
+ messages.append({"role": msg.role, "tool_calls": tool_calls_list})
1386
+ elif tool_call_id:
1387
+ if provider.get("tools"):
1388
+ messages.append({"role": msg.role, "tool_call_id": tool_call_id, "content": content})
1372
1389
  else:
1373
1390
  # print("content", content)
1374
1391
  if isinstance(content, list):
aient/core/response.py CHANGED
@@ -42,11 +42,12 @@ def gemini_json_poccess(response_str):
42
42
  is_thinking = safe_get(json_data, "parts", 0, "thought", default=False)
43
43
 
44
44
  function_call_name = safe_get(json_data, "functionCall", "name", default=None)
45
- function_full_response = json.dumps(safe_get(json_data, "functionCall", "args", default=""))
45
+ function_full_response = safe_get(json_data, "functionCall", "args", default="")
46
+ function_full_response = json.dumps(function_full_response) if function_full_response else None
46
47
 
47
48
  blockReason = safe_get(json_data, 0, "promptFeedback", "blockReason", default=None)
48
49
 
49
- return is_thinking, content, image_base64, function_call_name, function_full_response, blockReason, promptTokenCount, candidatesTokenCount, totalTokenCount
50
+ return is_thinking, content, image_base64, function_call_name, function_full_response, finishReason, blockReason, promptTokenCount, candidatesTokenCount, totalTokenCount
50
51
 
51
52
  async def fetch_gemini_response_stream(client, url, headers, payload, model):
52
53
  timestamp = int(datetime.timestamp(datetime.now()))
@@ -62,7 +63,6 @@ async def fetch_gemini_response_stream(client, url, headers, payload, model):
62
63
  parts_json = ""
63
64
  async for chunk in response.aiter_text():
64
65
  buffer += chunk
65
- cache_buffer += chunk
66
66
 
67
67
  while "\n" in buffer:
68
68
  line, buffer = buffer.split("\n", 1)
@@ -77,7 +77,7 @@ async def fetch_gemini_response_stream(client, url, headers, payload, model):
77
77
  continue
78
78
 
79
79
  # https://ai.google.dev/api/generate-content?hl=zh-cn#FinishReason
80
- is_thinking, content, image_base64, function_call_name, function_full_response, blockReason, promptTokenCount, candidatesTokenCount, totalTokenCount = gemini_json_poccess(parts_json)
80
+ is_thinking, content, image_base64, function_call_name, function_full_response, finishReason, blockReason, promptTokenCount, candidatesTokenCount, totalTokenCount = gemini_json_poccess(parts_json)
81
81
 
82
82
  if is_thinking:
83
83
  sse_string = await generate_sse_response(timestamp, model, reasoning_content=content)
@@ -99,9 +99,10 @@ async def fetch_gemini_response_stream(client, url, headers, payload, model):
99
99
  if parts_json == "[]" or blockReason == "PROHIBITED_CONTENT":
100
100
  sse_string = await generate_sse_response(timestamp, model, stop="PROHIBITED_CONTENT")
101
101
  yield sse_string
102
- else:
102
+ elif finishReason:
103
103
  sse_string = await generate_sse_response(timestamp, model, stop="stop")
104
104
  yield sse_string
105
+ break
105
106
 
106
107
  parts_json = ""
107
108
 
aient/models/chatgpt.py CHANGED
@@ -187,7 +187,8 @@ class chatgpt(BaseLLM):
187
187
  # print(json.dumps(replaced_text, indent=4, ensure_ascii=False))
188
188
  while message_index < conversation_len:
189
189
  if self.conversation[convo_id][message_index]["role"] == self.conversation[convo_id][message_index + 1]["role"]:
190
- if self.conversation[convo_id][message_index].get("content") and self.conversation[convo_id][message_index + 1].get("content"):
190
+ if self.conversation[convo_id][message_index].get("content") and self.conversation[convo_id][message_index + 1].get("content") \
191
+ and self.conversation[convo_id][message_index].get("content") != self.conversation[convo_id][message_index + 1].get("content"):
191
192
  if type(self.conversation[convo_id][message_index + 1]["content"]) == str \
192
193
  and type(self.conversation[convo_id][message_index]["content"]) == list:
193
194
  self.conversation[convo_id][message_index + 1]["content"] = [{"type": "text", "text": self.conversation[convo_id][message_index + 1]["content"]}]
@@ -754,8 +755,8 @@ class chatgpt(BaseLLM):
754
755
 
755
756
  # 打印日志
756
757
  if self.print_log:
757
- print("api_url", kwargs.get('api_url', self.api_url.chat_url) == url)
758
- print("api_url", kwargs.get('api_url', self.api_url.chat_url))
758
+ # print("api_url", kwargs.get('api_url', self.api_url.chat_url) == url)
759
+ # print("api_url", kwargs.get('api_url', self.api_url.chat_url))
759
760
  print("api_url", url)
760
761
  # print("headers", headers)
761
762
  print("api_key", kwargs.get('api_key', self.api_key))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.53
3
+ Version: 1.1.54
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -4,8 +4,8 @@ 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=1tedDQf8GRv5Y7rYNE_596vQb4o7e1icaKAA7lIl4YY,76114
8
- aient/core/response.py,sha256=Ba0BwsIN2ozZC_UInkGS07qKlpo3dIei6rw0INQ66BE,33086
7
+ aient/core/request.py,sha256=GrB8hQY1K8AF1O9f5g-hoY8fwZR4SUNNhvCDpuhHVl0,76822
8
+ aient/core/response.py,sha256=LwaDyCuuT0RPxBwE08k8_Dmh0df_q7q4BUix7NcCJV8,33207
9
9
  aient/core/utils.py,sha256=8TR442o3VV7Kl9l6f6LlmOUQ1UDZ-aXMzQqm-qIrqE4,28166
10
10
  aient/core/test/test_base_api.py,sha256=pWnycRJbuPSXKKU9AQjWrMAX1wiLC_014Qc9hh5C2Pw,524
11
11
  aient/core/test/test_geminimask.py,sha256=HFX8jDbNg_FjjgPNxfYaR-0-roUrOO-ND-FVsuxSoiw,13254
@@ -14,7 +14,7 @@ aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9XkdsuuKFGrwFhF
14
14
  aient/models/__init__.py,sha256=ouNDNvoBBpIFrLsk09Q_sq23HR0GbLAKfGLIFmfEuXE,219
15
15
  aient/models/audio.py,sha256=kRd-8-WXzv4vwvsTGwnstK-WR8--vr9CdfCZzu8y9LA,1934
16
16
  aient/models/base.py,sha256=z-Z0pJfTN2x0cuwfvu0BdMRY9O-RmLwHEnBIJN1x4Fg,6719
17
- aient/models/chatgpt.py,sha256=Yum3_-LgHmFUII0AljfNNfSc8gBhJzyPYAWZJyr4yFo,46969
17
+ aient/models/chatgpt.py,sha256=UP7cn6Vo0bXzj6FpqTHIOjg1UygYQDXMSlUbXbH1uU4,47118
18
18
  aient/models/claude.py,sha256=JezghW7y0brl4Y5qiSHvnYR5prQCFywX4RViHt39pGI,26037
19
19
  aient/models/duckduckgo.py,sha256=1l7vYCs9SG5SWPCbcl7q6pCcB5AUF_r-a4l9frz3Ogo,8115
20
20
  aient/models/gemini.py,sha256=chGLc-8G_DAOxr10HPoOhvVFW1RvMgHd6mt--VyAW98,14730
@@ -37,8 +37,8 @@ aient/plugins/write_file.py,sha256=hExFLuoNPtjYxJI3pVbofZRpokvUabpXdEkd3mZJPPc,3
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.53.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
41
- aient-1.1.53.dist-info/METADATA,sha256=jAig2OUeje7xn_pBPGi85qGsfRft0ReHMNdHnJxG-CQ,4968
42
- aient-1.1.53.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
- aient-1.1.53.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
44
- aient-1.1.53.dist-info/RECORD,,
40
+ aient-1.1.54.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
41
+ aient-1.1.54.dist-info/METADATA,sha256=u4mZpFMSy7ySTnxlB-OpoWvOMO0fthZvzcQbSZrtt_k,4968
42
+ aient-1.1.54.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ aient-1.1.54.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
44
+ aient-1.1.54.dist-info/RECORD,,
File without changes