Files
gpu-services/nanoclaude/main.py
Hyungi Ahn d946b769e5 feat: NanoClaude Phase 1 — 비동기 job 기반 AI Gateway 코어 구현
POST /chat → job_id ACK, GET /chat/{job_id}/stream → SSE 스트리밍,
EXAONE Ollama adapter, JobManager, StateStream, Worker 구조

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 11:12:04 +09:00

54 lines
1.3 KiB
Python

"""NanoClaude — 비동기 job 기반 AI Gateway."""
from __future__ import annotations
import logging
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from config import settings
from routers import chat
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s%(message)s",
)
app = FastAPI(
title="NanoClaude",
version="0.1.0",
description="비동기 job 기반 AI Gateway — Phase 1",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
@app.middleware("http")
async def check_api_key(request: Request, call_next):
"""Optional API key check. 설정이 비어있으면 통과."""
if settings.api_key:
auth = request.headers.get("Authorization", "")
if request.url.path not in ("/", "/health") and auth != f"Bearer {settings.api_key}":
return JSONResponse(status_code=401, content={"detail": "Invalid API key"})
return await call_next(request)
app.include_router(chat.router)
@app.get("/")
async def root():
return {"service": "NanoClaude", "version": "0.1.0", "phase": 1}
@app.get("/health")
async def health():
return {"status": "ok"}