agenta 0.45.4__py3-none-any.whl → 0.46.1__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.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

agenta/sdk/agenta_init.py CHANGED
@@ -3,8 +3,9 @@ from os import getenv
3
3
  from typing import Optional, Callable, Any
4
4
  from importlib.metadata import version
5
5
 
6
- from agenta.sdk.utils.logging import get_module_logger
6
+ from agenta.sdk.utils.helpers import parse_url
7
7
  from agenta.sdk.utils.globals import set_global
8
+ from agenta.sdk.utils.logging import get_module_logger
8
9
  from agenta.client.client import AgentaApi, AsyncAgentaApi
9
10
 
10
11
  from agenta.sdk.tracing import Tracing
@@ -73,14 +74,26 @@ class AgentaSingleton:
73
74
  if config_fname:
74
75
  config = toml.load(config_fname)
75
76
 
76
- self.host = (
77
+ _host = (
77
78
  host
78
79
  or getenv("AGENTA_HOST")
79
80
  or config.get("backend_host")
80
81
  or config.get("host")
81
- or "https://cloud.agenta.ai"
82
+ or getenv("AGENTA_API_URL", "https://cloud.agenta.ai")
82
83
  )
83
84
 
85
+ try:
86
+ assert _host and isinstance(
87
+ _host, str
88
+ ), "Host is required. Please provide a valid host or set AGENTA_HOST environment variable."
89
+ self.host = parse_url(url=_host)
90
+ except AssertionError as e:
91
+ log.error(str(e))
92
+ raise
93
+ except Exception as e:
94
+ log.error(f"Failed to parse host URL '{_host}': {e}")
95
+ raise
96
+
84
97
  log.info("Agenta - Host: %s", self.host)
85
98
 
86
99
  self.api_key = api_key or getenv("AGENTA_API_KEY") or config.get("api_key")
agenta/sdk/assets.py CHANGED
@@ -1,5 +1,7 @@
1
1
  supported_llm_models = {
2
2
  "Anthropic": [
3
+ "anthropic/claude-sonnet-4-20250514",
4
+ "anthropic/claude-opus-4-20250514",
3
5
  "anthropic/claude-3-7-sonnet-20250219",
4
6
  "anthropic/claude-3-5-sonnet-20241022",
5
7
  "anthropic/claude-3-5-sonnet-20240620",
@@ -193,7 +193,7 @@ class AuthMiddleware(BaseHTTPMiddleware):
193
193
  )
194
194
  raise DenyException(
195
195
  status_code=500,
196
- content=f"Could no verify credentials: {self.host} returned unexpected status code {response.status_code}. Please try again later or contact support if the issue persists.",
196
+ content=f"Could not verify credentials: {self.host} returned unexpected status code {response.status_code}. Please try again later or contact support if the issue persists.",
197
197
  )
198
198
 
199
199
  try:
@@ -202,7 +202,7 @@ class AuthMiddleware(BaseHTTPMiddleware):
202
202
  log.debug(f"Agenta returned invalid JSON response: {exc}")
203
203
  raise DenyException(
204
204
  status_code=500,
205
- content=f"Could no verify credentials: {self.host} returned unexpected invalid JSON response. Please try again later or contact support if the issue persists.",
205
+ content=f"Could not verify credentials: {self.host} returned unexpected invalid JSON response. Please try again later or contact support if the issue persists.",
206
206
  ) from exc
207
207
 
208
208
  if not isinstance(auth, dict):
@@ -211,7 +211,7 @@ class AuthMiddleware(BaseHTTPMiddleware):
211
211
  )
212
212
  raise DenyException(
213
213
  status_code=500,
214
- content=f"Could no verify credentials: {self.host} returned unexpected invalid response format. Please try again later or contact support if the issue persists.",
214
+ content=f"Could not verify credentials: {self.host} returned unexpected invalid response format. Please try again later or contact support if the issue persists.",
215
215
  )
216
216
 
217
217
  effect = auth.get("effect")
@@ -239,7 +239,7 @@ class AuthMiddleware(BaseHTTPMiddleware):
239
239
  )
240
240
  raise DenyException(
241
241
  status_code=500,
242
- content=f"Could no verify credentials: unexpected error - {str(exc)}. Please try again later or contact support if the issue persists.",
242
+ content=f"Could not verify credentials: unexpected error - {str(exc)}. Please try again later or contact support if the issue persists.",
243
243
  ) from exc
244
244
 
245
245
  except DenyException as deny:
@@ -248,5 +248,5 @@ class AuthMiddleware(BaseHTTPMiddleware):
248
248
  log.debug(f"Unexpected error while verifying credentials (local): {exc}")
