Download models_configuration.py from ResiNetResearchGroup/ResiNet-LLM-topology: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/ResiNetResearchGroup/ResiNet-LLM-topology/resolve/main/models_configuration.py
- Command line
-
hf download hf://ResiNetResearchGroup/ResiNet-LLM-topology/models_configuration.py
-
curl -L -o models_configuration.py https://huggingface.co/ResiNetResearchGroup/ResiNet-LLM-topology/resolve/main/models_configuration.py
2.26 kB
| # Models | |
| from typing import Any, List, Dict, Optional | |
| from langchain_community.chat_models import ChatOllama | |
| from langchain_core.messages import HumanMessage, AIMessage, SystemMessage | |
| model_configurations: Dict[str, Dict[str, Any]] = { | |
| "qwen3:32b": { | |
| "type": "Ollama", | |
| "model_name": "qwen3:32b", | |
| "temperature": 0.3, | |
| }, | |
| "mistral-small:24b": { | |
| "type": "Ollama", | |
| "model_name": "mistral-small:24b", | |
| "temperature": 0.3, | |
| }, | |
| "deepseek-r1:32b": { | |
| "type": "Ollama", | |
| "model_name": "deepseek-r1:32b", | |
| "temperature": 0.3, | |
| } | |
| } | |
| class OllamaWithDebug(ChatOllama): | |
| def __init__(self, model, **kwargs): | |
| super().__init__(model=model, **kwargs) | |
| print(f"--- DEBUG INIT: Model {model} ---") | |
| print(f"Injected parameters: {kwargs}") | |
| print("Actual instance attributes:") | |
| for attr in ['temperature', 'top_p', 'base_url']: | |
| print(f" - {attr}: {getattr(self, attr, 'UNDEFINED')}") | |
| print("-" * 40) | |
| def invoke(self, messages: Any, **kwargs): | |
| print(f"\n[DEBUG INVOKE] Sending to {self.model}") | |
| temp = getattr(self, 'temperature', 'N/A') | |
| print(f"Active config -> Temp: {temp}") | |
| preview = str(messages)[:150] | |
| print(f"Input preview: {preview}...") | |
| try: | |
| response = super().invoke(messages, **kwargs) | |
| print(f"[DEBUG RESPONSE] Success! Response length: {len(str(response.content))} chars") | |
| return response | |
| except Exception as e: | |
| print(f"!!! DEBUG ERROR !!! Ollama call failed: {e}") | |
| raise | |
| def get_model_instance(model_key: str) -> Any: | |
| config = model_configurations.get(model_key) | |
| if config is None: | |
| raise ValueError(f"Model not configured: {model_key}") | |
| if config.get("type", "").lower() == "ollama": | |
| return OllamaWithDebug( | |
| model=config["model_name"], | |
| base_url="http://localhost:11434", | |
| temperature=config.get("temperature", 0.3), | |
| top_p=config.get("top_p"), | |
| ) | |
| else: | |
| raise ValueError(f"Unsupported or missing model type: {config.get('type')}") |