Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.31.0 #2412

Merged
merged 40 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
46b3c84
Merge branch 'main' into feat/stateless-service
jp-agenta Dec 4, 2024
323bd38
Merge branch 'main' into feat/stateless-service
jp-agenta Dec 11, 2024
a5e3197
initial commit
jp-agenta Dec 11, 2024
7a0008e
black .
jp-agenta Dec 11, 2024
15c6b85
display exception improvements
jp-agenta Dec 12, 2024
372b3d7
Fix middleware and add positive caching.
jp-agenta Dec 12, 2024
1d59833
Add shared service and services in permissions router
jp-agenta Dec 12, 2024
fb4510c
Merge branch 'feat/stateless-service' of github.com:agenta-ai/agenta …
jp-agenta Dec 12, 2024
86f65cd
Add local secrets and mrge with vault secrets
jp-agenta Dec 13, 2024
041e9bb
integration fixes
jp-agenta Dec 13, 2024
a73afc4
fix integrations issues
jp-agenta Dec 13, 2024
19ff448
Merge branch 'dev' into feat/stateless-service
aybruhm Dec 17, 2024
c1f386e
Merge branch 'dev' into feat/stateless-service
jp-agenta Dec 17, 2024
6708afa
Add get_api_key_from_model()
jp-agenta Dec 17, 2024
b3fea92
refactor (sdk):
aybruhm Dec 17, 2024
2eda1a0
VaultManager to SecretsManager
jp-agenta Dec 18, 2024
8d61b6a
fix(cypress): hot-fix human eval failes
ashrafchowdury Dec 24, 2024
7272ae4
Merge branch 'checkpoint-2-vault-webui-and-api-integration_v2' of git…
bekossy Dec 26, 2024
2b57096
Merge branch 'dev' into checkpoint-2-vault-webui-and-api-integration_v2
bekossy Dec 26, 2024
5dc60f1
synced changes
bekossy Dec 26, 2024
0230d09
Merge pull request #2344 from Agenta-AI/feat/stateless-service
aybruhm Dec 26, 2024
ca53b40
Merge branch 'dev' into checkpoint-2-vault-webui-and-api-integration_v2
ardaerzin Dec 26, 2024
caa2a0f
Merge pull request #2393 from Agenta-AI/checkpoint-2-vault-webui-and-…
aybruhm Dec 26, 2024
12c5a34
fix(frontend): stale secret state causing 404 when adding secrets aft…
bekossy Dec 27, 2024
372c4e7
Merge pull request #2395 from Agenta-AI/hot-fix/-stale-secret-state-c…
aybruhm Dec 27, 2024
866e41e
Merge pull request #2391 from Agenta-AI/cypress/hot-fix-human-eval-fa…
ardaerzin Dec 27, 2024
151868f
build (cli): bump prelease version to 0.30.0a3
aybruhm Dec 27, 2024
623e491
fix (bug): resolve AttributeError: 'CORSMiddleware' object has no att…
aybruhm Dec 27, 2024
6d18883
chore (build): bump pre-release version to 0.30.0a4
aybruhm Dec 27, 2024
c91d1ab
add agenta SDK version back
jp-agenta Dec 27, 2024
0c13b65
fix mistral
jp-agenta Dec 27, 2024
badac33
fix env vars
jp-agenta Dec 27, 2024
837ea2b
Merge branch 'stateless-pre-release' of github.com:agenta-ai/agenta i…
jp-agenta Dec 27, 2024
d2f53c8
SDK prerelease bump
jp-agenta Dec 27, 2024
b568ba4
prettier
jp-agenta Dec 27, 2024
3b2137d
Merge pull request #2396 from Agenta-AI/stateless-pre-release
aybruhm Dec 31, 2024
e864e7e
Merge branch 'main' into release/v0.31.0
aakrem Jan 8, 2025
6c1aa9e
bump versions
aakrem Jan 8, 2025
6a1d58f
test pre-release
aakrem Jan 9, 2025
c916fcc
bump sdk to release version
aakrem Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class LLMRunRateLimit(BaseModel):

class LMProvidersEnum(str, Enum):
openai = "OPENAI_API_KEY"
mistralai = "MISTRAL_API_KEY"
mistral = "MISTRAL_API_KEY"
cohere = "COHERE_API_KEY"
anthropic = "ANTHROPIC_API_KEY"
anyscale = "ANYSCALE_API_KEY"
Expand Down
10 changes: 9 additions & 1 deletion agenta-backend/agenta_backend/routers/app_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ async def create_app_and_variant_from_template(
if isCloudEE()
else "Step 7: Starting variant and injecting environment variables"
)

