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

Update backend_models.py

Browse files
Files changed (1) hide show
  1. backend_models.py +13 -11
backend_models.py CHANGED
@@ -1,21 +1,23 @@
1
  import os
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
- # Dù menu có 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
-
 
1
  import os
2
+ import google.generativeai as genai
3
+
4
+ # Cấu hình API Key của bạn
5
+ # Bạn nên lưu key này trong phần 'Secrets' của Hugging Face với tên GEMINI_API_KEY
6
+ genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
7
 
8
  def get_inference_client(model_id: str, provider: str = "auto"):
9
+ """
10
+ Trả về model Gemini để xử lý yêu cầu.
11
+ """
12
+ # Gemini 1.5 Flash rất nhanh và thông minh cho tác vụ code
13
+ model = genai.GenerativeModel('gemini-1.5-flash')
14
+ return model
15
 
16
  def get_real_model_id(model_id: str) -> str:
17
+ return "gemini-1.5-flash"
 
 
18
 
19
  def is_native_sdk_model(model_id: str) -> bool:
20
+ return True
21
 
22
  def is_mistral_model(model_id: str) -> bool:
23
  return False