Skip to content

Commit

Permalink
Merge pull request #2353 from Agenta-AI/feature/age-1449-display-sdk-…
Browse files Browse the repository at this point in the history
…version-in-agenta-playground-interface

[Enhancement]: Display SDK Version in Deployed Applications (openapi.json)
  • Loading branch information
aybruhm authored Dec 10, 2024
2 parents 1d4a536 + 7b6a4c1 commit 8336d1d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions agenta-cli/agenta/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def check_latest_version() -> Union[str, None]:


def notify_update(available_version: str):
import pkg_resources
import importlib.metadata

installed_version = pkg_resources.get_distribution("agenta").version
installed_version = importlib.metadata.version("agenta")
if available_version > installed_version:
click.echo(
click.style(
Expand Down
4 changes: 4 additions & 0 deletions agenta-cli/agenta/sdk/decorators/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from agenta.sdk.context.routing import routing_context_manager, routing_context
from agenta.sdk.context.tracing import tracing_context
from agenta.sdk.router import router
from agenta.sdk.utils import helpers
from agenta.sdk.utils.exceptions import suppress
from agenta.sdk.utils.logging import log
from agenta.sdk.types import (
Expand Down Expand Up @@ -287,6 +288,9 @@ async def wrapper_deployed(*args, **kwargs) -> Any:
app.openapi_schema = None # Forces FastAPI to re-generate the schema
openapi_schema = app.openapi()

# Inject the current version of the SDK into the openapi_schema
openapi_schema["agenta_sdk"] = {"version": helpers.get_current_version()}

for route in entrypoint.routes:
self.override_schema(
openapi_schema=openapi_schema,
Expand Down
8 changes: 8 additions & 0 deletions agenta-cli/agenta/sdk/utils/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import importlib.metadata


def get_current_version():
"""Returns the current version of Agenta's SDK."""

version = importlib.metadata.version("agenta")
return version

0 comments on commit 8336d1d

Please sign in to comment.