Normalize model name to LiteLLM format (provider/model).
(model: str)
| 56 | |
| 57 | |
| 58 | def normalize_model_name(model: str) -> str: |
| 59 | """Normalize model name to LiteLLM format (provider/model).""" |
| 60 | if "/" in model: |
| 61 | return model |
| 62 | |
| 63 | model_lower = model.lower() |
| 64 | |
| 65 | if model_lower.startswith( |
| 66 | ("gpt-", "o1-", "o3-", "text-", "davinci", "curie", "babbage", "ada") |
| 67 | ): |
| 68 | return f"openai/{model}" |
| 69 | if model_lower.startswith("claude"): |
| 70 | return f"anthropic/{model}" |
| 71 | if model_lower.startswith(("gemini", "palm")): |
| 72 | return f"google/{model}" |
| 73 | if model_lower.startswith(("mistral", "mixtral", "codestral")): |
| 74 | return f"mistral/{model}" |
| 75 | if model_lower.startswith(("command", "cohere")): |
| 76 | return f"cohere/{model}" |
| 77 | |
| 78 | return f"openai/{model}" |
| 79 | |
| 80 | |
| 81 | def get_provider_from_model(model: str) -> str: |
no outgoing calls
no test coverage detected