Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -5,9 +5,10 @@

from typing import TYPE_CHECKING, Optional, Any

from .agent_framework import AgentFrameworkCBAgent
from .tool_client import ToolClient
from ._version import VERSION
from azure.ai.agentserver.agentframework.agent_framework import AgentFrameworkCBAgent
from azure.ai.agentserver.agentframework.tool_client import ToolClient
from azure.ai.agentserver.agentframework._version import VERSION
from azure.ai.agentserver.core.application._package_metadata import PackageMetadata, set_current_app

if TYPE_CHECKING: # pragma: no cover
from azure.core.credentials_async import AsyncTokenCredential
Expand All @@ -22,3 +23,5 @@ def from_agent_framework(agent,

__all__ = ["from_agent_framework", "ToolClient"]
__version__ = VERSION

set_current_app(PackageMetadata.from_dist("azure-ai-agentserver-agentframework"))
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from agent_framework.azure import AzureAIClient # pylint: disable=no-name-in-module
from opentelemetry import trace

from azure.ai.agentserver.core.client.tools import OAuthConsentRequiredError
from ..core.tools._exceptions import OAuthConsentRequiredError
from azure.ai.agentserver.core import AgentRunContext, FoundryCBAgent
from azure.ai.agentserver.core.constants import Constants as AdapterConstants
from azure.ai.agentserver.core.logger import APPINSIGHT_CONNSTR_ENV_NAME, get_logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pydantic import Field, create_model
from azure.ai.agentserver.core.logger import get_logger
if TYPE_CHECKING:
from azure.ai.agentserver.core.client.tools.aio import AzureAIToolClient, FoundryTool
from azure.ai.agentserver.core.tools import FoundryToolClient, ResolvedFoundryTool

logger = get_logger()

Expand Down Expand Up @@ -51,7 +51,7 @@ class ToolClient:
:meta private:
"""

def __init__(self, tool_client: "AzureAIToolClient") -> None:
def __init__(self, tool_client: "FoundryToolClient") -> None:
"""Initialize the ToolClient.

:param tool_client: The AzureAIToolClient instance to use for tool operations.
Expand Down Expand Up @@ -92,7 +92,7 @@ async def list_tools(self) -> List[AIFunction]:

return self._aifunction_cache

def _convert_to_agent_framework_tool(self, azure_tool: "FoundryTool") -> AIFunction:
def _convert_to_agent_framework_tool(self, azure_tool: "ResolvedFoundryTool") -> AIFunction:
"""Convert an AzureAITool to an Agent Framework AI Function

:param azure_tool: The AzureAITool to convert.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

__path__ = __import__("pkgutil").extend_path(__path__, __name__)
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
class AgentServerBuilder:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from dataclasses import dataclass, field

from azure.core.credentials_async import AsyncTokenCredential


@dataclass(frozen=True)
class HttpServerConfiguration:
"""Resolved configuration for the HTTP server.

:ivar str host: The host address the server listens on. Defaults to '0.0.0.0'.
:ivar int port: The port number the server listens on. Defaults to 8088.
"""

host: str = "0.0.0.0"
port: int = 8088


class ToolsConfiguration:
"""Resolved configuration for the Tools subsystem.

:ivar int catalog_cache_ttl: The time-to-live (TTL) for the tool catalog cache in seconds.
Defaults to 600 seconds (10 minutes).
:ivar int catalog_cache_max_size: The maximum size of the tool catalog cache.
Defaults to 1024 entries.
"""

catalog_cache_ttl: int = 600
catalog_cache_max_size: int = 1024


@dataclass(frozen=True, kw_only=True)
class AgentServerConfiguration:
"""Resolved configuration for the Agent Server application."""

agent_name: str = "$default"
project_endpoint: str
credential: AsyncTokenCredential
http: HttpServerConfiguration = field(default_factory=HttpServerConfiguration)
tools: ToolsConfiguration = field(default_factory=ToolsConfiguration)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from typing import Literal, NotRequired, TypedDict, Union

from azure.core.credentials import TokenCredential
from azure.core.credentials_async import AsyncTokenCredential


class AgentServerOptions(TypedDict):
"""Configuration options for the Agent Server.

Attributes:
project_endpoint (str, optional): The endpoint URL for the project. Defaults to current project.
credential (Union[AsyncTokenCredential, TokenCredential], optional): The credential used for authentication.
Defaults to current project's managed identity.
"""
project_endpoint: NotRequired[str]
credential: NotRequired[Union[AsyncTokenCredential, TokenCredential]]
http: NotRequired["HttpServerOptions"]
toos: NotRequired["ToolsOptions"]


class HttpServerOptions(TypedDict):
"""Configuration options for the HTTP server.

Attributes:
host (str, optional): The host address the server listens on.
"""
host: NotRequired[Literal["127.0.0.1", "localhost", "0.0.0.0"]]


class ToolsOptions(TypedDict):
"""Configuration options for the Tools subsystem.

Attributes:
catalog_cache_ttl (int, optional): The time-to-live (TTL) for the tool catalog cache in seconds.
Defaults to 600 seconds (10 minutes).
catalog_cache_max_size (int, optional): The maximum size of the tool catalog cache.
Defaults to 1024 entries.
"""
catalog_cache_ttl: NotRequired[int]
catalog_cache_max_size: NotRequired[int]

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from __future__ import annotations

import platform
from dataclasses import dataclass
from importlib.metadata import Distribution, PackageNotFoundError


@dataclass(frozen=True)
class PackageMetadata:
name: str
version: str
python_version: str
platform: str

@staticmethod
def from_dist(dist_name: str):
try:
ver = Distribution.from_name(dist_name).version
except PackageNotFoundError:
ver = ""

return PackageMetadata(
name=dist_name,
version=ver,
python_version=platform.python_version(),
platform=platform.platform(),
)

def as_user_agent(self, component: str | None = None) -> str:
return (f"{self.name}/{self.version} "
f"Python {self.python_version} "
f"{component} " if component else ""
f"({self.platform})")


_default = PackageMetadata.from_dist("azure-ai-agentserver-core")
_app: PackageMetadata = _default


def set_current_app(app: PackageMetadata) -> None:
global _app
_app = app


def get_current_app() -> PackageMetadata:
global _app
return _app

This file was deleted.

Loading