envvars = {}
if isCloudEE():
supported_llm_prodviders_keys = [
"OPENAI_API_KEY",
Expand All @@ -593,21 +595,27 @@ async def create_app_and_variant_from_template(
"GROQ_API_KEY",
"GEMINI_API_KEY",
]

missing_keys = [
key for key in supported_llm_prodviders_keys if not os.environ.get(key)
]

if missing_keys:
missing_keys_str = ", ".join(missing_keys)
raise Exception(
f"Unable to start app container. The following environment variables are missing: {missing_keys_str}. Please file an issue by clicking on the button below."
)

envvars = {**(payload.env_vars or {})}
if not isCloudEE():
envvars = {**(payload.env_vars or {})}

for key in supported_llm_prodviders_keys:
if not envvars.get(key):
envvars[key] = os.environ[key]

else:
envvars = {} if payload.env_vars is None else payload.env_vars

await app_manager.start_variant(
app_variant_db,
str(app.project_id),
Expand Down
16 changes: 13 additions & 3 deletions agenta-backend/agenta_backend/routers/permissions_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def verify_permissions(
if isOss():
return Allow(None)

if not action or not resource_type or not resource_id:
if not action or not resource_type:
raise Deny()

if isCloudEE():
Expand All @@ -70,8 +70,8 @@ async def verify_permissions(
# CHECK PERMISSION 2/2: RESOURCE
allow_resource = await check_resource_access(
project_id=UUID(request.state.project_id),
resource_id=resource_id,
resource_type=resource_type,
resource_id=resource_id,
)

if not allow_resource:
Expand All @@ -80,13 +80,14 @@ async def verify_permissions(
return Allow(request.state.credentials)

except Exception as exc: # pylint: disable=bare-except
print(exc)
raise Deny() from exc


async def check_resource_access(
project_id: UUID,
resource_id: UUID,
resource_type: str,
resource_id: Optional[UUID] = None,
) -> bool:
resource_project_id = None

Expand All @@ -95,6 +96,15 @@ async def check_resource_access(

resource_project_id = app.project_id

if resource_type == "service":
if resource_id is None:
resource_project_id = project_id

else:
base = await db_manager.fetch_base_by_id(base_id=str(resource_id))

resource_project_id = base.project_id

allow_resource = resource_project_id == project_id

return allow_resource
2 changes: 1 addition & 1 deletion agenta-backend/agenta_backend/services/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def format_llm_provider_keys(
Dict[str, str]: formatted llm provided keys

Example:
Input: {<LMProvidersEnum.mistralai: 'MISTRAL_API_KEY'>: '...', ...}
Input: {<LMProvidersEnum.mistral: 'MISTRAL_API_KEY'>: '...', ...}
Output: {'MISTRAL_API_KEY': '...', ...}
"""

Expand Down
2 changes: 1 addition & 1 deletion agenta-backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "agenta_backend"
version = "0.30.0"
version = "0.31.0"
description = ""
authors = ["Mahmoud Mabrouk <[email protected]>"]
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions agenta-cli/agenta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .sdk.utils.costs import calculate_token_usage
from .sdk.client import Agenta
from .sdk.litellm import litellm as callbacks
from .sdk.managers.secrets import SecretsManager
from .sdk.managers.config import ConfigManager
from .sdk.managers.variant import VariantManager
from .sdk.managers.deployment import DeploymentManager
Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/agenta/client/backend/types/provider_kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"deepinfra",
"alephalpha",
"groq",
"mistralai",
"mistral",
"anthropic",
"perplexityai",
"togetherai",
Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/agenta/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,5 +559,5 @@ def run_evaluation(app_name: str, host: str, api_key: str = None) -> str:
raise APIRequestError(
f"Request to run evaluations failed with status code {response.status_code} and error message: {error_message}."
)
print(response.json())

return response.json()
1 change: 1 addition & 0 deletions agenta-cli/agenta/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .decorators.routing import entrypoint, app, route
from .agenta_init import Config, AgentaSingleton, init as _init
from .utils.costs import calculate_token_usage
from .managers.secrets import SecretsManager
from .managers.config import ConfigManager
from .managers.variant import VariantManager
from .managers.deployment import DeploymentManager
Expand Down
165 changes: 47 additions & 118 deletions agenta-cli/agenta/sdk/agenta_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from agenta.sdk.utils.logging import log
from agenta.sdk.utils.globals import set_global
from agenta.client.backend.client import AgentaApi, AsyncAgentaApi

from agenta.sdk.tracing import Tracing
from agenta.client.exceptions import APIRequestError
from agenta.sdk.context.routing import routing_context


class AgentaSingleton:
Expand Down Expand Up @@ -59,9 +60,7 @@ def init(
ValueError: If `app_id` is not specified either as an argument, in the config file, or in the environment variables.
"""

log.info("---------------------------")
log.info("Agenta SDK - using version: %s", version("agenta"))
log.info("---------------------------")
log.info("Agenta - SDK version: %s", version("agenta"))

config = {}
if config_fname:
Expand All @@ -86,6 +85,13 @@ def init(

self.api_key = api_key or getenv("AGENTA_API_KEY") or config.get("api_key")

self.base_id = getenv("AGENTA_BASE_ID")

self.service_id = getenv("AGENTA_SERVICE_ID") or self.base_id

log.info("Agenta - Service ID: %s", self.service_id)
log.info("Agenta - Application ID: %s", self.app_id)

self.tracing = Tracing(
url=f"{self.host}/api/observability/v1/otlp/traces", # type: ignore
redact=redact,
Expand All @@ -94,6 +100,7 @@ def init(

self.tracing.configure(
api_key=self.api_key,
service_id=self.service_id,
# DEPRECATING
app_id=self.app_id,
)
Expand All @@ -108,8 +115,6 @@ def init(
api_key=self.api_key if self.api_key else "",
)

self.base_id = getenv("AGENTA_BASE_ID")

self.config = Config(
host=self.host,
base_id=self.base_id,
Expand All @@ -120,28 +125,43 @@ def init(
class Config:
def __init__(
self,
host: str,
# LEGACY
host: Optional[str] = None,
base_id: Optional[str] = None,
api_key: Optional[str] = "",
api_key: Optional[str] = None,
# LEGACY
**kwargs,
):
self.host = host
self.default_parameters = {**kwargs}

def set_default(self, **kwargs):
self.default_parameters.update(kwargs)

def get_default(self):
return self.default_parameters

def __getattr__(self, key):
context = routing_context.get()

parameters = context.parameters

if not parameters:
return None

if key in parameters:
value = parameters[key]

if isinstance(value, dict):
nested_config = Config()
nested_config.set_default(**value)

self.base_id = base_id
return nested_config

if self.base_id is None:
# print(
# "Warning: Your configuration will not be saved permanently since base_id is not provided.\n"
# )
pass
return value

if base_id is None or host is None:
self.persist = False
else:
self.persist = True
self.client = AgentaApi(
base_url=self.host + "/api",
api_key=api_key if api_key else "",
)
return None

### --- LEGACY --- ###

def register_default(self, overwrite=False, **kwargs):
"""alias for default"""
Expand All @@ -153,104 +173,13 @@ def default(self, overwrite=False, **kwargs):
overwrite: Whether to overwrite the existing configuration or not
**kwargs: A dict containing the parameters
"""
self.set(
**kwargs
) # In case there is no connectivity, we still can use the default values
try:
self.push(config_name="default", overwrite=overwrite, **kwargs)
except Exception as ex:
log.warning(
"Unable to push the default configuration to the server. %s", str(ex)
)

def push(self, config_name: str, overwrite=True, **kwargs):
"""Pushes the parameters for the app variant to the server
Args:
config_name: Name of the configuration to push to
overwrite: Whether to overwrite the existing configuration or not
**kwargs: A dict containing the parameters
"""
if not self.persist:
return
try:
self.client.configs.save_config(
base_id=self.base_id,
config_name=config_name,
parameters=kwargs,
overwrite=overwrite,
)
except Exception as ex:
log.warning(
"Failed to push the configuration to the server with error: %s", ex
)

def pull(
self, config_name: str = "default", environment_name: Optional[str] = None
):
"""Pulls the parameters for the app variant from the server and sets them to the config"""
if not self.persist and (
config_name != "default" or environment_name is not None
):
raise ValueError(
"Cannot pull the configuration from the server since the app_name and base_name are not provided."
)
if self.persist:
try:
if environment_name:
config = self.client.configs.get_config(
base_id=self.base_id, environment_name=environment_name
)

else:
config = self.client.configs.get_config(
base_id=self.base_id,
config_name=config_name,
)
except Exception as ex:
log.warning(
"Failed to pull the configuration from the server with error: %s",
str(ex),
)
try:
self.set(**{"current_version": config.current_version, **config.parameters})
except Exception as ex:
log.warning("Failed to set the configuration with error: %s", str(ex))
self.set(**kwargs)

def all(self):
"""Returns all the parameters for the app variant"""
return {
k: v
for k, v in self.__dict__.items()
if k
not in [
"app_name",
"base_name",
"host",
"base_id",
"api_key",
"persist",
"client",
]
}

# function to set the parameters for the app variant
def set(self, **kwargs):
"""Sets the parameters for the app variant

Args:
**kwargs: A dict containing the parameters
"""
for key, value in kwargs.items():
setattr(self, key, value)

def dump(self):
"""Returns all the information about the current version in the configuration.
self.set_default(**kwargs)

Raises:
NotImplementedError: _description_
"""

raise NotImplementedError()
def all(self):
return self.default_parameters


def init(
Expand Down
Loading
Loading