aient 1.1.78__py3-none-any.whl → 1.1.80__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 +12 -31
- aient/core/utils.py +5 -2
- aient/models/chatgpt.py +10 -0
- {aient-1.1.78.dist-info → aient-1.1.80.dist-info}/METADATA +1 -1
- {aient-1.1.78.dist-info → aient-1.1.80.dist-info}/RECORD +8 -8
- {aient-1.1.78.dist-info → aient-1.1.80.dist-info}/WHEEL +0 -0
- {aient-1.1.78.dist-info → aient-1.1.80.dist-info}/licenses/LICENSE +0 -0
- {aient-1.1.78.dist-info → aient-1.1.80.dist-info}/top_level.txt +0 -0
aient/core/request.py
CHANGED
@@ -1952,40 +1952,21 @@ async def get_embedding_payload(request, engine, provider, api_key=None):
|
|
1952
1952
|
headers = {
|
1953
1953
|
"Content-Type": "application/json",
|
1954
1954
|
}
|
1955
|
+
if api_key:
|
1956
|
+
headers['Authorization'] = f"Bearer {api_key}"
|
1955
1957
|
|
1956
1958
|
url = provider['base_url']
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
if api_key:
|
1963
|
-
headers['x-goog-api-key'] = f"{api_key}"
|
1964
|
-
parsed_url = urllib.parse.urlparse(url)
|
1965
|
-
url = f"{parsed_url.scheme}://{parsed_url.netloc}{parsed_url.path.split('/models')[0].rstrip('/')}/models/{original_model}:embedContent"
|
1966
|
-
payload = {
|
1967
|
-
"content": {
|
1968
|
-
"parts": [
|
1969
|
-
{
|
1970
|
-
"text": request.input
|
1971
|
-
}
|
1972
|
-
]
|
1973
|
-
}
|
1974
|
-
}
|
1975
|
-
else:
|
1976
|
-
if api_key:
|
1977
|
-
headers['Authorization'] = f"Bearer {api_key}"
|
1978
|
-
url = BaseAPI(url).embeddings
|
1979
|
-
payload = {
|
1980
|
-
"input": request.input,
|
1981
|
-
"model": original_model,
|
1982
|
-
}
|
1959
|
+
url = BaseAPI(url).embeddings
|
1960
|
+
payload = {
|
1961
|
+
"input": request.input,
|
1962
|
+
"model": original_model,
|
1963
|
+
}
|
1983
1964
|
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1965
|
+
if request.encoding_format:
|
1966
|
+
if url.startswith("https://api.jina.ai"):
|
1967
|
+
payload["embedding_type"] = request.encoding_format
|
1968
|
+
else:
|
1969
|
+
payload["encoding_format"] = request.encoding_format
|
1989
1970
|
|
1990
1971
|
return url, headers, payload
|
1991
1972
|
|
aient/core/utils.py
CHANGED
@@ -63,11 +63,14 @@ class BaseAPI:
|
|
63
63
|
else:
|
64
64
|
self.audio_speech: str = urlunparse(parsed_url[:2] + (before_v1 + "audio/speech",) + ("",) * 3)
|
65
65
|
|
66
|
-
if parsed_url.
|
66
|
+
if parsed_url.path.endswith("/v1beta") or \
|
67
|
+
parsed_url.path.endswith("/v1") or \
|
68
|
+
(parsed_url.netloc == 'generativelanguage.googleapis.com' and "openai/chat/completions" not in parsed_url.path):
|
69
|
+
before_v1 = parsed_url.path.split("/v1")[0]
|
67
70
|
self.base_url = api_url
|
68
71
|
self.v1_url = api_url
|
69
72
|
self.chat_url = api_url
|
70
|
-
self.embeddings =
|
73
|
+
self.embeddings = urlunparse(parsed_url[:2] + (before_v1 + "/v1beta/embeddings",) + ("",) * 3)
|
71
74
|
|
72
75
|
def get_engine(provider, endpoint=None, original_model=""):
|
73
76
|
parsed_url = urlparse(provider['base_url'])
|
aient/models/chatgpt.py
CHANGED
@@ -37,6 +37,10 @@ class RateLimitError(Exception):
|
|
37
37
|
"""Custom exception for rate limit (429) errors."""
|
38
38
|
pass
|
39
39
|
|
40
|
+
class HTTPError(Exception):
|
41
|
+
"""Custom exception for HTTP 500 errors."""
|
42
|
+
pass
|
43
|
+
|
40
44
|
class ConfigurationError(Exception):
|
41
45
|
"""Custom exception for configuration errors."""
|
42
46
|
pass
|
@@ -531,6 +535,7 @@ class chatgpt(BaseLLM):
|
|
531
535
|
# 删除 task_complete 跟其他工具一起调用的情况,因为 task_complete 必须单独调用
|
532
536
|
if len(function_parameter) > 1:
|
533
537
|
function_parameter = [tool_dict for tool_dict in function_parameter if tool_dict.get("function_name", "") != "task_complete"]
|
538
|
+
function_parameter = [tool_dict for tool_dict in function_parameter if tool_dict.get("function_name", "") != "get_task_result"]
|
534
539
|
if len(function_parameter) == 1 and function_parameter[0].get("function_name", "") == "task_complete":
|
535
540
|
raise TaskComplete(safe_get(function_parameter, 0, "parameter", "message", default="The task has been completed."))
|
536
541
|
|
@@ -792,6 +797,8 @@ class chatgpt(BaseLLM):
|
|
792
797
|
raise ModelNotFoundError(f"Model: {model or self.engine} not found!")
|
793
798
|
if "HTTP Error', 'status_code': 429" in processed_chunk:
|
794
799
|
raise RateLimitError(f"Rate limit exceeded for model: {model or self.engine}")
|
800
|
+
if "HTTP Error', 'status_code': " in processed_chunk:
|
801
|
+
raise HTTPError(f"HTTP Error: {processed_chunk}")
|
795
802
|
yield processed_chunk
|
796
803
|
index += 1
|
797
804
|
|
@@ -805,6 +812,9 @@ class chatgpt(BaseLLM):
|
|
805
812
|
except APITimeoutError:
|
806
813
|
self.logger.warning("API response timeout (524), retrying...")
|
807
814
|
continue
|
815
|
+
except HTTPError as e:
|
816
|
+
self.logger.warning(f"{e}, retrying...")
|
817
|
+
continue
|
808
818
|
except RateLimitError as e:
|
809
819
|
self.logger.warning(f"{e}, retrying...")
|
810
820
|
continue
|
@@ -2,9 +2,9 @@ aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
|
|
2
2
|
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=KMlCRLjtq1wQHZTJGqnbWhPS2cHq6eLdnk7peKDrzR8,7490
|
5
|
-
aient/core/request.py,sha256=
|
5
|
+
aient/core/request.py,sha256=QnDhyrjzcJOEQU2oauMQi_HHMRR5NxdkrX7nn5JMwTc,76675
|
6
6
|
aient/core/response.py,sha256=ye6Ie5HevXVcH3X5V5BoOC5yDJMBKTKopWQzsCNs008,34977
|
7
|
-
aient/core/utils.py,sha256=
|
7
|
+
aient/core/utils.py,sha256=9r-Z4KqZXXBm7bUkPx-vOYqgn4CEkG-cRRYz_tl0QUg,28851
|
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
|
10
10
|
aient/core/test/test_image.py,sha256=_T4peNGdXKBHHxyQNx12u-NTyFE8TlYI6NvvagsG2LE,319
|
@@ -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=
|
15
|
+
aient/models/chatgpt.py,sha256=hMYVxN6BuAWKoZnL73z60dUnXmtXVul9kFhdCeOEkW8,45615
|
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=TGgZ5SnNKZ8MmdznrZ-TEq7s2ulhAAwTSKH89bci3dA,7079
|
@@ -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.
|
34
|
-
aient-1.1.
|
35
|
-
aient-1.1.
|
36
|
-
aient-1.1.
|
37
|
-
aient-1.1.
|
33
|
+
aient-1.1.80.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
|
34
|
+
aient-1.1.80.dist-info/METADATA,sha256=Ix22MRtZoTcO4BewQWGer393FlWC5TRYbqOoyRDrYpo,4842
|
35
|
+
aient-1.1.80.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
36
|
+
aient-1.1.80.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
|
37
|
+
aient-1.1.80.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|