File size: 1,343 Bytes
00ff2c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from langchain_openai import ChatOpenAI
from langchain_huggingface import HuggingFaceEndpoint
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_community.chat_models import ChatAnthropic
from langchain_community.chat_models import ChatGrok
from langchain_community.chat_models import ChatDeepSeek

# Define supported providers
AVAILABLE_MODELS = {
    "openai": {
        "model": "gpt-4o-mini",
        "client": ChatOpenAI,
        "params": {"temperature": 0},
    },
    "huggingface": {
        "model": "Qwen/Qwen2.5-Coder-32B-Instruct",
        "client": HuggingFaceEndpoint,
        "params": {"temperature": 0},
    },
    "gemini": {
        "model": "gemini-2.0-flash",
        "client": ChatGoogleGenerativeAI,
        "params": {"temperature": 0},
    },
    "grok": {
        "model": "qwen-qwq-32b",
        "client": ChatGrok,
        "params": {"temperature": 0},
    },
    "deepseek": {
        "model": "deepseek-coder",
        "client": ChatDeepSeek,
        "params": {"temperature": 0},
    },
}

# Choose provider dynamically here
PROVIDER = "huggingface"  # Change this to "huggingface", "gemini", "grok", or "deepseek"

def get_llm(PROVIDER=PROVIDER):
    config = AVAILABLE_MODELS[PROVIDER]
    model_class = config["client"]
    return model_class(model=config["model"], **config["params"])