MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / _get_chat_model

Function _get_chat_model

methods/graph_rag.py:86–113  ·  view source on GitHub ↗

Create Chat model instance with provider auto-detection.

(model_name: str, temperature: float = 0.7, max_tokens: int = 100, callbacks=None)

Source from the content-addressed store, hash-verified

84
85
86def _get_chat_model(model_name: str, temperature: float = 0.7, max_tokens: int = 100, callbacks=None):
87 """Create Chat model instance with provider auto-detection."""
88 model_lower = model_name.lower()
89
90 if 'gemini' in model_lower:
91 return ChatGoogleGenerativeAI(
92 temperature=temperature,
93 model=model_name,
94 max_tokens=max_tokens,
95 callbacks=callbacks,
96 )
97
98 base_url = os.environ.get("OPENAI_BASE_URL")
99 api_key = os.environ.get("OPENAI_API_KEY")
100
101 kwargs = {
102 "model_name": model_name,
103 "temperature": temperature,
104 "max_tokens": max_tokens,
105 }
106 if api_key:
107 kwargs["api_key"] = api_key
108 if base_url:
109 kwargs["base_url"] = base_url
110 if callbacks:
111 kwargs["callbacks"] = callbacks
112
113 return ChatOpenAI(**kwargs)
114
115
116class Concepts(BaseModel):

Callers 1

__init__Method · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected