File size: 676 Bytes
8ba64a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from typing import Type

from ..config import get_settings
from .base import BaseAttributionService
from .service_anthropic import AnthropicService
from .service_openai import OpenAIService

settings = get_settings()


class AIServiceFactory:
    _services = {"openai": OpenAIService, "anthropic": AnthropicService}

    @classmethod
    def get_service(cls, ai_vendor: str = None) -> BaseAttributionService:
        ai_vendor = ai_vendor or settings.DEFAULT_VENDOR
        service_class = cls._services.get(ai_vendor.lower())
        if not service_class:
            raise ValueError(f"Unsupported ai_vendor: {ai_vendor}")
        return service_class()