aient 1.1.66__py3-none-any.whl → 1.1.68__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/response.py CHANGED
@@ -390,7 +390,7 @@ async def fetch_cloudflare_response_stream(client, url, headers, payload, model)
390
390
  async def fetch_cohere_response_stream(client, url, headers, payload, model):
391
391
  timestamp = int(datetime.timestamp(datetime.now()))
392
392
  async with client.stream('POST', url, headers=headers, json=payload) as response:
393
- error_message = await check_response(response, "fetch_gpt_response_stream")
393
+ error_message = await check_response(response, "fetch_cohere_response_stream")
394
394
  if error_message:
395
395
  yield error_message
396
396
  return
aient/models/chatgpt.py CHANGED
@@ -67,6 +67,7 @@ class chatgpt(BaseLLM):
67
67
  cut_history_by_function_name: str = "",
68
68
  cache_messages: list = None,
69
69
  logger: logging.Logger = None,
70
+ check_done: bool = False,
70
71
  ) -> None:
71
72
  """
72
73
  Initialize Chatbot with API key (from https://platform.openai.com/account/api-keys)
@@ -86,6 +87,7 @@ class chatgpt(BaseLLM):
86
87
  self.function_call_max_loop = function_call_max_loop
87
88
  self.cut_history_by_function_name = cut_history_by_function_name
88
89
  self.latest_file_content = {}
90
+ self.check_done = check_done
89
91
 
90
92
  if logger:
91
93
  self.logger = logger
@@ -465,6 +467,14 @@ class chatgpt(BaseLLM):
465
467
  missing_required_params = []
466
468
 
467
469
  if self.use_plugins == True:
470
+ if self.check_done:
471
+ # self.logger.info(f"worker Response: {full_response}")
472
+ if not full_response.strip().endswith('[done]'):
473
+ raise Exception(f"Response is not ended with [done]: {full_response}")
474
+ elif not full_response.strip():
475
+ raise Exception(f"Response is empty")
476
+ else:
477
+ full_response = full_response.strip().rstrip('[done]')
468
478
  full_response = full_response.replace("<tool_code>", "").replace("</tool_code>", "")
469
479
  function_parameter = parse_function_xml(full_response)
470
480
  if function_parameter:
@@ -711,7 +721,7 @@ class chatgpt(BaseLLM):
711
721
  self.logger.info(f"api_key: {kwargs.get('api_key', self.api_key)}")
712
722
 
713
723
  # 发送请求并处理响应
714
- for i in range(3):
724
+ for i in range(30):
715
725
  if self.print_log:
716
726
  replaced_text = json.loads(re.sub(r';base64,([A-Za-z0-9+/=]+)', ';base64,***', json.dumps(json_post)))
717
727
  replaced_text_str = json.dumps(replaced_text, indent=4, ensure_ascii=False)
@@ -763,6 +773,9 @@ class chatgpt(BaseLLM):
763
773
  except httpx.RemoteProtocolError:
764
774
  continue
765
775
  except Exception as e:
776
+ if "Response is" in str(e):
777
+ self.logger.error(f"{e}")
778
+ continue
766
779
  self.logger.error(f"发生了未预料的错误:{e}")
767
780
  import traceback
768
781
  self.logger.error(traceback.format_exc())
@@ -770,7 +783,7 @@ class chatgpt(BaseLLM):
770
783
  e = "您输入了无效的API URL,请使用正确的URL并使用`/start`命令重新设置API URL。具体错误如下:\n\n" + str(e)
771
784
  raise Exception(f"{e}")
772
785
  # 最后一次重试失败,向上抛出异常
773
- if i == 2:
786
+ if i == 11:
774
787
  raise Exception(f"{e}")
775
788
 
776
789
  def ask_stream(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.66
3
+ Version: 1.1.68
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -3,7 +3,7 @@ aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
3
3
  aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
4
4
  aient/core/models.py,sha256=d4MISNezTSe0ls0-fjuToI2SoT-sk5fWqAJuKVinIlo,7502
5
5
  aient/core/request.py,sha256=4FFCwQ7h7b6bqtrA8qw-DPJVXZTj2i1CkYccFeEwUPw,76552
6
- aient/core/response.py,sha256=sPcNV9qLosj3lIXElezUZEjIyglspdkBg-EsIUhr9bQ,33203
6
+ aient/core/response.py,sha256=tYKWOeexYEhWK4napIAfYjCn2rQ1zpxRvknsBBWrv2M,33206
7
7
  aient/core/utils.py,sha256=D98d5Cy1h4ejKtuxS0EEDtL4YqpaZLB5tuXoVP0IBWQ,28462
8
8
  aient/core/test/test_base_api.py,sha256=pWnycRJbuPSXKKU9AQjWrMAX1wiLC_014Qc9hh5C2Pw,524
9
9
  aient/core/test/test_geminimask.py,sha256=HFX8jDbNg_FjjgPNxfYaR-0-roUrOO-ND-FVsuxSoiw,13254
@@ -12,7 +12,7 @@ aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9XkdsuuKFGrwFhF
12
12
  aient/models/__init__.py,sha256=ZTiZgbfBPTjIPSKURE7t6hlFBVLRS9lluGbmqc1WjxQ,43
13
13
  aient/models/audio.py,sha256=kRd-8-WXzv4vwvsTGwnstK-WR8--vr9CdfCZzu8y9LA,1934
14
14
  aient/models/base.py,sha256=-nnihYnx-vHZMqeVO9ljjt3k4FcD3n-iMk4tT-10nRQ,7232
15
- aient/models/chatgpt.py,sha256=t9P0PsMsjnqjv3MrUKNKC1-gy7Pf9tOb8BhBPcnbhMw,48741
15
+ aient/models/chatgpt.py,sha256=sIAr_0jnux4VBnMu13wzWH1EBRdYuD7MmKHmI_QOixo,49396
16
16
  aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
17
17
  aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
18
18
  aient/plugins/config.py,sha256=2DXH-LP9KGl_P4467chJu3q4AAbX5nSn4DIkdI0aYH8,7105
@@ -30,8 +30,8 @@ aient/plugins/write_file.py,sha256=Jt8fOEwqhYiSWpCbwfAr1xoi_BmFnx3076GMhuL06uI,3
30
30
  aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
32
32
  aient/utils/scripts.py,sha256=VqtK4RFEx7KxkmcqG3lFDS1DxoNlFFGErEjopVcc8IE,40974
33
- aient-1.1.66.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
34
- aient-1.1.66.dist-info/METADATA,sha256=sAVJU71_BYtagFIvhB9RefiumnVUFPTA9vrhOba01R8,4842
35
- aient-1.1.66.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- aient-1.1.66.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
37
- aient-1.1.66.dist-info/RECORD,,
33
+ aient-1.1.68.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
34
+ aient-1.1.68.dist-info/METADATA,sha256=duF98k4OVbuSq6w-AU4ENUEzwloNGeq-5q08o3n8EDs,4842
35
+ aient-1.1.68.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
+ aient-1.1.68.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
37
+ aient-1.1.68.dist-info/RECORD,,
File without changes