| 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | # All rights reserved. |
| 3 | # |
| 4 | # This source code is licensed under the terms described in the LICENSE file in |
| 5 | # the root directory of this source tree. |
| 6 | |
| 7 | from typing import Optional |
| 8 | |
| 9 | from llama_models.schema_utils import json_schema_type |
| 10 | from pydantic import BaseModel, Field |
| 11 | |
| 12 | |
| 13 | @json_schema_type |
| 14 | class TGIImplConfig(BaseModel): |
| 15 | url: Optional[str] = Field( |
| 16 | default=None, |
| 17 | description="The URL for the local TGI endpoint (e.g., http://localhost:8080)", |
| 18 | ) |
| 19 | api_token: Optional[str] = Field( |
| 20 | default=None, |
| 21 | description="The HF token for Hugging Face Inference Endpoints (will default to locally saved token if not provided)", |
| 22 | ) |
| 23 | hf_endpoint_name: Optional[str] = Field( |
| 24 | default=None, |
| 25 | description="The name of the Hugging Face Inference Endpoint : can be either in the format of '{namespace}/{endpoint_name}' (namespace can be the username or organization name) or just '{endpoint_name}' if logged into the same account as the namespace", |
| 26 | ) |
| 27 | |
| 28 | def is_inference_endpoint(self) -> bool: |
| 29 | return self.hf_endpoint_name is not None |