fix: corrige autenticação e ciclo de streaming do DeepAgents
This commit is contained in:
@@ -64,6 +64,7 @@ def test_deep_agent_stream_can_be_cancelled():
|
||||
async def scenario():
|
||||
adapter = object.__new__(DeepAgentsAdapter)
|
||||
adapter._closed = False
|
||||
adapter._stream_event_timeout = 1.0
|
||||
|
||||
started = asyncio.Event()
|
||||
cancelled = asyncio.Event()
|
||||
@@ -341,3 +342,53 @@ def test_deep_agent_checkpoint_survives_cancellation():
|
||||
started = None
|
||||
asyncio.run(scenario())
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("options", "expected_auth"),
|
||||
[
|
||||
({}, ("INSTANCE_PRINCIPAL", "DEFAULT", "~/.oci/config")),
|
||||
(
|
||||
{"auth_type": "API_KEY", "auth_profile": "LOCAL", "auth_file_location": "/config/oci"},
|
||||
("API_KEY", "LOCAL", "/config/oci"),
|
||||
),
|
||||
(
|
||||
{"auth_type": "SECURITY_TOKEN", "auth_profile": "SESSION"},
|
||||
("SECURITY_TOKEN", "SESSION", "~/.oci/config"),
|
||||
),
|
||||
({"auth_type": "RESOURCE_PRINCIPAL"}, ("RESOURCE_PRINCIPAL", "DEFAULT", "~/.oci/config")),
|
||||
],
|
||||
)
|
||||
def test_deep_agent_factory_configures_authentication(monkeypatch, options, expected_auth):
|
||||
import voice_assistant.agent.deep_agent as module
|
||||
from voice_assistant.config.loader import load_provider_catalog
|
||||
from voice_assistant.config.models import AppConfig
|
||||
from voice_assistant.providers import create_agent_adapter
|
||||
|
||||
model_factory = MagicMock()
|
||||
agent_factory = MagicMock()
|
||||
monkeypatch.setattr(module, "ChatOCIGenAI", model_factory)
|
||||
monkeypatch.setattr(module, "create_deep_agent", agent_factory)
|
||||
config = AppConfig.model_validate({
|
||||
"stt": {"provider": "nvidia"},
|
||||
"tts": {"provider": "voxcpm"},
|
||||
"agent": {
|
||||
"provider": "deepagents",
|
||||
"options": {
|
||||
"region": "sa-vinhedo-1",
|
||||
"compartment_id": "test-compartment",
|
||||
"model_id": "test-model",
|
||||
"temperature": 0.3,
|
||||
"max_completion_tokens": 256,
|
||||
"timeout_seconds": 60.0,
|
||||
**options,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
adapter = create_agent_adapter(config=config, catalog=load_provider_catalog())
|
||||
|
||||
model_factory.assert_called_once()
|
||||
kwargs = model_factory.call_args.kwargs
|
||||
assert (kwargs["auth_type"], kwargs["auth_profile"], kwargs["auth_file_location"]) == expected_auth
|
||||
assert adapter.model is model_factory.return_value
|
||||
assert agent_factory.call_args.kwargs["model"] is adapter.model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user