mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
82ca4065cb
* test with stack and simplified names * quick demo of agent decorator * moved builder to protocol to enhance functionality * undid chatclientAgent -> agent rename * one more * reverted AIAgent rename * final reverts * fixed foundry import * revert changes * streamlined otel and fcc decorators * cleanup of telemetry * further refinement * lots of updates * fixed typing * fix for mypy * added input and output atttributes * fix import * initial work on baking in otel * major update to telemetry * final fixes after rename * fix * fix test * updated tests * fix for tests * fixes for tests * updated based on comments * removed agent decorator * fix for Python: ServiceResponseException when using multiple tools Fixes #649 * addressed comments * fix tests * fix tests * fix tools tests * fix for conversation_id in assistants client * fix responses test * fix tests and mypy * updated test * foundry fix --------- Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
77 lines
2.5 KiB
Python
77 lines
2.5 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
from typing import Any
|
|
|
|
from pytest import fixture
|
|
|
|
from agent_framework.telemetry import OtelSettings, setup_telemetry
|
|
|
|
|
|
# region Connector Settings fixtures
|
|
@fixture
|
|
def exclude_list(request: Any) -> list[str]:
|
|
"""Fixture that returns a list of environment variables to exclude."""
|
|
return request.param if hasattr(request, "param") else []
|
|
|
|
|
|
@fixture
|
|
def override_env_param_dict(request: Any) -> dict[str, str]:
|
|
"""Fixture that returns a dict of environment variables to override."""
|
|
return request.param if hasattr(request, "param") else {}
|
|
|
|
|
|
@fixture()
|
|
def openai_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # type: ignore
|
|
"""Fixture to set environment variables for OpenAISettings."""
|
|
|
|
if exclude_list is None:
|
|
exclude_list = []
|
|
|
|
if override_env_param_dict is None:
|
|
override_env_param_dict = {}
|
|
|
|
env_vars = {
|
|
"OPENAI_API_KEY": "test-dummy-key",
|
|
"OPENAI_ORG_ID": "test_org_id",
|
|
"OPENAI_RESPONSES_MODEL_ID": "test_responses_model_id",
|
|
"OPENAI_CHAT_MODEL_ID": "test_chat_model_id",
|
|
"OPENAI_TEXT_MODEL_ID": "test_text_model_id",
|
|
"OPENAI_EMBEDDING_MODEL_ID": "test_embedding_model_id",
|
|
"OPENAI_TEXT_TO_IMAGE_MODEL_ID": "test_text_to_image_model_id",
|
|
"OPENAI_AUDIO_TO_TEXT_MODEL_ID": "test_audio_to_text_model_id",
|
|
"OPENAI_TEXT_TO_AUDIO_MODEL_ID": "test_text_to_audio_model_id",
|
|
"OPENAI_REALTIME_MODEL_ID": "test_realtime_model_id",
|
|
}
|
|
|
|
env_vars.update(override_env_param_dict) # type: ignore
|
|
|
|
for key, value in env_vars.items():
|
|
if key in exclude_list:
|
|
monkeypatch.delenv(key, raising=False) # type: ignore
|
|
continue
|
|
monkeypatch.setenv(key, value) # type: ignore
|
|
|
|
return env_vars
|
|
|
|
|
|
@fixture
|
|
def enable_otel(request: Any) -> bool:
|
|
"""Fixture that returns a boolean indicating if Otel is enabled."""
|
|
return request.param if hasattr(request, "param") else True
|
|
|
|
|
|
@fixture
|
|
def enable_sensitive_data(request: Any) -> bool:
|
|
"""Fixture that returns a boolean indicating if sensitive data is enabled."""
|
|
return request.param if hasattr(request, "param") else False
|
|
|
|
|
|
@fixture
|
|
def otel_settings(enable_otel: bool, enable_sensitive_data: bool) -> OtelSettings:
|
|
"""Fixture to set environment variables for OtelSettings."""
|
|
|
|
from agent_framework.telemetry import OTEL_SETTINGS
|
|
|
|
setup_telemetry(enable_otel=enable_otel, enable_sensitive_data=enable_sensitive_data)
|
|
|
|
return OTEL_SETTINGS
|