Skip to content

Commit

Permalink
Merge pull request #1567 from Agenta-AI/1560-age-118-observability-in…
Browse files Browse the repository at this point in the history
…tegration-without-using-agenta-hosted-apps

[Enhancement]: observability integration without using agenta hosted apps
  • Loading branch information
mmabrouk authored May 30, 2024
2 parents ddab8d8 + 46539a2 commit b200bb7
Show file tree
Hide file tree
Showing 26 changed files with 1,073 additions and 793 deletions.
2 changes: 0 additions & 2 deletions agenta-backend/agenta_backend/services/app_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ async def start_variant(
env_vars = {} if env_vars is None else env_vars
env_vars.update(
{
"AGENTA_VARIANT_NAME": db_app_variant.variant_name,
"AGENTA_VARIANT_ID": str(db_app_variant.id),
"AGENTA_BASE_ID": str(db_app_variant.base.id),
"AGENTA_APP_ID": str(db_app_variant.app.id),
"AGENTA_HOST": domain_name,
Expand Down
9 changes: 6 additions & 3 deletions agenta-cli/agenta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .sdk.utils.preinit import PreInitObject
from .sdk.agenta_decorator import app, entrypoint
from .sdk.context import get_contexts, save_context
from .sdk.types import (
Context,
Expand All @@ -14,9 +13,13 @@
FileInputURL,
BinaryParam,
)
from .sdk.tracing.decorators import span
from .sdk.agenta_init import Config, init, llm_tracing
from .sdk.tracing.llm_tracing import Tracing
from .sdk.decorators.tracing import instrument
from .sdk.decorators.llm_entrypoint import entrypoint, app
from .sdk.agenta_init import Config, AgentaSingleton, init
from .sdk.utils.helper.openai_cost import calculate_token_usage
from .sdk.client import Agenta

config = PreInitObject("agenta.config", Config)
DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
14 changes: 8 additions & 6 deletions agenta-cli/agenta/client/backend/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def __init__(
self._client_wrapper = SyncClientWrapper(
base_url=base_url,
api_key=api_key,
httpx_client=httpx.Client(timeout=timeout)
if httpx_client is None
else httpx_client,
httpx_client=(
httpx.Client(timeout=timeout) if httpx_client is None else httpx_client
),
)
self.observability = ObservabilityClient(client_wrapper=self._client_wrapper)
self.apps = AppsClient(client_wrapper=self._client_wrapper)
Expand Down Expand Up @@ -1037,9 +1037,11 @@ def __init__(
self._client_wrapper = AsyncClientWrapper(
base_url=base_url,
api_key=api_key,
httpx_client=httpx.AsyncClient(timeout=timeout)
if httpx_client is None
else httpx_client,
httpx_client=(
httpx.AsyncClient(timeout=timeout)
if httpx_client is None
else httpx_client
),
)
self.observability = AsyncObservabilityClient(
client_wrapper=self._client_wrapper
Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/agenta/client/backend/types/create_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
return super().dict(**kwargs_with_defaults)

class Config:
frozen = True
frozen = False
smart_union = True
json_encoders = {dt.datetime: serialize_datetime}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM public.ecr.aws/s2t9a1r1/agentaai/lambda_templates_public:main

COPY requirements.txt ${LAMBDA_TASK_ROOT}
RUN pip install --no-cache-dir --disable-pip-version-check -r requirements.txt
RUN pip install --no-cache-dir --disable-pip-version-check mangum
RUN pip install --no-cache-dir --disable-pip-version-check -U agenta
RUN pip install --no-cache-dir --disable-pip-version-check -U -r requirements.txt
RUN pip install --no-cache-dir --disable-pip-version-check mangum
COPY . ${LAMBDA_TASK_ROOT}

CMD [ "lambda_function.handler" ]
2 changes: 1 addition & 1 deletion agenta-cli/agenta/docker/docker-assets/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ WORKDIR /app

COPY . .

RUN pip install --no-cache-dir --disable-pip-version-check -r requirements.txt
RUN pip install --no-cache-dir --disable-pip-version-check -U agenta
RUN pip install --no-cache-dir --disable-pip-version-check -r requirements.txt

EXPOSE 80

Expand Down
10 changes: 6 additions & 4 deletions agenta-cli/agenta/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from .utils.preinit import PreInitObject # always the first import!
from . import agenta_decorator, context, types, utils # noqa: F401
from .agenta_decorator import app, entrypoint
from .context import get_contexts, save_context
from .types import (
Context,
Expand All @@ -15,9 +13,13 @@
FileInputURL,
BinaryParam,
)
from .tracing.decorators import span
from .agenta_init import Config, init, llm_tracing
from .tracing.llm_tracing import Tracing
from .decorators.tracing import instrument
from .decorators.llm_entrypoint import entrypoint, app
from .agenta_init import Config, AgentaSingleton, init
from .utils.helper.openai_cost import calculate_token_usage


config = PreInitObject("agenta.config", Config)
DEFAULT_AGENTA_SINGLETON_INSTANCE = AgentaSingleton()
tracing = DEFAULT_AGENTA_SINGLETON_INSTANCE.tracing # type: ignore
Loading

0 comments on commit b200bb7

Please sign in to comment.