File size: 847 Bytes
a8b3f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from services.auth.api_key_auth_base import ApiKeyAuthBase
from services.auth.auth_type import AuthType


class ApiKeyAuthFactory:
    def __init__(self, provider: str, credentials: dict):
        auth_factory = self.get_apikey_auth_factory(provider)
        self.auth = auth_factory(credentials)

    def validate_credentials(self):
        return self.auth.validate_credentials()

    @staticmethod
    def get_apikey_auth_factory(provider: str) -> type[ApiKeyAuthBase]:
        match provider:
            case AuthType.FIRECRAWL:
                from services.auth.firecrawl.firecrawl import FirecrawlAuth

                return FirecrawlAuth
            case AuthType.JINA:
                from services.auth.jina.jina import JinaAuth

                return JinaAuth
            case _:
                raise ValueError("Invalid provider")