Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -179,62 +179,7 @@ def home():
|
|
| 179 |
status_html += f"<li>{model_name}: {status}</li>"
|
| 180 |
status_html += "</ul>"
|
| 181 |
|
| 182 |
-
return f'''
|
| 183 |
-
<!DOCTYPE html>
|
| 184 |
-
<html>
|
| 185 |
-
<head>
|
| 186 |
-
<title>TeleChars AI API</title>
|
| 187 |
-
<style>
|
| 188 |
-
body {{ font-family: Arial, sans-serif; margin: 40px; }}
|
| 189 |
-
.config {{ background: #f0f0f0; padding: 15px; border-radius: 5px; margin-bottom: 20px; }}
|
| 190 |
-
.endpoint {{ background: #e8f4f8; padding: 10px; border-left: 4px solid #2196F3; margin: 10px 0; }}
|
| 191 |
-
</style>
|
| 192 |
-
</head>
|
| 193 |
-
<body>
|
| 194 |
-
<h1>TeleChars AI API</h1>
|
| 195 |
-
|
| 196 |
-
<div class="config">
|
| 197 |
-
<h3>⚙️ Configuración</h3>
|
| 198 |
-
<p><strong>Max Context Tokens:</strong> {MAX_CONTEXT_TOKENS}</p>
|
| 199 |
-
<p><strong>Max Generation Tokens:</strong> {MAX_GENERATION_TOKENS}</p>
|
| 200 |
-
</div>
|
| 201 |
-
|
| 202 |
-
<h2>📦 Modelos cargados:</h2>
|
| 203 |
-
{status_html}
|
| 204 |
-
<p>Total modelos: {len(loaded_models)}/{len(MODELS)}</p>
|
| 205 |
-
|
| 206 |
-
<h2>🔗 Endpoints disponibles:</h2>
|
| 207 |
-
<div class="endpoint">
|
| 208 |
-
<strong>GET /generate/<mensaje>[?params]</strong><br>
|
| 209 |
-
Devuelve solo el texto generado. Parámetros opcionales:<br>
|
| 210 |
-
• system= (instrucciones del sistema)<br>
|
| 211 |
-
• temperature= (0.0-2.0)<br>
|
| 212 |
-
• top_p= (0.0-1.0)<br>
|
| 213 |
-
• top_k= (0-100)<br>
|
| 214 |
-
• model= (nombre del modelo)<br>
|
| 215 |
-
• max_tokens= (máximo tokens a generar, default: {MAX_GENERATION_TOKENS})<br>
|
| 216 |
-
• repetition_penalty= (penalización de repetición)<br>
|
| 217 |
-
• presence_penalty= (penalización de presencia)<br>
|
| 218 |
-
• frequency_penalty= (penalización de frecuencia)
|
| 219 |
-
</div>
|
| 220 |
-
|
| 221 |
-
<div class="endpoint">
|
| 222 |
-
<strong>POST /v1/chat/completions</strong><br>
|
| 223 |
-
Compatible con OpenAI API
|
| 224 |
-
</div>
|
| 225 |
-
|
| 226 |
-
<div class="endpoint">
|
| 227 |
-
<strong>GET /health</strong><br>
|
| 228 |
-
Estado del servicio
|
| 229 |
-
</div>
|
| 230 |
-
|
| 231 |
-
<div class="endpoint">
|
| 232 |
-
<strong>GET /models</strong><br>
|
| 233 |
-
Lista todos los modelos disponibles
|
| 234 |
-
</div>
|
| 235 |
-
</body>
|
| 236 |
-
</html>
|
| 237 |
-
'''
|
| 238 |
|
| 239 |
@app.route('/v1/chat/completions', methods=['POST'])
|
| 240 |
def chat_completions():
|
|
|
|
| 179 |
status_html += f"<li>{model_name}: {status}</li>"
|
| 180 |
status_html += "</ul>"
|
| 181 |
|
| 182 |
+
return f'''<!doctypehtml><title>TeleChars AI API</title><style>body{margin:40px}</style><h1>TeleChars AI API</h1><div class=config><h3>⚙️ Configuración</h3><p><strong>Max Context Tokens:</strong>{MAX_CONTEXT_TOKENS}<p><strong>Max Generation Tokens:</strong>{MAX_GENERATION_TOKENS}</div><h2>📦 Modelos cargados:</h2>{status_html}<p>Total modelos: {len(loaded_models)}/{len(MODELS)}<h2>🔗 Endpoints disponibles:</h2><div class=endpoint><strong>GET /generate/<mensaje>[?params]</strong><br>Devuelve solo el texto generado. Parámetros opcionales:<br>• system= (instrucciones del sistema)<br>• temperature= (0.0-2.0)<br>• top_p= (0.0-1.0)<br>• top_k= (0-100)<br>• model= (nombre del modelo)<br>• max_tokens= (máximo tokens a generar, default: {MAX_GENERATION_TOKENS})<br>• repetition_penalty= (penalización de repetición)<br>• presence_penalty= (penalización de presencia)<br>• frequency_penalty= (penalización de frecuencia)</div><div class=endpoint><strong>POST /v1/chat/completions</strong><br>Compatible con OpenAI API</div><div class=endpoint><strong>GET /health</strong><br>Estado del servicio</div><div class=endpoint><strong>GET /models</strong><br>Lista todos los modelos disponibles</div>'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
@app.route('/v1/chat/completions', methods=['POST'])
|
| 185 |
def chat_completions():
|