|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# SPDX-License-Identifier: Apache-2.0 |
| 16 | + |
| 17 | +"""xAI model information.""" |
| 18 | + |
| 19 | +from genkit.types import ModelInfo, Supports |
| 20 | + |
| 21 | +__all__ = ['SUPPORTED_XAI_MODELS', 'get_model_info'] |
| 22 | + |
| 23 | +_LANGUAGE_MODEL_SUPPORTS = Supports( |
| 24 | + multiturn=True, |
| 25 | + tools=True, |
| 26 | + media=False, |
| 27 | + system_role=True, |
| 28 | + output=['text', 'json'], |
| 29 | +) |
| 30 | + |
| 31 | +_VISION_MODEL_SUPPORTS = Supports( |
| 32 | + multiturn=False, |
| 33 | + tools=True, |
| 34 | + media=True, |
| 35 | + system_role=False, |
| 36 | + output=['text', 'json'], |
| 37 | +) |
| 38 | + |
| 39 | +SUPPORTED_XAI_MODELS: dict[str, ModelInfo] = { |
| 40 | + 'grok-3': ModelInfo( |
| 41 | + label='xAI - Grok 3', |
| 42 | + versions=['grok-3'], |
| 43 | + supports=_LANGUAGE_MODEL_SUPPORTS, |
| 44 | + ), |
| 45 | + 'grok-3-fast': ModelInfo( |
| 46 | + label='xAI - Grok 3 Fast', |
| 47 | + versions=['grok-3-fast'], |
| 48 | + supports=_LANGUAGE_MODEL_SUPPORTS, |
| 49 | + ), |
| 50 | + 'grok-3-mini': ModelInfo( |
| 51 | + label='xAI - Grok 3 Mini', |
| 52 | + versions=['grok-3-mini'], |
| 53 | + supports=_LANGUAGE_MODEL_SUPPORTS, |
| 54 | + ), |
| 55 | + 'grok-3-mini-fast': ModelInfo( |
| 56 | + label='xAI - Grok 3 Mini Fast', |
| 57 | + versions=['grok-3-mini-fast'], |
| 58 | + supports=_LANGUAGE_MODEL_SUPPORTS, |
| 59 | + ), |
| 60 | + 'grok-2-vision-1212': ModelInfo( |
| 61 | + label='xAI - Grok 2 Vision', |
| 62 | + versions=['grok-2-vision-1212'], |
| 63 | + supports=_VISION_MODEL_SUPPORTS, |
| 64 | + ), |
| 65 | +} |
| 66 | + |
| 67 | + |
| 68 | +def get_model_info(name: str) -> ModelInfo: |
| 69 | + return SUPPORTED_XAI_MODELS.get( |
| 70 | + name, |
| 71 | + ModelInfo( |
| 72 | + label=f'xAI - {name}', |
| 73 | + supports=_LANGUAGE_MODEL_SUPPORTS, |
| 74 | + ), |
| 75 | + ) |
0 commit comments