Spaces:
Runtime error
Runtime error
Download backend/integrations/llm/factory.py from Amitkasar/ai-api-testing: direct link, hf CLI and curl.
- Browser
- Download file 637 Bytes
-
https://huggingface.co/spaces/Amitkasar/ai-api-testing/resolve/main/backend/integrations/llm/factory.py
- Command line
-
hf download hf://spaces/Amitkasar/ai-api-testing/backend/integrations/llm/factory.py
-
curl -L -o factory.py https://huggingface.co/spaces/Amitkasar/ai-api-testing/resolve/main/backend/integrations/llm/factory.py
637 Bytes
| from .base import BaseLLMClient | |
| from .providers import AnthropicClient, GeminiClient, GroqClient, MistralClient, OpenAIClient | |
| _PROVIDER_MAP: dict[str, type[BaseLLMClient]] = { | |
| "mistral": MistralClient, | |
| "anthropic": AnthropicClient, | |
| "openai": OpenAIClient, | |
| "gemini": GeminiClient, | |
| "groq": GroqClient, | |
| } | |
| def build_client(provider_id: str, model: str, api_key: str, temperature: float = 0.0) -> BaseLLMClient: | |
| cls = _PROVIDER_MAP.get(provider_id) | |
| if not cls: | |
| raise ValueError(f"Unknown LLM provider: '{provider_id}'") | |
| return cls(model=model, api_key=api_key, temperature=temperature) | |