Transformers
English

Run this model with HF Jobs

Run Raiff1982/Gruntcoder on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/Raiff1982/Gruntcoder. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/Raiff1982/Gruntcoder on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Gruntcoder / handler.py
Raiff1982's picture
Update handler.py
3f5be06 verified
Raw History Blame Contribute Delete
872 Bytes
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import asyncio
from ai_core import AICore
app = FastAPI()
# Initialize the AI core
ai_core = AICore()
class QueryRequest(BaseModel):
query: str
class QueryResponse(BaseModel):
insights: list
response: str
security_level: int
safety_checks: dict
health_status: dict
encrypted_query: str
@app.post("/query", response_model=QueryResponse)
async def handle_query(request: QueryRequest):
try:
response = await ai_core.generate_response(request.query)
return QueryResponse(**response)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.on_event("shutdown")
async def shutdown_event():
await ai_core.shutdown()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=7860)