Spaces:
Sleeping
Sleeping
File size: 1,026 Bytes
20977fd |
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 32 33 34 |
from fastapi import FastAPI, Request
import requests
import os
app = FastAPI()
# Секрет берется из настроек Hugging Face (Settings -> Secrets)
GEMINI_KEY = os.getenv("GEMINI_KEY")
PASS_KEY = "KOSTYA_ROBOTICS_2026"
@app.get("/")
def home():
return {"status": "Divine Soup Bridge is Online", "owner": "Kostya"}
@app.post("/ask")
async def ask_gemini(data: dict):
# Защита доступа
if data.get("password") != PASS_KEY:
return {"error": "Access Denied. Wrong Password."}
prompt = data.get("prompt")
# URL для Gemini 1.5 Pro или Gemini 3 Pro (зависит от твоего API ключа)
url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent?key={GEMINI_KEY}"
payload = {
"contents": [{"parts": [{"text": prompt}]}]
}
try:
response = requests.post(url, json=payload, timeout=10)
return response.json()
except Exception as e:
return {"error": str(e)} |