ryan33121 commited on
Commit
ce4e5c9
·
verified ·
1 Parent(s): 35ca4ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -1,5 +1,7 @@
1
  from fastapi import FastAPI
2
  from fastapi.middleware.cors import CORSMiddleware
 
 
3
 
4
  app = FastAPI()
5
 
@@ -10,6 +12,19 @@ app.add_middleware(
10
  allow_headers=["*"],
11
  )
12
 
 
 
 
 
 
 
 
 
 
13
  @app.get("/")
14
  def read_root():
15
- return {"message": "The server is working!"}
 
 
 
 
 
1
  from fastapi import FastAPI
2
  from fastapi.middleware.cors import CORSMiddleware
3
+ from llama_cpp import Llama
4
+ from huggingface_hub import hf_hub_download
5
 
6
  app = FastAPI()
7
 
 
12
  allow_headers=["*"],
13
  )
14
 
15
+ # 1. Load the model (carefully)
16
+ print("Loading model... this might take a minute.")
17
+ MODEL_PATH = hf_hub_download(
18
+ repo_id="Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF",
19
+ filename="qwen2.5-coder-1.5b-instruct-q4_k_m.gguf"
20
+ )
21
+ llm = Llama(model_path=MODEL_PATH, n_ctx=512)
22
+ print("Model finished loading.")
23
+
24
  @app.get("/")
25
  def read_root():
26
+ return {"message": "The server is working and the model is loaded!"}
27
+
28
+ @app.get("/check-model")
29
+ def check_model():
30
+ return {"status": "Model is active in memory."}