Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ from llama_cpp import Llama
|
|
| 9 |
|
| 10 |
app = FastAPI(title="Qwen 2.5 Coder Public Secure Server")
|
| 11 |
|
| 12 |
-
# Enable CORS for local IDE connections
|
| 13 |
app.add_middleware(
|
| 14 |
CORSMiddleware,
|
| 15 |
allow_origins=["*"],
|
|
@@ -18,8 +17,7 @@ app.add_middleware(
|
|
| 18 |
allow_headers=["*"],
|
| 19 |
)
|
| 20 |
|
| 21 |
-
# 🔐
|
| 22 |
-
# You will type this exact key into Cline / Continue / Claude Code
|
| 23 |
CUSTOM_API_KEY = "varsshancoder"
|
| 24 |
|
| 25 |
security = HTTPBearer()
|
|
@@ -38,7 +36,7 @@ MODEL_FILE = "qwen2.5-coder-7b-instruct-q4_k_m.gguf"
|
|
| 38 |
print("Checking and downloading Qwen 2.5 Coder 7B GGUF model...")
|
| 39 |
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
|
| 40 |
|
| 41 |
-
print(f"Loading model into
|
| 42 |
llm = Llama(
|
| 43 |
model_path=model_path,
|
| 44 |
n_ctx=4096,
|
|
@@ -48,7 +46,6 @@ llm = Llama(
|
|
| 48 |
)
|
| 49 |
print("Model loaded successfully and secured!")
|
| 50 |
|
| 51 |
-
# Add the verify_api_key dependency to secure your completions endpoint completely
|
| 52 |
@app.post("/v1/chat/completions", dependencies=[Depends(verify_api_key)])
|
| 53 |
async def chat_completions(request: Request):
|
| 54 |
body = await request.json()
|
|
@@ -100,4 +97,3 @@ def index():
|
|
| 100 |
"model": "qwen2.5-coder-7b-instruct-q4_k_m",
|
| 101 |
"endpoint": "/v1/chat/completions"
|
| 102 |
}
|
| 103 |
-
|
|
|
|
| 9 |
|
| 10 |
app = FastAPI(title="Qwen 2.5 Coder Public Secure Server")
|
| 11 |
|
|
|
|
| 12 |
app.add_middleware(
|
| 13 |
CORSMiddleware,
|
| 14 |
allow_origins=["*"],
|
|
|
|
| 17 |
allow_headers=["*"],
|
| 18 |
)
|
| 19 |
|
| 20 |
+
# 🔐 YOUR PREFERRED CUSTOM API KEY
|
|
|
|
| 21 |
CUSTOM_API_KEY = "varsshancoder"
|
| 22 |
|
| 23 |
security = HTTPBearer()
|
|
|
|
| 36 |
print("Checking and downloading Qwen 2.5 Coder 7B GGUF model...")
|
| 37 |
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
|
| 38 |
|
| 39 |
+
print(f"Loading model into memory from: {model_path}")
|
| 40 |
llm = Llama(
|
| 41 |
model_path=model_path,
|
| 42 |
n_ctx=4096,
|
|
|
|
| 46 |
)
|
| 47 |
print("Model loaded successfully and secured!")
|
| 48 |
|
|
|
|
| 49 |
@app.post("/v1/chat/completions", dependencies=[Depends(verify_api_key)])
|
| 50 |
async def chat_completions(request: Request):
|
| 51 |
body = await request.json()
|
|
|
|
| 97 |
"model": "qwen2.5-coder-7b-instruct-q4_k_m",
|
| 98 |
"endpoint": "/v1/chat/completions"
|
| 99 |
}
|
|
|