File size: 890 Bytes
f50b43c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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())