Update app.py
Browse files11 unmodified lines1213141516171 unmodified line192021222324252627282930116 unmodified lines14714814915015115211 unmodified linesfrom fastapi import FastAPI, HTTPExceptionfrom fastapi.responses import StreamingResponsefrom fastapi.middleware.cors import CORSMiddlewarefrom pydantic import BaseModelfrom transformers import AutoTokenizer, AutoModelForCausalLM, TextIteratorStreamerfrom threading import Thread1 unmodified line# Model configurationMODEL_NAME = "Nanbeige/Nanbeige4.1-3B"MAX_LENGTH = 8192# Global model and tokenizermodel = Nonetokenizer = Noneclass Message(BaseModel):role: str116 unmodified lines}@app.get("/health")async def health():"""Health check endpoint."""11 unmodified lines121314151617181 unmodified line20212223242526272829303132116 unmodified lines14915015115215315415515615715815916011 unmodified linesfrom fastapi import FastAPI, HTTPExceptionfrom fastapi.responses import StreamingResponsefrom fastapi.middleware.cors import CORSMiddlewarefrom fastapi.responses import FileResponsefrom pydantic import BaseModelfrom transformers import AutoTokenizer, AutoModelForCausalLM, TextIteratorStreamerfrom threading import Thread1 unmodified line# Model configurationMODEL_NAME = "Nanbeige/Nanbeige4.1-3B"MAX_LENGTH = 32768# Global model and tokenizermodel = Nonetokenizer = NoneBASE_DIR = os.path.dirname(os.path.abspath(__file__))class Message(BaseModel):role: str116 unmodified lines}@app.get("/index", response_class=FileResponse)async def serve_chat():"""Serve chat.html as index."""return FileResponse(os.path.join(BASE_DIR, "index.html"))@app.get("/health")async def health():"""Health check endpoint."""
app.py+9-1