Coverage for src/fastoai/routers/_client.py: 91%

1 from typing import get_args

2

3 from anthropic import AsyncAnthropic

4 from anthropic.types.model_param import ModelParam

5 from openai import AsyncOpenAI

6 from openai.types.chat_model import ChatModel

7

8

9 def get_client_class(model: str) -> type[AsyncAnthropic] | type[AsyncOpenAI]:

10 if model in get_args(ChatModel):

11 return AsyncOpenAI

12 if model in get_args(get_args(ModelParam)[1]):

13 return AsyncAnthropic

14 raise ValueError(f"Can't recognize model {model}.")