aient 1.1.79__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 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
- parsed_url = urlparse(url)
1958
- if "embedding-00" in original_model and "127.0.0.1" not in url and \
1959
- (parsed_url.path.endswith("/v1beta") or \
1960
- parsed_url.path.endswith("/v1") or \
1961
- (parsed_url.netloc == 'generativelanguage.googleapis.com' and "openai/chat/completions" not in parsed_url.path)):
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
- if request.encoding_format:
1985
- if url.startswith("https://api.jina.ai"):
1986
- payload["embedding_type"] = request.encoding_format
1987
- else:
1988
- payload["encoding_format"] = request.encoding_format
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.hostname == "generativelanguage.googleapis.com":
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 = api_url
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
@@ -793,6 +797,8 @@ class chatgpt(BaseLLM):
793
797
  raise ModelNotFoundError(f"Model: {model or self.engine} not found!")
794
798
  if "HTTP Error', 'status_code': 429" in processed_chunk:
795
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}")
796
802
  yield processed_chunk
797
803
  index += 1
798
804
 
@@ -806,6 +812,9 @@ class chatgpt(BaseLLM):
806
812
  except APITimeoutError:
807
813
  self.logger.warning("API response timeout (524), retrying...")
808
814
  continue
815
+ except HTTPError as e:
816
+ self.logger.warning(f"{e}, retrying...")
817
+ continue
809
818
  except RateLimitError as e:
810
819
  self.logger.warning(f"{e}, retrying...")
811
820
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.79
3
+ Version: 1.1.80
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -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=nSLKNI-T6lI4yv873eQUElz5_fkJVy1LbOy27NiJPNk,77512
5
+ aient/core/request.py,sha256=QnDhyrjzcJOEQU2oauMQi_HHMRR5NxdkrX7nn5JMwTc,76675
6
6
  aient/core/response.py,sha256=ye6Ie5HevXVcH3X5V5BoOC5yDJMBKTKopWQzsCNs008,34977
7
- aient/core/utils.py,sha256=wCPw4upG4-ciBxGyEXeTEHzxTbm38rVHrr4PIu8hDW8,28579
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=S2KLZEfJLoRh9u60C4AEjOR7yf5iyqMmvSYt9tr8ldY,45256
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.79.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
34
- aient-1.1.79.dist-info/METADATA,sha256=zphfUbkd-RKheXgm26wDs91hdp_ECfcV2VB816IQXzw,4842
35
- aient-1.1.79.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- aient-1.1.79.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
37
- aient-1.1.79.dist-info/RECORD,,
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