feat(llm): añade factory que selecciona proveedor según settings

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Juan
2026-05-10 10:30:40 +02:00
co-authored by Claude Opus 4.7
parent 4630fa214d
commit d774a6b509
2 changed files with 48 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Factory que selecciona el LLMProvider según settings."""
from __future__ import annotations
from agentforge_core.config import Settings
from agentforge_core.llm.azure import AzureOpenAIProvider
from agentforge_core.llm.base import LLMProvider
from agentforge_core.llm.mock import MockProvider
from agentforge_core.llm.openai import OpenAIProvider
def build_llm_provider(settings: Settings) -> LLMProvider:
"""Materializa el proveedor activo. Falla en arranque si la config es inconsistente."""
match settings.llm_provider:
case "mock":
return MockProvider()
case "azure":
return AzureOpenAIProvider(
endpoint=settings.azure_openai_endpoint,
api_key=settings.azure_openai_api_key,
deployment=settings.azure_openai_deployment,
api_version=settings.azure_openai_api_version,
)
case "openai":
return OpenAIProvider(
api_key=settings.openai_api_key,
model=settings.openai_model,
)