File size: 713 Bytes
779a4c4
5b84392
 
8cb81e8
 
 
5b84392
 
 
8cb81e8
 
5b84392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8cb81e8
 
5b84392
8cb81e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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"}