aient 1.1.60__tar.gz → 1.1.61__tar.gz

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.
Files changed (51) hide show
  1. {aient-1.1.60 → aient-1.1.61}/PKG-INFO +1 -1
  2. {aient-1.1.60 → aient-1.1.61}/aient/models/chatgpt.py +72 -33
  3. {aient-1.1.60 → aient-1.1.61}/aient.egg-info/PKG-INFO +1 -1
  4. {aient-1.1.60 → aient-1.1.61}/pyproject.toml +1 -1
  5. {aient-1.1.60 → aient-1.1.61}/LICENSE +0 -0
  6. {aient-1.1.60 → aient-1.1.61}/README.md +0 -0
  7. {aient-1.1.60 → aient-1.1.61}/aient/__init__.py +0 -0
  8. {aient-1.1.60 → aient-1.1.61}/aient/core/__init__.py +0 -0
  9. {aient-1.1.60 → aient-1.1.61}/aient/core/log_config.py +0 -0
  10. {aient-1.1.60 → aient-1.1.61}/aient/core/models.py +0 -0
  11. {aient-1.1.60 → aient-1.1.61}/aient/core/request.py +0 -0
  12. {aient-1.1.60 → aient-1.1.61}/aient/core/response.py +0 -0
  13. {aient-1.1.60 → aient-1.1.61}/aient/core/test/test_base_api.py +0 -0
  14. {aient-1.1.60 → aient-1.1.61}/aient/core/test/test_geminimask.py +0 -0
  15. {aient-1.1.60 → aient-1.1.61}/aient/core/test/test_image.py +0 -0
  16. {aient-1.1.60 → aient-1.1.61}/aient/core/test/test_payload.py +0 -0
  17. {aient-1.1.60 → aient-1.1.61}/aient/core/utils.py +0 -0
  18. {aient-1.1.60 → aient-1.1.61}/aient/models/__init__.py +0 -0
  19. {aient-1.1.60 → aient-1.1.61}/aient/models/audio.py +0 -0
  20. {aient-1.1.60 → aient-1.1.61}/aient/models/base.py +0 -0
  21. {aient-1.1.60 → aient-1.1.61}/aient/plugins/__init__.py +0 -0
  22. {aient-1.1.60 → aient-1.1.61}/aient/plugins/arXiv.py +0 -0
  23. {aient-1.1.60 → aient-1.1.61}/aient/plugins/config.py +0 -0
  24. {aient-1.1.60 → aient-1.1.61}/aient/plugins/excute_command.py +0 -0
  25. {aient-1.1.60 → aient-1.1.61}/aient/plugins/get_time.py +0 -0
  26. {aient-1.1.60 → aient-1.1.61}/aient/plugins/image.py +0 -0
  27. {aient-1.1.60 → aient-1.1.61}/aient/plugins/list_directory.py +0 -0
  28. {aient-1.1.60 → aient-1.1.61}/aient/plugins/read_file.py +0 -0
  29. {aient-1.1.60 → aient-1.1.61}/aient/plugins/read_image.py +0 -0
  30. {aient-1.1.60 → aient-1.1.61}/aient/plugins/readonly.py +0 -0
  31. {aient-1.1.60 → aient-1.1.61}/aient/plugins/registry.py +0 -0
  32. {aient-1.1.60 → aient-1.1.61}/aient/plugins/run_python.py +0 -0
  33. {aient-1.1.60 → aient-1.1.61}/aient/plugins/websearch.py +0 -0
  34. {aient-1.1.60 → aient-1.1.61}/aient/plugins/write_file.py +0 -0
  35. {aient-1.1.60 → aient-1.1.61}/aient/utils/__init__.py +0 -0
  36. {aient-1.1.60 → aient-1.1.61}/aient/utils/prompt.py +0 -0
  37. {aient-1.1.60 → aient-1.1.61}/aient/utils/scripts.py +0 -0
  38. {aient-1.1.60 → aient-1.1.61}/aient.egg-info/SOURCES.txt +0 -0
  39. {aient-1.1.60 → aient-1.1.61}/aient.egg-info/dependency_links.txt +0 -0
  40. {aient-1.1.60 → aient-1.1.61}/aient.egg-info/requires.txt +0 -0
  41. {aient-1.1.60 → aient-1.1.61}/aient.egg-info/top_level.txt +0 -0
  42. {aient-1.1.60 → aient-1.1.61}/setup.cfg +0 -0
  43. {aient-1.1.60 → aient-1.1.61}/test/test_Web_crawler.py +0 -0
  44. {aient-1.1.60 → aient-1.1.61}/test/test_ddg_search.py +0 -0
  45. {aient-1.1.60 → aient-1.1.61}/test/test_google_search.py +0 -0
  46. {aient-1.1.60 → aient-1.1.61}/test/test_ollama.py +0 -0
  47. {aient-1.1.60 → aient-1.1.61}/test/test_plugin.py +0 -0
  48. {aient-1.1.60 → aient-1.1.61}/test/test_search.py +0 -0
  49. {aient-1.1.60 → aient-1.1.61}/test/test_url.py +0 -0
  50. {aient-1.1.60 → aient-1.1.61}/test/test_whisper.py +0 -0
  51. {aient-1.1.60 → aient-1.1.61}/test/test_yjh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.60