249
249
  raise DenyException(
250
250
  status_code=500,
251
- content=f"Could no verify credentials: unexpected error - {str(exc)}. Please try again later or contact support if the issue persists.",
251
+ content=f"Could not verify credentials: unexpected error - {str(exc)}. Please try again later or contact support if the issue persists.",
252
252
  ) from exc
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import importlib.metadata
2
3
 
3
4
 
@@ -6,3 +7,37 @@ def get_current_version():
6
7
 
7
8
  version = importlib.metadata.version("agenta")
8
9
  return version
10
+
11
+
12
+ def parse_url(url: str) -> str:
13
+ """
14
+ Parses and potentially rewrites a URL based on the environment and Docker network mode.
15
+
16
+ Args:
17
+ url (str): The original URL to parse and potentially rewrite.
18
+
19
+ Returns:
20
+ str: The parsed or rewritten URL suitable for the current environment and Docker network mode.
21
+ """
22
+
23
+ # Normalize: remove trailing slash and /api suffix
24
+ url = url.rstrip("/")
25
+ if url.endswith("/api"):
26
+ url = url[: -len("/api")]
27
+
28
+ if "localhost" not in url:
29
+ return url
30
+
31
+ internal_url = os.getenv("AGENTA_API_INTERNAL_URL")
32
+ if internal_url:
33
+ return internal_url
34
+
35
+ docker_network_mode = os.getenv("DOCKER_NETWORK_MODE", "").lower()
36
+ if docker_network_mode == "bridge":
37
+ return url.replace("localhost", "host.docker.internal")
38
+
39
+ if not docker_network_mode or docker_network_mode == "host":
40
+ return url
41
+
42
+ # For any other network mode, return the URL unchanged
43
+ return url
@@ -37,17 +37,17 @@ def bound_logger_trace(self, *args, **kwargs):
37
37
  structlog.stdlib.BoundLogger.trace = bound_logger_trace
38
38
 
39
39
  # ENV VARS
40
- LOG_CONSOLE_ENABLED = os.getenv("LOG_CONSOLE_ENABLED", "true") == "true"
41
- LOG_CONSOLE_LEVEL = os.getenv("LOG_CONSOLE_LEVEL", "TRACE").upper()
40
+ AGENTA_LOG_CONSOLE_ENABLED = os.getenv("AGENTA_LOG_CONSOLE_ENABLED", "true") == "true"
41
+ AGENTA_LOG_CONSOLE_LEVEL = os.getenv("AGENTA_LOG_CONSOLE_LEVEL", "TRACE").upper()
42
42
 
43
- # LOG_OTLP_ENABLED = os.getenv("LOG_OTLP_ENABLED", "false") == "true"
44
- # LOG_OTLP_LEVEL = os.getenv("LOG_OTLP_LEVEL", "INFO").upper()
43
+ # AGENTA_LOG_OTLP_ENABLED = os.getenv("AGENTA_LOG_OTLP_ENABLED", "false") == "true"
44
+ # AGENTA_LOG_OTLP_LEVEL = os.getenv("AGENTA_LOG_OTLP_LEVEL", "INFO").upper()
45
45
 
46
- # LOG_FILE_ENABLED = os.getenv("LOG_FILE_ENABLED", "true") == "true"
47
- # LOG_FILE_LEVEL = os.getenv("LOG_FILE_LEVEL", "WARNING").upper()
48
- # LOG_FILE_BASE = os.getenv("LOG_FILE_PATH", "error")
46
+ # AGENTA_LOG_FILE_ENABLED = os.getenv("AGENTA_LOG_FILE_ENABLED", "true") == "true"
47
+ # AGENTA_LOG_FILE_LEVEL = os.getenv("AGENTA_LOG_FILE_LEVEL", "WARNING").upper()
48
+ # AGENTA_LOG_FILE_BASE = os.getenv("AGENTA_LOG_FILE_PATH", "error")
49
49
  # LOG_FILE_DATE = datetime.utcnow().strftime("%Y-%m-%d")
50
- # LOG_FILE_PATH = f"{LOG_FILE_BASE}-{LOG_FILE_DATE}.log"
50
+ # AGENTA_LOG_FILE_PATH = f"{AGENTA_LOG_FILE_BASE}-{LOG_FILE_DATE}.log"
51
51
 
52
52
  # COLORS
