Spaces:
Runtime error
Runtime error
Create lib/settings.py
Browse files- lib/settings.py +27 -0
lib/settings.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from llama_cpp_agent import MessagesFormatterType
|
| 2 |
+
|
| 3 |
+
def get_context_by_model(model_name):
|
| 4 |
+
model_context_limits = {
|
| 5 |
+
"Mistral-7B-Instruct-v0.3-Q6_K.gguf": 32768,
|
| 6 |
+
"mixtral-8x7b-instruct-v0.1.Q5_K_M.gguf": 32768,
|
| 7 |
+
"Meta-Llama-3-8B-Instruct-Q6_K.gguf": 8192,
|
| 8 |
+
"gemma-2-9b-it-Q8_0.gguf": 8192,
|
| 9 |
+
"cognitivecomputations_Dolphin3.0-Mistral-24B-Q8_0.gguf": 8192,
|
| 10 |
+
"gemma-2-27b-it-Q8_0.gguf": 8192
|
| 11 |
+
}
|
| 12 |
+
return model_context_limits.get(model_name, None)
|
| 13 |
+
|
| 14 |
+
def get_messages_formatter_type(model_name):
|
| 15 |
+
model_name = model_name.lower()
|
| 16 |
+
if any(keyword in model_name for keyword in ["meta", "aya"]):
|
| 17 |
+
return MessagesFormatterType.LLAMA_3
|
| 18 |
+
elif any(keyword in model_name for keyword in ["mistral", "mixtral"]):
|
| 19 |
+
return MessagesFormatterType.MISTRAL
|
| 20 |
+
elif any(keyword in model_name for keyword in ["einstein", "dolphin", "cognitivecomputations"]):
|
| 21 |
+
return MessagesFormatterType.CHATML
|
| 22 |
+
elif any(keyword in model_name for keyword in ["gemma"]):
|
| 23 |
+
return MessagesFormatterType.GEMMA_2
|
| 24 |
+
elif "phi" in model_name:
|
| 25 |
+
return MessagesFormatterType.PHI_3
|
| 26 |
+
else:
|
| 27 |
+
return MessagesFormatterType.CHATML
|