Manish Kumar commited on
Commit ·
ef7f5ec
1
Parent(s): 99f9013
chnage model
Browse files- .env +4 -4
- backend/app/config.py +1 -1
- backend/app/llm/manager.py +2 -2
- backend/app/main.py +1 -1
- frontend/src/components/ChatInterface.tsx +1 -1
- frontend/src/components/Dashboard.tsx +2 -2
- frontend/src/components/Navbar.tsx +1 -1
- frontend/src/components/Settings.tsx +2 -2
- frontend/src/hooks/useChat.ts +2 -2
- render.yaml +3 -3
- scripts/download_model.py +3 -3
.env
CHANGED
|
@@ -5,10 +5,10 @@ HOST=0.0.0.0
|
|
| 5 |
DEBUG=true
|
| 6 |
CORS_ORIGINS=http://localhost:5173,http://localhost:3000,http://localhost:8000
|
| 7 |
|
| 8 |
-
# SmolLM2 Model Settings
|
| 9 |
-
LOCAL_MODEL_PATH=models/SmolLM2-
|
| 10 |
-
LOCAL_MODEL_REPO=bartowski/SmolLM2-
|
| 11 |
-
LOCAL_MODEL_FILE=SmolLM2-
|
| 12 |
|
| 13 |
# Generation Parameters
|
| 14 |
DEFAULT_TEMPERATURE=0.7
|
|
|
|
| 5 |
DEBUG=true
|
| 6 |
CORS_ORIGINS=http://localhost:5173,http://localhost:3000,http://localhost:8000
|
| 7 |
|
| 8 |
+
# SmolLM2 Model Settings (135M for Render free tier)
|
| 9 |
+
LOCAL_MODEL_PATH=models/SmolLM2-135M-Instruct-Q4_K_M.gguf
|
| 10 |
+
LOCAL_MODEL_REPO=bartowski/SmolLM2-135M-Instruct-GGUF
|
| 11 |
+
LOCAL_MODEL_FILE=SmolLM2-135M-Instruct-Q4_K_M.gguf
|
| 12 |
|
| 13 |
# Generation Parameters
|
| 14 |
DEFAULT_TEMPERATURE=0.7
|
backend/app/config.py
CHANGED
|
@@ -6,7 +6,7 @@ class Settings(BaseSettings):
|
|
| 6 |
HOST: str = Field(default="0.0.0.0")
|
| 7 |
DEBUG: bool = Field(default=False)
|
| 8 |
|
| 9 |
-
LOCAL_MODEL_PATH: str = Field(default="models/SmolLM2-
|
| 10 |
|
| 11 |
DEFAULT_TEMPERATURE: float = Field(default=0.7)
|
| 12 |
DEFAULT_MAX_TOKENS: int = Field(default=512)
|
|
|
|
| 6 |
HOST: str = Field(default="0.0.0.0")
|
| 7 |
DEBUG: bool = Field(default=False)
|
| 8 |
|
| 9 |
+
LOCAL_MODEL_PATH: str = Field(default="models/SmolLM2-135M-Instruct-Q4_K_M.gguf")
|
| 10 |
|
| 11 |
DEFAULT_TEMPERATURE: float = Field(default=0.7)
|
| 12 |
DEFAULT_MAX_TOKENS: int = Field(default=512)
|
backend/app/llm/manager.py
CHANGED
|
@@ -8,8 +8,8 @@ from backend.app.config import settings
|
|
| 8 |
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
-
MODEL_REPO = "bartowski/SmolLM2-
|
| 12 |
-
MODEL_FILE = "SmolLM2-
|
| 13 |
|
| 14 |
|
| 15 |
class LLMManager:
|
|
|
|
| 8 |
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
+
MODEL_REPO = "bartowski/SmolLM2-135M-Instruct-GGUF"
|
| 12 |
+
MODEL_FILE = "SmolLM2-135M-Instruct-Q4_K_M.gguf"
|
| 13 |
|
| 14 |
|
| 15 |
class LLMManager:
|
backend/app/main.py
CHANGED
|
@@ -103,7 +103,7 @@ async def run_standard(
|
|
| 103 |
"total_tokens": usage.get("total_tokens", 0),
|
| 104 |
"duration_ms": int(duration * 1000),
|
| 105 |
},
|
| 106 |
-
model="SmolLM2-
|
| 107 |
)
|
| 108 |
except Exception as e:
|
| 109 |
logger.error(f"Generation error: {e}")
|
|
|
|
| 103 |
"total_tokens": usage.get("total_tokens", 0),
|
| 104 |
"duration_ms": int(duration * 1000),
|
| 105 |
},
|
| 106 |
+
model="SmolLM2-135M-Q4_K_M",
|
| 107 |
)
|
| 108 |
except Exception as e:
|
| 109 |
logger.error(f"Generation error: {e}")
|
frontend/src/components/ChatInterface.tsx
CHANGED
|
@@ -204,7 +204,7 @@ export const ChatInterface: React.FC<ChatInterfaceProps> = ({
|
|
| 204 |
}
|
| 205 |
};
|
| 206 |
|
| 207 |
-
const modelName = modelInfo?.model_name.split('/').pop() || 'SmolLM2-
|
| 208 |
|
| 209 |
return (
|
| 210 |
<div className="flex-1 flex h-full bg-[#090810] min-w-0 overflow-hidden font-sans">
|
|
|
|
| 204 |
}
|
| 205 |
};
|
| 206 |
|
| 207 |
+
const modelName = modelInfo?.model_name.split('/').pop() || 'SmolLM2-135M-Instruct';
|
| 208 |
|
| 209 |
return (
|
| 210 |
<div className="flex-1 flex h-full bg-[#090810] min-w-0 overflow-hidden font-sans">
|
frontend/src/components/Dashboard.tsx
CHANGED
|
@@ -66,7 +66,7 @@ export const Dashboard: React.FC<DashboardProps> = ({
|
|
| 66 |
}, 100);
|
| 67 |
};
|
| 68 |
|
| 69 |
-
const modelName = modelInfo?.model_name || 'SmolLM2-
|
| 70 |
|
| 71 |
return (
|
| 72 |
<div className="flex-1 overflow-y-auto bg-[#090810] p-6 space-y-6 font-sans max-w-[1400px] mx-auto w-full">
|
|
@@ -118,7 +118,7 @@ export const Dashboard: React.FC<DashboardProps> = ({
|
|
| 118 |
</div>
|
| 119 |
</div>
|
| 120 |
<div className="space-y-1 flex-1 flex flex-col justify-end">
|
| 121 |
-
<h2 className="text-sm font-bold text-white">~
|
| 122 |
<p className="text-[10px] text-[#58556f]">Q4_K_M quantized</p>
|
| 123 |
</div>
|
| 124 |
</div>
|
|
|
|
| 66 |
}, 100);
|
| 67 |
};
|
| 68 |
|
| 69 |
+
const modelName = modelInfo?.model_name || 'SmolLM2-135M-Q4_K_M';
|
| 70 |
|
| 71 |
return (
|
| 72 |
<div className="flex-1 overflow-y-auto bg-[#090810] p-6 space-y-6 font-sans max-w-[1400px] mx-auto w-full">
|
|
|
|
| 118 |
</div>
|
| 119 |
</div>
|
| 120 |
<div className="space-y-1 flex-1 flex flex-col justify-end">
|
| 121 |
+
<h2 className="text-sm font-bold text-white">~80 MB</h2>
|
| 122 |
<p className="text-[10px] text-[#58556f]">Q4_K_M quantized</p>
|
| 123 |
</div>
|
| 124 |
</div>
|
frontend/src/components/Navbar.tsx
CHANGED
|
@@ -108,7 +108,7 @@ export const Navbar: React.FC<NavbarProps> = ({
|
|
| 108 |
<div className="hidden lg:flex items-center gap-2 px-3 py-1.5 bg-secondary border border-border rounded-full text-xs font-semibold text-foreground">
|
| 109 |
<Cpu size={13} className="text-primary animate-pulse" />
|
| 110 |
<span className="truncate max-w-[120px] font-mono text-[11px]">
|
| 111 |
-
{modelInfo?.model_name.split('/').pop() || 'SmolLM2-
|
| 112 |
</span>
|
| 113 |
</div>
|
| 114 |
|
|
|
|
| 108 |
<div className="hidden lg:flex items-center gap-2 px-3 py-1.5 bg-secondary border border-border rounded-full text-xs font-semibold text-foreground">
|
| 109 |
<Cpu size={13} className="text-primary animate-pulse" />
|
| 110 |
<span className="truncate max-w-[120px] font-mono text-[11px]">
|
| 111 |
+
{modelInfo?.model_name.split('/').pop() || 'SmolLM2-135M'}
|
| 112 |
</span>
|
| 113 |
</div>
|
| 114 |
|
frontend/src/components/Settings.tsx
CHANGED
|
@@ -51,7 +51,7 @@ export const Settings: React.FC<SettingsProps> = ({
|
|
| 51 |
<div className="space-y-1.5">
|
| 52 |
<label className="text-[10px] font-bold text-[#9d99b3] uppercase tracking-wider">Model</label>
|
| 53 |
<div className="bg-[#090810] border border-[#1d1b2e] text-xs text-white rounded-xl px-3 py-2.5 font-mono">
|
| 54 |
-
SmolLM2-
|
| 55 |
</div>
|
| 56 |
</div>
|
| 57 |
|
|
@@ -127,7 +127,7 @@ export const Settings: React.FC<SettingsProps> = ({
|
|
| 127 |
<div className="space-y-3.5 text-xs select-none">
|
| 128 |
<div className="flex justify-between">
|
| 129 |
<span className="text-[#9d99b3]">Model</span>
|
| 130 |
-
<span className="font-semibold text-white font-mono text-[11px]">{modelInfo?.model_name || 'SmolLM2-
|
| 131 |
</div>
|
| 132 |
<div className="flex justify-between">
|
| 133 |
<span className="text-[#9d99b3]">Status</span>
|
|
|
|
| 51 |
<div className="space-y-1.5">
|
| 52 |
<label className="text-[10px] font-bold text-[#9d99b3] uppercase tracking-wider">Model</label>
|
| 53 |
<div className="bg-[#090810] border border-[#1d1b2e] text-xs text-white rounded-xl px-3 py-2.5 font-mono">
|
| 54 |
+
SmolLM2-135M-Instruct-Q4_K_M.gguf
|
| 55 |
</div>
|
| 56 |
</div>
|
| 57 |
|
|
|
|
| 127 |
<div className="space-y-3.5 text-xs select-none">
|
| 128 |
<div className="flex justify-between">
|
| 129 |
<span className="text-[#9d99b3]">Model</span>
|
| 130 |
+
<span className="font-semibold text-white font-mono text-[11px]">{modelInfo?.model_name || 'SmolLM2-135M-Q4_K_M'}</span>
|
| 131 |
</div>
|
| 132 |
<div className="flex justify-between">
|
| 133 |
<span className="text-[#9d99b3]">Status</span>
|
frontend/src/hooks/useChat.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const useChat = () => {
|
|
| 16 |
const [conversations, setConversations] = useState<Conversation[]>([]);
|
| 17 |
const [activeConversationId, setActiveConversationId] = useState<string | null>(null);
|
| 18 |
const [settings, setSettings] = useState<AppSettings>(DEFAULT_SETTINGS);
|
| 19 |
-
const modelInfo = { model_name: 'SmolLM2-
|
| 20 |
const [isLoading, setIsLoading] = useState<boolean>(false);
|
| 21 |
const [error, setError] = useState<string | null>(null);
|
| 22 |
|
|
@@ -86,7 +86,7 @@ export const useChat = () => {
|
|
| 86 |
id: Math.random().toString(36).substring(7),
|
| 87 |
title: cleanTitle,
|
| 88 |
messages: [],
|
| 89 |
-
activeModel: 'SmolLM2-
|
| 90 |
timestamp: Date.now(),
|
| 91 |
};
|
| 92 |
setConversations((prev) => [newConv, ...prev]);
|
|
|
|
| 16 |
const [conversations, setConversations] = useState<Conversation[]>([]);
|
| 17 |
const [activeConversationId, setActiveConversationId] = useState<string | null>(null);
|
| 18 |
const [settings, setSettings] = useState<AppSettings>(DEFAULT_SETTINGS);
|
| 19 |
+
const modelInfo = { model_name: 'SmolLM2-135M-Q4_K_M', status: 'loaded' };
|
| 20 |
const [isLoading, setIsLoading] = useState<boolean>(false);
|
| 21 |
const [error, setError] = useState<string | null>(null);
|
| 22 |
|
|
|
|
| 86 |
id: Math.random().toString(36).substring(7),
|
| 87 |
title: cleanTitle,
|
| 88 |
messages: [],
|
| 89 |
+
activeModel: 'SmolLM2-135M-Q4_K_M',
|
| 90 |
timestamp: Date.now(),
|
| 91 |
};
|
| 92 |
setConversations((prev) => [newConv, ...prev]);
|
render.yaml
CHANGED
|
@@ -8,11 +8,11 @@ services:
|
|
| 8 |
- key: PORT
|
| 9 |
value: 8000
|
| 10 |
- key: LOCAL_MODEL_PATH
|
| 11 |
-
value: models/SmolLM2-
|
| 12 |
- key: DEFAULT_CONTEXT_LENGTH
|
| 13 |
-
value:
|
| 14 |
- key: DEFAULT_MAX_TOKENS
|
| 15 |
-
value:
|
| 16 |
disk:
|
| 17 |
name: models-storage
|
| 18 |
mountPath: /app/models
|
|
|
|
| 8 |
- key: PORT
|
| 9 |
value: 8000
|
| 10 |
- key: LOCAL_MODEL_PATH
|
| 11 |
+
value: models/SmolLM2-135M-Instruct-Q4_K_M.gguf
|
| 12 |
- key: DEFAULT_CONTEXT_LENGTH
|
| 13 |
+
value: 1024
|
| 14 |
- key: DEFAULT_MAX_TOKENS
|
| 15 |
+
value: 1024
|
| 16 |
disk:
|
| 17 |
name: models-storage
|
| 18 |
mountPath: /app/models
|
scripts/download_model.py
CHANGED
|
@@ -2,9 +2,9 @@ import os
|
|
| 2 |
import sys
|
| 3 |
|
| 4 |
def download_model():
|
| 5 |
-
repo_id = os.getenv("LOCAL_MODEL_REPO", "bartowski/SmolLM2-
|
| 6 |
-
filename = os.getenv("LOCAL_MODEL_FILE", "SmolLM2-
|
| 7 |
-
model_path = os.getenv("LOCAL_MODEL_PATH", "models/SmolLM2-
|
| 8 |
|
| 9 |
target_dir = os.path.dirname(os.path.abspath(model_path))
|
| 10 |
os.makedirs(target_dir, exist_ok=True)
|
|
|
|
| 2 |
import sys
|
| 3 |
|
| 4 |
def download_model():
|
| 5 |
+
repo_id = os.getenv("LOCAL_MODEL_REPO", "bartowski/SmolLM2-135M-Instruct-GGUF")
|
| 6 |
+
filename = os.getenv("LOCAL_MODEL_FILE", "SmolLM2-135M-Instruct-Q4_K_M.gguf")
|
| 7 |
+
model_path = os.getenv("LOCAL_MODEL_PATH", "models/SmolLM2-135M-Instruct-Q4_K_M.gguf")
|
| 8 |
|
| 9 |
target_dir = os.path.dirname(os.path.abspath(model_path))
|
| 10 |
os.makedirs(target_dir, exist_ok=True)
|