Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/transformers/cli/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
from urllib.parse import urljoin, urlparse

import httpx
import requests
import typer


try:
import requests
except ImportError:
requests = None
import yaml
from huggingface_hub import AsyncInferenceClient, ChatCompletionStreamOutput

Expand Down Expand Up @@ -209,6 +214,12 @@ def print_help(self, minimal: bool = False):
self._console.print()

def print_model_load(self, model: str):
if requests is None:
self._console.print(
"[bold red]Error: 'requests' package is required for serving mode.[/bold red] "
"Install it with: pip install requests"
)
return
response = requests.post(f"{self.base_url.rstrip('/')}/load_model", json={"model": model}, stream=True)
response.raise_for_status()

Expand Down
Loading