Fayzbek's picture
Update main.py
5b84392 verified
Raw History Blame Contribute Delete
713 Bytes
from fastapi import FastAPI
import httpx
import asyncio
app = FastAPI()
# Ollama bilan bog'lanish uchun bazaviy URL
OLLAMA_URL = "http://127.0.0.1:11434"
@app.get("/")
def read_root():
return {"message": "AI Coding Agent v1 ishlamoqda!"}
@app.post("/generate")
async def generate_code(prompt: str):
async with httpx.AsyncClient() as client:
response = await client.post(
f"{OLLAMA_URL}/api/generate",
json={
"model": "qwen2.5:3b",
"prompt": prompt,
"stream": False
},
timeout=60.0
)
return response.json()
@app.get("/health")
async def health_check():
return {"status": "ok"}