"""Factory for creating message channels from target configuration.""" from agenteval.channels.base import EvalChannel from agenteval.channels.http import HttpChannel from agenteval.channels.tutu import TutuApiChannel from agenteval.models import ChannelType, EvalTarget class ChannelFactory: """Create the appropriate channel adapter for a target.""" _mapping: dict[ChannelType, type[EvalChannel]] = { ChannelType.TUTU_API: TutuApiChannel, ChannelType.HTTP: HttpChannel, } @classmethod def create(cls, target: EvalTarget) -> EvalChannel: if target.channel_type not in cls._mapping: raise ValueError(f"unsupported channel type: {target.channel_type}") return cls._mapping[target.channel_type](target.channel_config) @classmethod def register(cls, channel_type: ChannelType, channel_cls: type[EvalChannel]) -> None: cls._mapping[channel_type] = channel_cls