aient 1.0.59__py3-none-any.whl → 1.0.60__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 +2 -3
- aient/models/base.py +1 -0
- aient/models/chatgpt.py +5 -11
- {aient-1.0.59.dist-info → aient-1.0.60.dist-info}/METADATA +1 -1
- {aient-1.0.59.dist-info → aient-1.0.60.dist-info}/RECORD +8 -8
- {aient-1.0.59.dist-info → aient-1.0.60.dist-info}/WHEEL +0 -0
- {aient-1.0.59.dist-info → aient-1.0.60.dist-info}/licenses/LICENSE +0 -0
- {aient-1.0.59.dist-info → aient-1.0.60.dist-info}/top_level.txt +0 -0
aient/core/response.py
CHANGED
@@ -191,7 +191,7 @@ async def fetch_gpt_response_stream(client, url, headers, payload):
|
|
191
191
|
while "\n" in buffer:
|
192
192
|
line, buffer = buffer.split("\n", 1)
|
193
193
|
# logger.info("line: %s", repr(line))
|
194
|
-
if line and
|
194
|
+
if line and not line.startswith(": ") and (result:=line.lstrip("data: ").strip()):
|
195
195
|
if result.strip() == "[DONE]":
|
196
196
|
break
|
197
197
|
line = json.loads(result)
|
@@ -298,8 +298,7 @@ async def fetch_azure_response_stream(client, url, headers, payload):
|
|
298
298
|
while "\n" in buffer:
|
299
299
|
line, buffer = buffer.split("\n", 1)
|
300
300
|
# logger.info("line: %s", repr(line))
|
301
|
-
if line and line
|
302
|
-
result = line.lstrip("data: ")
|
301
|
+
if line and not line.startswith(": ") and (result:=line.lstrip("data: ").strip()):
|
303
302
|
if result.strip() == "[DONE]":
|
304
303
|
break
|
305
304
|
line = json.loads(result)
|
aient/models/base.py
CHANGED
aient/models/chatgpt.py
CHANGED
@@ -207,6 +207,7 @@ class chatgpt(BaseLLM):
|
|
207
207
|
history_len = history_len - 1
|
208
208
|
|
209
209
|
if total_tokens:
|
210
|
+
self.current_tokens[convo_id] = total_tokens
|
210
211
|
self.tokens_usage[convo_id] += total_tokens
|
211
212
|
|
212
213
|
def truncate_conversation(self, convo_id: str = "default") -> None:
|
@@ -215,25 +216,17 @@ class chatgpt(BaseLLM):
|
|
215
216
|
"""
|
216
217
|
while True:
|
217
218
|
if (
|
218
|
-
self.
|
219
|
+
self.current_tokens[convo_id] > self.truncate_limit
|
219
220
|
and len(self.conversation[convo_id]) > 1
|
220
221
|
):
|
221
222
|
# Don't remove the first message
|
222
223
|
mess = self.conversation[convo_id].pop(1)
|
224
|
+
string_mess = json.dumps(mess, ensure_ascii=False)
|
225
|
+
self.current_tokens[convo_id] -= len(string_mess) / 4
|
223
226
|
print("Truncate message:", mess)
|
224
227
|
else:
|
225
228
|
break
|
226
229
|
|
227
|
-
def extract_values(self, obj):
|
228
|
-
if isinstance(obj, dict):
|
229
|
-
for value in obj.values():
|
230
|
-
yield from self.extract_values(value)
|
231
|
-
elif isinstance(obj, list):
|
232
|
-
for item in obj:
|
233
|
-
yield from self.extract_values(item)
|
234
|
-
else:
|
235
|
-
yield obj
|
236
|
-
|
237
230
|
async def get_post_body(
|
238
231
|
self,
|
239
232
|
prompt: str,
|
@@ -789,6 +782,7 @@ class chatgpt(BaseLLM):
|
|
789
782
|
{"role": "system", "content": self.system_prompt},
|
790
783
|
]
|
791
784
|
self.tokens_usage[convo_id] = 0
|
785
|
+
self.current_tokens[convo_id] = 0
|
792
786
|
|
793
787
|
def save(self, file: str, *keys: str) -> None:
|
794
788
|
"""
|
@@ -4,15 +4,15 @@ aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
|
|
4
4
|
aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
|
5
5
|
aient/core/models.py,sha256=_1wYZg_n9kb2A3C8xCboyqleH2iHc9scwOvtx9DPeok,7582
|
6
6
|
aient/core/request.py,sha256=oavFyF5P0BL-85cse_lhyfP3UErFzeSdj6kTaSWzQrg,49690
|
7
|
-
aient/core/response.py,sha256=
|
7
|
+
aient/core/response.py,sha256=6Fq-EIL7ua1zeT6GMc1fgQeRs_MCP6UST_pL0tM3f3I,27879
|
8
8
|
aient/core/utils.py,sha256=DFpFU8Y-8lzgQlhaDUnao8HmviGoh3-oN8jZR3Dha7E,26150
|
9
9
|
aient/core/test/test_base_api.py,sha256=CjfFzMG26r8C4xCPoVkKb3Ac6pp9gy5NUCbZJHoSSsM,393
|
10
10
|
aient/core/test/test_image.py,sha256=_T4peNGdXKBHHxyQNx12u-NTyFE8TlYI6NvvagsG2LE,319
|
11
11
|
aient/core/test/test_payload.py,sha256=8jBiJY1uidm1jzL-EiK0s6UGmW9XkdsuuKFGrwFhFkw,2755
|
12
12
|
aient/models/__init__.py,sha256=ouNDNvoBBpIFrLsk09Q_sq23HR0GbLAKfGLIFmfEuXE,219
|
13
13
|
aient/models/audio.py,sha256=kRd-8-WXzv4vwvsTGwnstK-WR8--vr9CdfCZzu8y9LA,1934
|
14
|
-
aient/models/base.py,sha256=
|
15
|
-
aient/models/chatgpt.py,sha256=
|
14
|
+
aient/models/base.py,sha256=vRCDEwabEm0u0RU4J62T2t271xg7YGCPjE3s9HzhtV8,6860
|
15
|
+
aient/models/chatgpt.py,sha256=gOLBHWimbg2mbt9EjDXr5Za60Jt0ICqe-Hah95taupc,42217
|
16
16
|
aient/models/claude.py,sha256=thK9P8qkaaoUN3OOJ9Shw4KDs-pAGKPoX4FOPGFXva8,28597
|
17
17
|
aient/models/duckduckgo.py,sha256=1l7vYCs9SG5SWPCbcl7q6pCcB5AUF_r-a4l9frz3Ogo,8115
|
18
18
|
aient/models/gemini.py,sha256=chGLc-8G_DAOxr10HPoOhvVFW1RvMgHd6mt--VyAW98,14730
|
@@ -35,8 +35,8 @@ aient/prompt/agent.py,sha256=h39WOoafv0_lh2coBCiG9k-VWa3Yi9HRZV0hnvsc4gs,23598
|
|
35
35
|
aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
36
|
aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
|
37
37
|
aient/utils/scripts.py,sha256=n0jR5eXCBIK12W4bIx-xU1FVl1hZ4zDC7hq_BWQHYJU,27537
|
38
|
-
aient-1.0.
|
39
|
-
aient-1.0.
|
40
|
-
aient-1.0.
|
41
|
-
aient-1.0.
|
42
|
-
aient-1.0.
|
38
|
+
aient-1.0.60.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
|
39
|
+
aient-1.0.60.dist-info/METADATA,sha256=A78P4-U_ExGyY5oFvV_32VVdgv_ZtjWwMiBUezBHNQc,4973
|
40
|
+
aient-1.0.60.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
41
|
+
aient-1.0.60.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
|
42
|
+
aient-1.0.60.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|