mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
added telemetry decorators to other chat clients (#255)
This commit is contained in:
committed by
GitHub
Unverified
parent
c794892d79
commit
dff700e469
@@ -29,6 +29,7 @@ from agent_framework import (
|
||||
)
|
||||
from agent_framework._clients import ai_function_to_json_schema_spec
|
||||
from agent_framework.exceptions import ServiceInitializationError
|
||||
from agent_framework.telemetry import use_telemetry
|
||||
from azure.ai.agents.models import (
|
||||
AgentsNamedToolChoice,
|
||||
AgentsNamedToolChoiceType,
|
||||
@@ -90,6 +91,7 @@ class FoundrySettings(AFBaseSettings):
|
||||
agent_name: str | None = "UnnamedAgent"
|
||||
|
||||
|
||||
@use_telemetry
|
||||
@use_tool_calling
|
||||
class FoundryChatClient(ChatClientBase):
|
||||
"""Azure AI Foundry Chat client."""
|
||||
|
||||
@@ -4,12 +4,7 @@ import sys
|
||||
from collections.abc import AsyncIterable, Callable, Mapping, MutableMapping, MutableSequence, Sequence
|
||||
from datetime import datetime
|
||||
from itertools import chain
|
||||
from typing import Any, Literal
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
from typing import override # type: ignore
|
||||
else:
|
||||
from typing_extensions import override # type: ignore[import]
|
||||
from typing import Any, ClassVar, Literal
|
||||
|
||||
from openai import AsyncOpenAI, AsyncStream
|
||||
from openai.types.responses.response import Response as OpenAIResponse
|
||||
@@ -44,17 +39,26 @@ from .._types import (
|
||||
UsageDetails,
|
||||
)
|
||||
from ..exceptions import ServiceInitializationError, ServiceInvalidResponseError
|
||||
from ..telemetry import use_telemetry
|
||||
from ._shared import OpenAIConfigBase, OpenAIHandler, OpenAIModelTypes, OpenAISettings
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
from typing import override # type: ignore # pragma: no cover
|
||||
else:
|
||||
from typing_extensions import override # type: ignore[import] # pragma: no cover
|
||||
|
||||
__all__ = ["OpenAIResponsesClient"]
|
||||
|
||||
# region ResponsesClient
|
||||
|
||||
|
||||
@use_telemetry
|
||||
@use_tool_calling
|
||||
class OpenAIResponsesClient(OpenAIConfigBase, ChatClientBase, OpenAIHandler):
|
||||
"""OpenAI Responses client class."""
|
||||
|
||||
MODEL_PROVIDER_NAME: ClassVar[str] = "openai" # type: ignore[reportIncompatibleVariableOverride, misc]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
ai_model_id: str | None = None,
|
||||
|
||||
Reference in New Issue
Block a user