R-Kentaren commited on
Commit
154253c
·
verified ·
1 Parent(s): 8d5e34c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -101
app.py CHANGED
@@ -4,7 +4,7 @@ import time
4
  import traceback
5
  from pathlib import Path
6
  from typing import Any, Dict, List, Tuple
7
-
8
  import torch
9
  from fastapi import Request
10
  from fastapi.responses import HTMLResponse, JSONResponse
@@ -106,106 +106,6 @@ def _ensure_chat_template(tokenizer, model_id: str):
106
  tokenizer.chat_template = tpl
107
  print(f"[chat_template] injected fallback template for {model_id}")
108
 
109
- # ── Model Registry ──────────────────────────────────────────────────────
110
- MODEL_REGISTRY: Dict[str, Dict[str, Any]] = {
111
- "HuggingFaceTB/SmolLM2-360M-Instruct": {
112
- "label": "SmolLM2 360M · ultra-fast",
113
- "family": "causal-lm",
114
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
115
- "context": 2048,
116
- },
117
- "Qwen/Qwen2.5-0.5B-Instruct": {
118
- "label": "Qwen2.5 0.5B · lightweight",
119
- "family": "causal-lm",
120
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
121
- "context": 32768,
122
- },
123
- "TinyLlama/TinyLlama-1.1B-Chat-v1.0": {
124
- "label": "TinyLlama 1.1B · balanced",
125
- "family": "causal-lm",
126
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
127
- "context": 2048,
128
- },
129
- "Qwen/Qwen2.5-1.5B-Instruct": {
130
- "label": "Qwen2.5 1.5B · capable",
131
- "family": "causal-lm",
132
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
133
- "context": 32768,
134
- },
135
- "microsoft/Phi-3.5-mini-instruct": {
136
- "label": "Phi-3.5 mini · higher quality",
137
- "family": "causal-lm",
138
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
139
- "context": 128000,
140
- },
141
- "microsoft/Phi-3-mini-4k-instruct": {
142
- "label": "Phi-3 mini 4K · T4 sweet spot",
143
- "family": "causal-lm",
144
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
145
- "context": 4096,
146
- },
147
- "Qwen/Qwen2.5-3B-Instruct": {
148
- "label": "Qwen2.5 3B · T4 capable",
149
- "family": "causal-lm",
150
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
151
- "context": 32768,
152
- },
153
- "openbmb/MiniCPM5-2B": {
154
- "label": "MiniCPM5 2B · T4 verified 100+ tok/s",
155
- "family": "causal-lm",
156
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
157
- "context": 131072,
158
- },
159
- "constructai/Qwenite3.5-2B": {
160
- "label": "Qwenite 3.5 2B · T4 trained reasoning",
161
- "family": "causal-lm",
162
- "tasks": ["chat", "code", "summarize", "translate", "agent"],
163
- "context": 32768,
164
- },
165
- }
166
-
167
- DEFAULT_MODEL = "HuggingFaceTB/SmolLM2-360M-Instruct"
168
-
169
- # ── Task Registry ───────────────────────────────────────────────────────
170
- TASK_REGISTRY: Dict[str, Dict[str, Any]] = {
171
- "chat": {
172
- "label": "💬 Chat",
173
- "description": "Open-ended conversation",
174
- "system_prompt": "You are a friendly, helpful conversational assistant.",
175
- },
176
- "code": {
177
- "label": "💻 Code",
178
- "description": "Generate, explain, or debug code",
179
- "system_prompt": (
180
- "You are a senior software engineer. Produce clean, idiomatic, "
181
- "well-commented code. Wrap code in fenced markdown blocks."
182
- ),
183
- },
184
- "summarize": {
185
- "label": "📝 Summarize",
186
- "description": "Condense long text into key points",
187
- "system_prompt": (
188
- "Summarise the user's text in 5–7 bullet points. "
189
- "Be concise and faithful to the source."
190
- ),
191
- },
192
- "translate": {
193
- "label": "🌍 Translate",
194
- "description": "Translate text between languages",
195
- "system_prompt": (
196
- "Translate the user's text. If they don't specify a target "
197
- "language, translate to English."
198
- ),
199
- },
200
- "agent": {
201
- "label": "🤖 Agent",
202
- "description": "Autonomous tool-using agent",
203
- "system_prompt": (
204
- "You are an autonomous agent. Use tools when they help, "
205
- "then give a final answer."
206
- ),
207
- },
208
- }
209
 
210
  # ── Model cache (lazy) ──────────────────────────────────────────────────
211
  _MODEL_CACHE: Dict[str, Dict[str, Any]] = {}
 
4
  import traceback
5
  from pathlib import Path
6
  from typing import Any, Dict, List, Tuple
7
+ from config import *
8
  import torch
9
  from fastapi import Request
10
  from fastapi.responses import HTMLResponse, JSONResponse
 
106
  tokenizer.chat_template = tpl
107
  print(f"[chat_template] injected fallback template for {model_id}")
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  # ── Model cache (lazy) ──────────────────────────────────────────────────
111
  _MODEL_CACHE: Dict[str, Dict[str, Any]] = {}