3
+ Version: 1.1.61
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -17,7 +17,7 @@ from ..plugins.registry import registry
17
17
  from ..plugins import PLUGINS, get_tools_result_async, function_call_list, update_tools_config
18
18
  from ..utils.scripts import safe_get, async_generator_to_sync, parse_function_xml, parse_continuous_json, convert_functions_to_xml, remove_xml_tags_and_content
19
19
  from ..core.request import prepare_request_payload
20
- from ..core.response import fetch_response_stream
20
+ from ..core.response import fetch_response_stream, fetch_response
21
21
 
22
22
  def get_filtered_keys_from_object(obj: object, *keys: str) -> Set[str]:
23
23
  """
@@ -288,6 +288,7 @@ class chatgpt(BaseLLM):
288
288
  convo_id: str = "default",
289
289
  model: str = "",
290
290
  pass_history: int = 9999,
291
+ stream: bool = True,
291
292
  **kwargs,
292
293
  ):
293
294
  self.conversation[convo_id][0] = {"role": "system","content": self.system_prompt + "\n\n" + self.get_latest_file_content()}
@@ -309,12 +310,13 @@ class chatgpt(BaseLLM):
309
310
  {"role": "system","content": self.system_prompt + "\n\n" + self.get_latest_file_content()},
310
311
  {"role": role, "content": prompt}
311
312
  ],
312
- "stream": True,
313
- "stream_options": {
314
- "include_usage": True
315
- },
313
+ "stream": stream,
316
314
  "temperature": kwargs.get("temperature", self.temperature)
317
315
  }
316
+ if stream:
317
+ request_data["stream_options"] = {
318
+ "include_usage": True
319
+ }
318
320
 
319
321
  if kwargs.get("max_tokens", self.max_tokens):
320
322
  request_data["max_tokens"] = kwargs.get("max_tokens", self.max_tokens)
@@ -687,6 +689,7 @@ class chatgpt(BaseLLM):
687
689
  function_call_id: str = "",
688
690
  language: str = "English",
689
691
  system_prompt: str = None,
692
+ stream: bool = True,
690
693
  **kwargs,
691
694
  ):
692
695
  """
@@ -702,7 +705,7 @@ class chatgpt(BaseLLM):
702
705
  json_post = None
703
706
  async def get_post_body_async():
704
707
  nonlocal json_post
705
- url, headers, json_post, engine_type = await self.get_post_body(prompt, role, convo_id, model, pass_history, **kwargs)
708
+ url, headers, json_post, engine_type = await self.get_post_body(prompt, role, convo_id, model, pass_history, stream=stream, **kwargs)
706
709
  return url, headers, json_post, engine_type
707
710
 
708
711
  # 替换原来的获取请求体的代码
@@ -760,14 +763,24 @@ class chatgpt(BaseLLM):
760
763
  yield f"data: {json.dumps(tmp_response)}\n\n"
761
764
  async_generator = _mock_response_generator()
762
765
  else:
763
- async_generator = fetch_response_stream(
764
- self.aclient,
765
- url,
766
- headers,
767
- json_post,
768
- engine_type,
769
- model or self.engine,
770
- )
766
+ if stream:
767
+ async_generator = fetch_response_stream(
768
+ self.aclient,
769
+ url,
770
+ headers,
771
+ json_post,
772
+ engine_type,
773
+ model or self.engine,
774
+ )
775
+ else:
776
+ async_generator = fetch_response(
777
+ self.aclient,
778
+ url,
779
+ headers,
780
+ json_post,
781
+ engine_type,
782
+ model or self.engine,
783
+ )
771
784
  # 异步处理响应流
