Resource that identifies an LLM endpoint and its configuration.
| 41 | |
| 42 | |
| 43 | class LLM(Resource): |
| 44 | """Resource that identifies an LLM endpoint and its configuration.""" |
| 45 | |
| 46 | resource_type: Literal["llm"] = "llm" |
| 47 | endpoint: str |
| 48 | """The URL of the LLM API endpoint.""" |
| 49 | model: str |
| 50 | """The identifier for the model to be used (e.g., 'gpt-4o').""" |
| 51 | api_key: Optional[str] = None |
| 52 | """Optional secret used to authenticate requests.""" |
| 53 | sampling_parameters: Dict[str, Any] = Field(default_factory=dict) |
| 54 | """A dictionary of hyperparameters for model inference, such as temperature, top_p, etc.""" |
| 55 | |
| 56 | def get_base_url(self, *args: Any, **kwargs: Any) -> str: |
| 57 | """Return the base URL consumed by OpenAI-compatible clients. |
| 58 | |
| 59 | Users are encouraged to use `get_base_url(rollout_id, attempt_id)` to get |
| 60 | the LLM endpoint instead of accessing `.endpoint` directly. |
| 61 | """ |
| 62 | return self.endpoint |
| 63 | |
| 64 | |
| 65 | class ProxyLLM(LLM): |
no outgoing calls