aient 1.0.93__py3-none-any.whl → 1.0.94__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/models/claude.py CHANGED
@@ -2,7 +2,6 @@ import os
2
2
  import re
3
3
  import json
4
4
  import copy
5
- import tiktoken
6
5
  import requests
7
6
 
8
7
  from .base import BaseLLM
@@ -65,39 +64,6 @@ class claude(BaseLLM):
65
64
  self.conversation[convo_id] = claudeConversation()
66
65
  self.system_prompt = system_prompt or self.system_prompt
67
66
 
68
- def __truncate_conversation(self, convo_id: str = "default") -> None:
69
- """
70
- Truncate the conversation
71
- """
72
- while True:
73
- if (
74
- self.get_token_count(convo_id) > self.truncate_limit
75
- and len(self.conversation[convo_id]) > 1
76
- ):
77
- # Don't remove the first message
78
- self.conversation[convo_id].pop(1)
79
- else:
80
- break
81
-
82
- def get_token_count(self, convo_id: str = "default") -> int:
83
- """
84
- Get token count
85
- """
86
- tiktoken.model.MODEL_TO_ENCODING["claude-2.1"] = "cl100k_base"
87
- encoding = tiktoken.encoding_for_model(self.engine)
88
-
89
- num_tokens = 0
90
- for message in self.conversation[convo_id]:
91
- # every message follows <im_start>{role/name}\n{content}<im_end>\n
92
- num_tokens += 5
93
- for key, value in message.items():
94
- if value:
95
- num_tokens += len(encoding.encode(value))
96
- if key == "name": # if there's a name, the role is omitted
97
- num_tokens += 5 # role is always required and always 1 token
98
- num_tokens += 5 # every reply is primed with <im_start>assistant
99
- return num_tokens
100
-
101
67
  def ask_stream(
102
68
  self,
103
69
  prompt: str,
@@ -267,39 +233,6 @@ class claude3(BaseLLM):
267
233
  self.conversation[convo_id] = list()
268
234
  self.system_prompt = system_prompt or self.system_prompt
269
235
 
270
- def __truncate_conversation(self, convo_id: str = "default") -> None:
271
- """
272
- Truncate the conversation
273
- """
274
- while True:
275
- if (
276
- self.get_token_count(convo_id) > self.truncate_limit
277
- and len(self.conversation[convo_id]) > 1
278
- ):
279
- # Don't remove the first message
280
- self.conversation[convo_id].pop(1)
281
- else:
282
- break
283
-
284
- def get_token_count(self, convo_id: str = "default") -> int:
285
- """
286
- Get token count
287
- """
288
- tiktoken.model.MODEL_TO_ENCODING["claude-2.1"] = "cl100k_base"
289
- encoding = tiktoken.encoding_for_model(self.engine)
290
-
291
- num_tokens = 0
292
- for message in self.conversation[convo_id]:
293
- # every message follows <im_start>{role/name}\n{content}<im_end>\n
294
- num_tokens += 5
295
- for key, value in message.items():
296
- if value:
297
- num_tokens += len(encoding.encode(value))
298
- if key == "name": # if there's a name, the role is omitted
299
- num_tokens += 5 # role is always required and always 1 token
300
- num_tokens += 5 # every reply is primed with <im_start>assistant
301
- return num_tokens
302
-
303
236
  def ask_stream(
304
237
  self,
305
238
  prompt: str,
aient/models/groq.py CHANGED
@@ -1,7 +1,6 @@
1
1
  import os
2
2
  import json
3
3
  import requests
4
- import tiktoken
5
4
 
6
5
  from .base import BaseLLM
7
6
 
@@ -52,39 +51,6 @@ class groq(BaseLLM):
52
51
  self.conversation[convo_id] = list()
53
52
  self.system_prompt = system_prompt or self.system_prompt
54
53
 
55
- def __truncate_conversation(self, convo_id: str = "default") -> None:
56
- """
57
- Truncate the conversation
58
- """
59
- while True:
60
- if (
61
- self.get_token_count(convo_id) > self.truncate_limit
62
- and len(self.conversation[convo_id]) > 1
63
- ):
64
- # Don't remove the first message
65
- self.conversation[convo_id].pop(1)
66
- else:
67
- break
68
-
69
- def get_token_count(self, convo_id: str = "default") -> int:
70
- """
71
- Get token count
72
- """
73
- # tiktoken.model.MODEL_TO_ENCODING["mixtral-8x7b-32768"] = "cl100k_base"
74
- encoding = tiktoken.get_encoding("cl100k_base")
75
-
76
- num_tokens = 0
77
- for message in self.conversation[convo_id]:
78
- # every message follows <im_start>{role/name}\n{content}<im_end>\n
79
- num_tokens += 5
80
- for key, value in message.items():
81
- if value:
82
- num_tokens += len(encoding.encode(value))
83
- if key == "name": # if there's a name, the role is omitted
84
- num_tokens += 5 # role is always required and always 1 token
85
- num_tokens += 5 # every reply is primed with <im_start>assistant
86
- return num_tokens
87
-
88
54
  def ask_stream(
89
55
  self,
90
56
  prompt: str,
aient/plugins/config.py CHANGED
@@ -3,8 +3,7 @@ import json
3
3
  import inspect
4
4
 
5
5
  from .registry import registry
6
- from ..utils.scripts import cut_message
7
- from ..utils.prompt import search_key_word_prompt, arxiv_doc_user_prompt
6
+ from ..utils.prompt import search_key_word_prompt
8
7
 
9
8
  async def get_tools_result_async(function_call_name, function_full_response, function_call_max_tokens, engine, robot, api_key, api_url, use_plugins, model, add_message, convo_id, language):
10
9
  function_response = ""
@@ -26,10 +25,7 @@ async def get_tools_result_async(function_call_name, function_full_response, fun
26
25
  yield chunk
27
26
  else:
28
27
  function_response = "\n\n".join(chunk)
29
- # function_response = yield chunk
30
- # function_response = yield from eval(function_call_name)(prompt, keywords)
31
- function_call_max_tokens = 32000
32
- function_response, text_len = cut_message(function_response, function_call_max_tokens, engine)
28
+
33
29
  if function_response:
34
30
  function_response = (
35
31
  f"You need to response the following question: {prompt}. Search results is provided inside <Search_results></Search_results> XML tags. Your task is to think about the question step by step and then answer the above question in {language} based on the Search results provided. Please response in {language} and adopt a style that is logical, in-depth, and detailed. Note: In order to make the answer appear highly professional, you should be an expert in textual analysis, aiming to make the answer precise and comprehensive. Directly response markdown format, without using markdown code blocks. For each sentence quoting search results, a markdown ordered superscript number url link must be used to indicate the source, e.g., [¹](https://www.example.com)"
@@ -40,18 +36,13 @@ async def get_tools_result_async(function_call_name, function_full_response, fun
40
36
  ).format(function_response)
41
37
  else:
42
38
  function_response = "无法找到相关信息,停止使用 tools"
43
- # user_prompt = f"You need to response the following question: {prompt}. Search results is provided inside <Search_results></Search_results> XML tags. Your task is to think about the question step by step and then answer the above question in {config.language} based on the Search results provided. Please response in {config.language} and adopt a style that is logical, in-depth, and detailed. Note: In order to make the answer appear highly professional, you should be an expert in textual analysis, aiming to make the answer precise and comprehensive. Directly response markdown format, without using markdown code blocks"
44
- # self.add_to_conversation(user_prompt, "user", convo_id=convo_id)
39
+
45
40
  elif function_to_call:
46
41
  prompt = json.loads(function_full_response)
47
42
  if inspect.iscoroutinefunction(function_to_call):
48
43
  function_response = await function_to_call(**prompt)
49
44
  else:
50
45
  function_response = function_to_call(**prompt)
51
- function_response, text_len = cut_message(function_response, function_call_max_tokens, engine)
52
-
53
- # if function_call_name == "download_read_arxiv_pdf":
54
- # add_message(arxiv_doc_user_prompt, "user", convo_id=convo_id)
55
46
 
56
47
  function_response = (
57
48
  f"function_response:{function_response}"
aient/utils/scripts.py CHANGED
@@ -1,33 +1,10 @@
1
1
  import os
2
2
  import json
3
- import base64
4
- import tiktoken
5
3
  import requests
6
4
  import urllib.parse
7
5
 
8
6
  from ..core.utils import get_image_message
9
7
 
10
- def get_encode_text(text, model_name):
11
- tiktoken.get_encoding("cl100k_base")
12
- model_name = "gpt-3.5-turbo"
13
- encoding = tiktoken.encoding_for_model(model_name)
14
- encode_text = encoding.encode(text, disallowed_special=())
15
- return encoding, encode_text
16
-
17
- def get_text_token_len(text, model_name):
18
- encoding, encode_text = get_encode_text(text, model_name)
19
- return len(encode_text)
20
-
21
- def cut_message(message: str, max_tokens: int, model_name: str):
22
- if type(message) != str:
23
- message = str(message)
24
- encoding, encode_text = get_encode_text(message, model_name)
25
- if len(encode_text) > max_tokens:
26
- encode_text = encode_text[:max_tokens]
27
- message = encoding.decode(encode_text)
28
- encode_text = encoding.encode(message, disallowed_special=())
29
- return message, len(encode_text)
30
-
31
8
  def get_doc_from_url(url):
32
9
  filename = urllib.parse.unquote(url.split("/")[-1])
33
10
  response = requests.get(url, stream=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.0.93
3
+ Version: 1.0.94
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -15,7 +15,6 @@ Requires-Dist: html2text
15
15
  Requires-Dist: httpx-socks
16
16
  Requires-Dist: fake-useragent
17
17
  Requires-Dist: beautifulsoup4
18
- Requires-Dist: tiktoken==0.6.0
19
18
  Requires-Dist: lxml-html-clean
20
19
  Requires-Dist: pdfminer.six==20240706
21
20
  Requires-Dist: duckduckgo-search==5.3.1
@@ -15,14 +15,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
17
  aient/models/chatgpt.py,sha256=-NWkkKxTCyraPYT0YN37NA2rUfOaDNXtvFSQmIE5tS8,45066
18
- aient/models/claude.py,sha256=thK9P8qkaaoUN3OOJ9Shw4KDs-pAGKPoX4FOPGFXva8,28597
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
21
- aient/models/groq.py,sha256=2JCB0QE1htOprJHI5fZ11R2RtOhsHlsTjbmFyzc8oSM,10084
21
+ aient/models/groq.py,sha256=eXfSOaPxgQEtk4U8qseArN8rFYOFBfMsPwRcDW1nERo,8790
22
22
  aient/models/vertex.py,sha256=qVD5l1Q538xXUPulxG4nmDjXE1VoV4yuAkTCpIeJVw0,16795
23
23
  aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
24
24
  aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
25
- aient/plugins/config.py,sha256=KnZ5xtb5o41FI2_qvxTEQhssdd3WJc7lIAFNR85INQw,7817
25
+ aient/plugins/config.py,sha256=Vp6CG9ocdC_FAlCMEGtKj45xamir76DFxdJVvURNtog,6539
26
26
  aient/plugins/excute_command.py,sha256=u-JOZ21dDcDx1j3O0KVIHAsa6MNuOxHFBdV3iCnTih0,5413
27
27
  aient/plugins/get_time.py,sha256=Ih5XIW5SDAIhrZ9W4Qe5Hs1k4ieKPUc_LAd6ySNyqZk,654
28
28
  aient/plugins/image.py,sha256=ZElCIaZznE06TN9xW3DrSukS7U3A5_cjk1Jge4NzPxw,2072
@@ -36,9 +36,9 @@ aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p4FEyMCy4BfwGs,20
36
36
  aient/prompt/agent.py,sha256=3VycHGnUq9OdR5pd_RM0AeLESlpAgBcmzrsesfq82X0,23856
37
37
  aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
38
  aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
39
- aient/utils/scripts.py,sha256=PPwaJEigPkpciJHUXOag483iq1GjvaLReHDHjkinv6c,26780
40
- aient-1.0.93.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
41
- aient-1.0.93.dist-info/METADATA,sha256=gY5o1t1r59AE53NnRXuDVGE7hNlSgi9vlWIMfgJceV0,5000
42
- aient-1.0.93.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
43
- aient-1.0.93.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
44
- aient-1.0.93.dist-info/RECORD,,
39
+ aient/utils/scripts.py,sha256=JbYHsU3LLtxBcuO_2MWbSgpHpCgtVQe9FGEFJpUyejc,25926
40
+ aient-1.0.94.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
41
+ aient-1.0.94.dist-info/METADATA,sha256=tTyW2ICb7VYVE7cOdOixBiA9Fj3qFw3-lVGxmRLCHT4,4969
42
+ aient-1.0.94.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
43
+ aient-1.0.94.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
44
+ aient-1.0.94.dist-info/RECORD,,
File without changes