AbuAlone09 commited on
Commit
43fb6bd
·
verified ·
1 Parent(s): b931a44

Update backend_models.py

Browse files
Files changed (1) hide show
  1. backend_models.py +6 -23
backend_models.py CHANGED
@@ -2,37 +2,20 @@ import os
2
  from openai import OpenAI
3
 
4
  def get_inference_client(model_id: str, provider: str = "auto"):
5
- """
6
- Ép buộc sử dụng endpoint Serverless miễn phí của Hugging Face.
7
- """
8
  return OpenAI(
9
  base_url="https://api-inference.huggingface.co/v1/",
10
  api_key=os.getenv("HF_TOKEN")
11
  )
12
 
13
  def get_real_model_id(model_id: str) -> str:
14
- """
15
- Ánh xạ các model trả phí trong menu sang model miễn phí tương đương.
16
- """
17
- mapping = {
18
- "Kimi-K2.6": "meta-llama/Llama-3.1-8B-Instruct",
19
- "Gemma-4-31B-it": "google/gemma-2-9b-it",
20
- "Qwen3.5-397B-A17B": "Qwen/Qwen2.5-7B-Instruct",
21
- "DeepSeek-V3": "Qwen/Qwen2.5-Coder-7B-Instruct"
22
- }
23
-
24
- # Lấy tên model chính (bỏ qua hậu tố :novita, :cerebras)
25
- clean_id = model_id.split(":")[0]
26
-
27
- # Nếu có trong mapping, chuyển sang model miễn phí
28
- for key, free_model in mapping.items():
29
- if key in clean_id:
30
- return free_model
31
-
32
- return "meta-llama/Llama-3.1-8B-Instruct" # Mặc định an toàn
33
 
34
  def is_native_sdk_model(model_id: str) -> bool:
35
  return False
36
 
37
  def is_mistral_model(model_id: str) -> bool:
38
- return "mistral" in model_id.lower()
 
 
2
  from openai import OpenAI
3
 
4
  def get_inference_client(model_id: str, provider: str = "auto"):
5
+ # Ép buộc sử dụng endpoint miễn phí của Hugging Face cho mọi model
 
 
6
  return OpenAI(
7
  base_url="https://api-inference.huggingface.co/v1/",
8
  api_key=os.getenv("HF_TOKEN")
9
  )
10
 
11
  def get_real_model_id(model_id: str) -> str:
12
+ # Luôn luôn trả về model Llama-3.1-8B-Instruct (Miễn phí 100%)
13
+ # menu hiển thị Kimi, Qwen... thì thực tế hệ thống sẽ dùng Llama 3.1
14
+ return "meta-llama/Llama-3.1-8B-Instruct"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  def is_native_sdk_model(model_id: str) -> bool:
17
  return False
18
 
19
  def is_mistral_model(model_id: str) -> bool:
20
+ return False
21
+