772
785
  async for chunk in self._process_stream_response(
773
786
  async_generator,
@@ -817,6 +830,7 @@ class chatgpt(BaseLLM):
817
830
  function_call_id: str = "",
818
831
  language: str = "English",
819
832
  system_prompt: str = None,
833
+ stream: bool = True,
820
834
  **kwargs,
821
835
  ):
822
836
  """
@@ -829,7 +843,7 @@ class chatgpt(BaseLLM):
829
843
  self.add_to_conversation(prompt, role, convo_id=convo_id, function_name=function_name, total_tokens=total_tokens, function_arguments=function_arguments, pass_history=pass_history, function_call_id=function_call_id)
830
844
 
831
845
  # 获取请求体
832
- url, headers, json_post, engine_type = await self.get_post_body(prompt, role, convo_id, model, pass_history, **kwargs)
846
+ url, headers, json_post, engine_type = await self.get_post_body(prompt, role, convo_id, model, pass_history, stream=stream, **kwargs)
833
847
  self.truncate_conversation(convo_id=convo_id)
834
848
 
835
849
  # 打印日志
@@ -874,24 +888,24 @@ class chatgpt(BaseLLM):
874
888
  yield f"data: {json.dumps(tmp_response)}\n\n"
875
889
  generator = _mock_response_generator()
876
890
  else:
877
- generator = fetch_response_stream(
878
- self.aclient,
879
- url,
880
- headers,
881
- json_post,
882
- engine_type,
883
- model or self.engine,
884
- )
885
- # if isinstance(chunk, dict) and "error" in chunk:
886
- # # 处理错误响应
887
- # if chunk["status_code"] in (400, 422, 503):
888
- # json_post, should_retry = await self._handle_response_error(
889
- # type('Response', (), {'status_code': chunk["status_code"], 'text': json.dumps(chunk["details"]), 'aread': lambda: asyncio.sleep(0)}),
890
- # json_post
891
- # )
892
- # if should_retry:
893
- # break # 跳出内部循环,继续外部循环重试
894
- # raise Exception(f"{chunk['status_code']} {chunk['error']} {chunk['details']}")
891
+ if stream:
892
+ generator = fetch_response_stream(
893
+ self.aclient,
894
+ url,
895
+ headers,
896
+ json_post,
897
+ engine_type,
898
+ model or self.engine,
899
+ )
900
+ else:
901
+ generator = fetch_response(
902
+ self.aclient,
903
+ url,
904
+ headers,
905
+ json_post,
906
+ engine_type,
907
+ model or self.engine,
908
+ )
895
909
 
896
910
  # 处理正常响应
897
911
  async for processed_chunk in self._process_stream_response(
@@ -943,11 +957,36 @@ class chatgpt(BaseLLM):
943
957
  convo_id=convo_id,
944
958
  pass_history=pass_history,
945
959
  model=model or self.engine,
960
+ stream=False,
946
961
  **kwargs,
947
962
  )
948
963
  full_response: str = "".join([r async for r in response])
949
964
  return full_response
950
965
 
966
+ def ask(
967
+ self,
968
+ prompt: str,
969
+ role: str = "user",
970
+ convo_id: str = "default",
971
+ model: str = "",
972
+ pass_history: int = 9999,
973
+ **kwargs,
974
+ ) -> str:
975
+ """
976
+ Non-streaming ask
977
+ """
978
+ response = self.ask_stream(
979
+ prompt=prompt,
980
+ role=role,
981
+ convo_id=convo_id,
982
+ pass_history=pass_history,
983
+ model=model or self.engine,
984
+ stream=False,
985
+ **kwargs,
986
+ )
987
+ full_response: str = "".join([r for r in response])
988
+ return full_response
989
+
951
990
  def rollback(self, n: int = 1, convo_id: str = "default") -> None:
952
991
  """
953
992
  Rollback the conversation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.60
3
+ Version: 1.1.61
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aient"
3
- version = "1.1.60"
3
+ version = "1.1.61"
4
4
  description = "Aient: The Awakening of Agent."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes