Spaces:
Sleeping
Sleeping
GitHub Copilot commited on
Commit ·
63bc04d
1
Parent(s): ef36da0
Restore original PNG logo in Space via base64 static asset
Browse files- app.py +12 -3
- static/index.html +2 -2
- static/logo_png_base64.txt +0 -0
app.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
|
|
|
| 3 |
import urllib.parse
|
| 4 |
from datetime import datetime
|
| 5 |
from typing import Any
|
| 6 |
from fastapi import FastAPI
|
| 7 |
from fastapi.middleware.cors import CORSMiddleware
|
| 8 |
from fastapi.staticfiles import StaticFiles
|
| 9 |
-
from fastapi.responses import FileResponse
|
| 10 |
from pydantic import BaseModel, Field
|
| 11 |
import uvicorn
|
| 12 |
|
|
@@ -36,9 +37,11 @@ REPO_ID = "Krishkanth/krish-mind-mobile"
|
|
| 36 |
MODEL_FILENAME = "krish-mind-mobile.gguf"
|
| 37 |
BASE_DIR = os.path.dirname(__file__)
|
| 38 |
STATIC_DIR = os.path.join(BASE_DIR, "static")
|
|
|
|
| 39 |
default_clean_data = os.path.join(BASE_DIR, "data", "krce_college_data_clean.jsonl")
|
| 40 |
default_legacy_data = os.path.join(BASE_DIR, "data", "krce_college_data.jsonl")
|
| 41 |
DATA_FILE = default_clean_data if os.path.exists(default_clean_data) else default_legacy_data
|
|
|
|
| 42 |
|
| 43 |
# --- Load GGUF Model ---
|
| 44 |
print(f"\n⏳ Downloading/Loading model from {REPO_ID}...")
|
|
@@ -95,8 +98,14 @@ async def root():
|
|
| 95 |
|
| 96 |
@app.get("/logo.png")
|
| 97 |
async def logo():
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
@app.get("/logo.svg")
|
| 102 |
async def logo_svg():
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
+
import base64
|
| 4 |
import urllib.parse
|
| 5 |
from datetime import datetime
|
| 6 |
from typing import Any
|
| 7 |
from fastapi import FastAPI
|
| 8 |
from fastapi.middleware.cors import CORSMiddleware
|
| 9 |
from fastapi.staticfiles import StaticFiles
|
| 10 |
+
from fastapi.responses import FileResponse, Response
|
| 11 |
from pydantic import BaseModel, Field
|
| 12 |
import uvicorn
|
| 13 |
|
|
|
|
| 37 |
MODEL_FILENAME = "krish-mind-mobile.gguf"
|
| 38 |
BASE_DIR = os.path.dirname(__file__)
|
| 39 |
STATIC_DIR = os.path.join(BASE_DIR, "static")
|
| 40 |
+
LOGO_B64_FILE = os.path.join(STATIC_DIR, "logo_png_base64.txt")
|
| 41 |
default_clean_data = os.path.join(BASE_DIR, "data", "krce_college_data_clean.jsonl")
|
| 42 |
default_legacy_data = os.path.join(BASE_DIR, "data", "krce_college_data.jsonl")
|
| 43 |
DATA_FILE = default_clean_data if os.path.exists(default_clean_data) else default_legacy_data
|
| 44 |
+
_logo_png_cache: bytes | None = None
|
| 45 |
|
| 46 |
# --- Load GGUF Model ---
|
| 47 |
print(f"\n⏳ Downloading/Loading model from {REPO_ID}...")
|
|
|
|
| 98 |
|
| 99 |
@app.get("/logo.png")
|
| 100 |
async def logo():
|
| 101 |
+
global _logo_png_cache
|
| 102 |
+
if _logo_png_cache is None:
|
| 103 |
+
if os.path.exists(LOGO_B64_FILE):
|
| 104 |
+
with open(LOGO_B64_FILE, "r", encoding="ascii") as handle:
|
| 105 |
+
_logo_png_cache = base64.b64decode(handle.read().strip())
|
| 106 |
+
else:
|
| 107 |
+
return FileResponse(os.path.join(STATIC_DIR, "logo.svg"), media_type="image/svg+xml")
|
| 108 |
+
return Response(content=_logo_png_cache, media_type="image/png")
|
| 109 |
|
| 110 |
@app.get("/logo.svg")
|
| 111 |
async def logo_svg():
|
static/index.html
CHANGED
|
@@ -1286,7 +1286,7 @@
|
|
| 1286 |
<line x1="3" y1="18" x2="21" y2="18"></line>
|
| 1287 |
</svg>
|
| 1288 |
</button>
|
| 1289 |
-
<img src="/
|
| 1290 |
</div>
|
| 1291 |
<div class="header-actions">
|
| 1292 |
<button class="icon-btn" onclick="toggleTheme()" title="Toggle theme">
|
|
@@ -1307,7 +1307,7 @@
|
|
| 1307 |
<div class="chat-container" id="chatContainer">
|
| 1308 |
<!-- Welcome Screen -->
|
| 1309 |
<div class="welcome-screen" id="welcomeScreen">
|
| 1310 |
-
<img src="/
|
| 1311 |
<h1 class="welcome-title">Hello! I'm Krish Mind</h1>
|
| 1312 |
<p class="welcome-subtitle">Your AI assistant, developed by Krish CS</p>
|
| 1313 |
<div class="suggestions-grid">
|
|
|
|
| 1286 |
<line x1="3" y1="18" x2="21" y2="18"></line>
|
| 1287 |
</svg>
|
| 1288 |
</button>
|
| 1289 |
+
<img src="/logo.png" alt="Krish Mind" class="logo-img">
|
| 1290 |
</div>
|
| 1291 |
<div class="header-actions">
|
| 1292 |
<button class="icon-btn" onclick="toggleTheme()" title="Toggle theme">
|
|
|
|
| 1307 |
<div class="chat-container" id="chatContainer">
|
| 1308 |
<!-- Welcome Screen -->
|
| 1309 |
<div class="welcome-screen" id="welcomeScreen">
|
| 1310 |
+
<img src="/logo.png" alt="Krish Mind" class="welcome-logo">
|
| 1311 |
<h1 class="welcome-title">Hello! I'm Krish Mind</h1>
|
| 1312 |
<p class="welcome-subtitle">Your AI assistant, developed by Krish CS</p>
|
| 1313 |
<div class="suggestions-grid">
|
static/logo_png_base64.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|