AbuAlone09 commited on
Commit
f40ffb1
·
verified ·
1 Parent(s): 5a5470f

Update backend_models.py

Browse files
Files changed (1) hide show
  1. backend_models.py +12 -5
backend_models.py CHANGED
@@ -3,21 +3,28 @@ from openai import OpenAI
3
 
4
  def get_inference_client(model_id: str, provider: str = "auto"):
5
  """
6
- Ép hệ thống sử dụng endpoint miễn phí của Hugging Face
7
- cho tất cả các model trong danh sách.
8
  """
9
- # Xóa bỏ hoàn toàn header X-HF-Bill-To để tránh lỗi 402
10
  return OpenAI(
11
  base_url="https://api-inference.huggingface.co/v1/",
12
  api_key=os.getenv("HF_TOKEN")
13
  )
14
 
15
  def get_real_model_id(model_id: str) -> str:
16
- # Trả về ID sạch, không có hậu tố :novita hay :cerebras
17
- return model_id.split(":")[0]
 
 
 
 
 
 
18
 
19
  def is_native_sdk_model(model_id: str) -> bool:
20
  return False
21
 
22
  def is_mistral_model(model_id: str) -> bool:
23
  return "mistral" in model_id.lower()
 
 
3
 
4
  def get_inference_client(model_id: str, provider: str = "auto"):
5
  """
6
+ Ép tất cả các model trong danh sách (Kimi, Gemma, Qwen...)
7
+ phải gọi vào endpoint miễn phí của Hugging Face.
8
  """
9
+ # Nếu đòi Novita, ta cứ phớt lờ đưa nó sang endpoint miễn phí
10
  return OpenAI(
11
  base_url="https://api-inference.huggingface.co/v1/",
12
  api_key=os.getenv("HF_TOKEN")
13
  )
14
 
15
  def get_real_model_id(model_id: str) -> str:
16
+ """
17
+ Hàm này cực kỳ quan trọng:
18
+ Nó biến 'moonshotai/Kimi-K2.6:novita' thành 'moonshotai/Kimi-K2.6'
19
+ 'google/gemma-4-31B:fastest' thành 'google/gemma-4-31B'
20
+ """
21
+ # Xóa hậu tố provider để API của Hugging Face nhận diện được model
22
+ base_id = model_id.split(":")[0]
23
+ return base_id
24
 
25
  def is_native_sdk_model(model_id: str) -> bool:
26
  return False
27
 
28
  def is_mistral_model(model_id: str) -> bool:
29
  return "mistral" in model_id.lower()
30
+