AbuAlone09 commited on
Commit
0e70d75
·
verified ·
1 Parent(s): 10ac332

Update backend_models.py

Browse files
Files changed (1) hide show
  1. backend_models.py +7 -6
backend_models.py CHANGED
@@ -1,11 +1,12 @@
1
  import os
2
  from openai import OpenAI
3
 
4
- # Sử dụng key duy nhất từ GROQ
5
- client = OpenAI(
6
- base_url="https://api.groq.com/openai/v1",
7
- api_key=os.getenv("GROQ_API_KEY")
8
- )
 
9
 
10
  def get_real_model_id(model_id: str) -> str:
11
  mapping = {
@@ -13,8 +14,8 @@ def get_real_model_id(model_id: str) -> str:
13
  "Qwen 2.5 Coder": "qwen-2.5-coder-32b",
14
  "Gemma 2 9B": "gemma-2-9b-it"
15
  }
16
- # Mặc định dùng Llama 3.3 nếu có lỗi
17
  return mapping.get(model_id, "llama-3.3-70b-versatile")
18
 
 
19
  def is_native_sdk_model(model_id: str) -> bool: return True
20
  def is_mistral_model(model_id: str) -> bool: return False
 
1
  import os
2
  from openai import OpenAI
3
 
4
+ def get_inference_client(model_id: str, provider: str = "auto"):
5
+ """Hàm khởi tạo client kết nối với Groq"""
6
+ return OpenAI(
7
+ base_url="https://api.groq.com/openai/v1",
8
+ api_key=os.getenv("GROQ_API_KEY")
9
+ )
10
 
11
  def get_real_model_id(model_id: str) -> str:
12
  mapping = {
 
14
  "Qwen 2.5 Coder": "qwen-2.5-coder-32b",
15
  "Gemma 2 9B": "gemma-2-9b-it"
16
  }
 
17
  return mapping.get(model_id, "llama-3.3-70b-versatile")
18
 
19
+
20
  def is_native_sdk_model(model_id: str) -> bool: return True
21
  def is_mistral_model(model_id: str) -> bool: return False