Ai_beyin / app.py
Fffffd's picture
Create app.py
f50b43c verified
Raw History Blame Contribute Delete
890 Bytes
# HuggingFace Space'e yüklenecek olan app.py (Sunucu Tarafı)
import asyncio
import websockets
import pickle
from huggingface_hub import hf_hub_download
# 1. Beyni bir kez yükle
print("🧠 Beyin yükleniyor...")
beyin_dosyasi = hf_hub_download(repo_id="Fffffd/Ai_beyin", filename="dexo_brain.pkl")
with open(beyin_dosyasi, 'rb') as f:
dexo_model = pickle.load(f)
print("✅ Beyin sunucuda hazır!")
async def handler(websocket):
async for message in websocket:
# Gelen mesajı işle (Burada kendi yapay zeka mantığını çalıştır)
cevap = f"Dexo İşledi: {message}"
await websocket.send(cevap)
async def main():
# HuggingFace Space üzerinde otomatik 7860 portunu kullanır
async with websockets.serve(handler, "0.0.0.0", 7860):
await asyncio.Future() # Sürekli çalış
if __name__ == "__main__":
asyncio.run(main())