53
53
  LEVEL_COLORS = {
@@ -197,27 +197,27 @@ def create_struct_logger(
197
197
  handlers = []
198
198
  loggers = []
199
199
 
200
- if LOG_CONSOLE_ENABLED:
200
+ if AGENTA_LOG_CONSOLE_ENABLED:
201
201
  h = logging.StreamHandler(sys.stdout)
202
- h.setLevel(getattr(logging, LOG_CONSOLE_LEVEL, TRACE_LEVEL))
202
+ h.setLevel(getattr(logging, AGENTA_LOG_CONSOLE_LEVEL, TRACE_LEVEL))
203
203
  h.setFormatter(logging.Formatter("%(message)s"))
204
204
  logging.getLogger("console").addHandler(h)
205
205
  loggers.append(create_struct_logger([colored_console_renderer()], "console"))
206
206
 
207
- # if LOG_FILE_ENABLED:
208
- # h = RotatingFileHandler(LOG_FILE_PATH, maxBytes=10 * 1024 * 1024, backupCount=5)
209
- # h.setLevel(getattr(logging, LOG_FILE_LEVEL, logging.WARNING))
207
+ # if AGENTA_LOG_FILE_ENABLED:
208
+ # h = RotatingFileHandler(AGENTA_LOG_FILE_PATH, maxBytes=10 * 1024 * 1024, backupCount=5)
209
+ # h.setLevel(getattr(logging, AGENTA_LOG_FILE_LEVEL, logging.WARNING))
210
210
  # h.setFormatter(logging.Formatter("%(message)s"))
211
211
  # logging.getLogger("file").addHandler(h)
212
212
  # loggers.append(create_struct_logger([plain_renderer()], "file"))
213
213
 
214
- # if LOG_OTLP_ENABLED:
214
+ # if AGENTA_LOG_OTLP_ENABLED:
215
215
  # provider = LoggerProvider()
216
216
  # exporter = OTLPLogExporter()
217
217
  # provider.add_log_record_processor(BatchLogRecordProcessor(exporter))
218
218
  # set_logger_provider(provider)
219
219
  # h = LoggingHandler(
220
- # level=getattr(logging, LOG_OTLP_LEVEL, logging.INFO), logger_provider=provider
220
+ # level=getattr(logging, AGENTA_LOG_OTLP_LEVEL, logging.INFO), logger_provider=provider
221
221
  # )
222
222
  # h.setFormatter(logging.Formatter("%(message)s"))
223
223
  # logging.getLogger("otel").addHandler(h)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: agenta
3
- Version: 0.45.4
3
+ Version: 0.46.1
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Keywords: LLMOps,LLM,evaluation,prompt engineering
6
6
  Author: Mahmoud Mabrouk
@@ -182,7 +182,7 @@ docker compose -f hosting/docker-compose/oss/docker-compose.gh.yml --env-file ho
182
182
 
183
183
  3. Access Agenta at `http://localhost`.
184
184
 
185
- For deploying on a remote host, or using different ports refers to our [self-hosting](https://docs.agenta.ai/self-host/host-locally?utm_source=github&utm_medium=referral&utm_campaign=readme) and [remote deployment documentation](https://docs.agenta.ai/self-host/host-remotely?utm_source=github&utm_medium=referral&utm_campaign=readme).
185
+ For deploying on a remote host, or using different ports refers to our [self-hosting](https://docs.agenta.ai/self-host/quick-start?utm_source=github&utm_medium=referral&utm_campaign=readme) and [remote deployment documentation](https://docs.agenta.ai/self-host/guides/deploy-remotely?utm_source=github&utm_medium=referral&utm_campaign=readme).
186
186
 
187
187
  ## 💬 Community
188
188
 
@@ -303,5 +303,5 @@ This project follows the [all-contributors](https://github.com/all-contributors/
303
303
 
304
304
  ## Disabling Anonymized Tracking
305
305
 
306
- By default, Agenta automatically reports anonymized basic usage statistics. This helps us understand how Agenta is used and track its overall usage and growth. This data does not include any sensitive information. To disable anonymized telemetry set `TELEMETRY_ENABLED` to `false` in your `.env` file.
306
+ By default, Agenta automatically reports anonymized basic usage statistics. This helps us understand how Agenta is used and track its overall usage and growth. This data does not include any sensitive information. To disable anonymized telemetry set `AGENTA_TELEMETRY_ENABLED` to `false` in your `.env` file.
307
307
 
@@ -199,8 +199,8 @@ agenta/client/types/provider_kind.py~feat_model-registry,sha256=u_fXncQyXH3pfh2w
199
199
  agenta/config.py,sha256=0VrTqduB4g8Mt_Ll7ffFcEjKF5qjTUIxmUtTPW2ygWw,653
200
200
  agenta/config.toml,sha256=sIORbhnyct2R9lJrquxhNL4pHul3O0R7iaipCoja5MY,193
201
201
  agenta/sdk/__init__.py,sha256=m5UxAteSVzJtYhSsmUmdGFsyFdZO6jlfvOpJi_4mK_E,2118
202
- agenta/sdk/agenta_init.py,sha256=fZQdPO0i9fub17N7KmUamT2OgAmQekwRo7iFpg8hfL0,6111
203
- agenta/sdk/assets.py,sha256=z6pUK5b9dZMD7vaaghDu1w9lMD_IopspbgVxmop5PLY,8181
202
+ agenta/sdk/agenta_init.py,sha256=-0m0IH6K2Nic8Vftt5ENdRxpChhsaihKLtMWn8jzoJs,6610
203
+ agenta/sdk/assets.py,sha256=viDrSsQfVnMEVkzxRVcQ3WsOuhD5HPfaslLwm9uV0MA,8271
204
204
  agenta/sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
205
205
  agenta/sdk/context/exporting.py,sha256=16X8fgMhl58gehSlqANX97FiKxx4TkGiG4d2B0-7ZX0,516
206
206
  agenta/sdk/context/routing.py,sha256=FEsjw8EttI1SMyUo96ptcUsvHJnhoKwdr1szlkxxJNU,598
@@ -221,7 +221,7 @@ agenta/sdk/managers/shared.py,sha256=kI3w74E4rS3YDORG2e-_r0Pz5KslTRzRBK7vgyOeaJA
221
221
  agenta/sdk/managers/variant.py,sha256=A5ga3mq3b0weUTXa9HO72MGaspthGcu1uK9K5OnP738,4172
222
222
  agenta/sdk/managers/vault.py,sha256=054ce9X_xKa2M4NtQWz-GugO6q_pYVWCP3IxbAJJcRw,337
223
223
  agenta/sdk/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
224
- agenta/sdk/middleware/auth.py,sha256=xS8lVlPmapvxz_bbZ2XPxcllA0kK7iFR8TMoMVymp4M,10156
224
+ agenta/sdk/middleware/auth.py,sha256=x1b6S57-7xlomkWKLqtYMt1Y6RPAO0HTGHpk3xPw2xo,10161
225
225
  agenta/sdk/middleware/config.py,sha256=g3f81uywYCcgT_TSQxZ5O1Db9wGmPuRMlf-8WKqWqdA,7963
226
226
  agenta/sdk/middleware/cors.py,sha256=q3r7lGkrIdMcT_vuhsburMcjG7pyl7w0ycxrIrGJ2e8,921
227
227
  agenta/sdk/middleware/inline.py,sha256=ee8E4XBGcRSrHTvblqX1yRXuTN_sxLm7lY1jnywrBG8,901
@@ -245,11 +245,11 @@ agenta/sdk/utils/constants.py,sha256=zW3R4rjXOo2L5lz6q84l_zYuOM9u4mpPRHw_B1Dr_hI
245
245
  agenta/sdk/utils/costs.py,sha256=i8C7ud__pThLS55XkN4YW8czXtGeXr2mx7jjcOFeiXg,5955
246
246
  agenta/sdk/utils/exceptions.py,sha256=Dq3lh5Ug7IhF4nvYRXXlwhgxEuByOnT1w0uVMZx1eaM,1504
247
247
  agenta/sdk/utils/globals.py,sha256=9ixKS8aI6ZWgsjT8WngvTg4dsnP2cKErNJngHxzdK9U,256
248
- agenta/sdk/utils/helpers.py,sha256=utrxDoELpR6QgFgHCEAWrWW4TYWXA10q72Gs5R78Ens,181
249
- agenta/sdk/utils/logging.py,sha256=gBk2ecRvltN7f8qtnUHXBiZPWOdArN_b5civ_3w_Oek,8225
248
+ agenta/sdk/utils/helpers.py,sha256=gfvQ-2-M_tZonFJtSdC0F7CNFcHyUG1CTgGQNwxRt2g,1169
249
+ agenta/sdk/utils/logging.py,sha256=j4NzpFk2ilOM10sRBOxCjmansDHSx6HwMV8IAEreRb8,8386
250
250
  agenta/sdk/utils/preinit.py,sha256=YlJL7RLfel0R7DFp-jK7OV-z4ZIQJM0oupYlk7g8b5o,1278
251
251
  agenta/sdk/utils/singleton.py,sha256=17Ph7LGnnV8HkPjImruKita2ni03Ari5jr0jqm__4sc,312
252
252
  agenta/sdk/utils/timing.py,sha256=nZR-kudVUtKFlHuBhztgSGxj7FVnCB4Uv6sfg-1dkrQ,1556
253
- agenta-0.45.4.dist-info/METADATA,sha256=KMLDfLdOevs1L_62dYt08pGobZzemWB8pzxD1eYYlms,31418
254
- agenta-0.45.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
255
- agenta-0.45.4.dist-info/RECORD,,
253
+ agenta-0.46.1.dist-info/METADATA,sha256=G4dj4ZetpuNW00cmTpNwJVrJWWzZjDMKvuFP2pg65eM,31433
254
+ agenta-0.46.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
255
+ agenta-0.46.1.dist-info/RECORD,,