File size: 578 Bytes
ae7e219 87d6326 68d3b08 87d6326 ae7e219 87d6326 ae7e219 68d3b08 ae7e219 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from fastapi import FastAPI, Request
import requests
import os
app = FastAPI()
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
HF_TOKEN = os.getenv("HF_API_KEY")
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
@app.get("/")
async def root():
return {"message": "✅ QuickPrep is running!"}
@app.post("/generate")
async def generate(request: Request):
data = await request.json()
prompt = data.get("prompt")
response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
return response.json()
|