File size: 1,064 Bytes
ea077e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from .ModelStrategy import ModelStrategy

from langchain_community.chat_models import ChatOpenAI
from langchain_mistralai.chat_models import ChatMistralAI
from langchain_anthropic import ChatAnthropic
from langchain_ollama import ChatOllama

class MistralModel(ModelStrategy):
    def get_model(self, model_name):
        return ChatMistralAI(model=model_name)
    

class OpenAIModel(ModelStrategy):
    def get_model(self, model_name):
        return ChatOpenAI(model=model_name)


class AnthropicModel(ModelStrategy):
    def get_model(self, model_name):
        return ChatAnthropic(model=model_name)


class OllamaModel(ModelStrategy):
    def get_model(self, model_name):
        return ChatOllama(model=model_name)

class ModelManager():
    def __init__(self):
        self.models = {
            "mistral": MistralModel(),
            "openai": OpenAIModel(),
            "anthropic": AnthropicModel(),
            "ollama": OllamaModel()
        }

    def get_model(self, provider, model_name):
        return self.models[provider].get_model(model_name)