Spaces:
Sleeping
Sleeping
Download main.py from Fayzbek/ai-coding-agent-v1: direct link, hf CLI and curl.
- Browser
- Download file 713 Bytes
-
https://huggingface.co/spaces/Fayzbek/ai-coding-agent-v1/resolve/main/main.py
- Command line
-
hf download hf://spaces/Fayzbek/ai-coding-agent-v1/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Fayzbek/ai-coding-agent-v1/resolve/main/main.py
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" | |
| def read_root(): | |
| return {"message": "AI Coding Agent v1 ishlamoqda!"} | |
| 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() | |
| async def health_check(): | |
| return {"status": "ok"} | |