#!/usr/bin/env python
# encoding: utf-8
"""
@author: simin. Gong
@license: (C) Copyright 2013-2023 Spacemit Corporation Limited.
@contact: simin.gong@spacemit.com
@file: app.py.py
@date: 2024/11/6 16:58 
@desc:
"""

from flask import Flask
from flask_cors import CORS
from flask_socketio import SocketIO

from ai_tool.io_namespace.AiDomainNamespace import AiDomainNamespace
from ai_tool.io_namespace.OllamaNamespace import OllamaNamespace

app = Flask(__name__)
CORS(app)
socketio = SocketIO(app, async_mode='threading', cors_allowed_origins="*")
app.config['SECRET_KEY'] = 'secret!'
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024


socketio.on_namespace(OllamaNamespace('/llm-chat'))
socketio.on_namespace(AiDomainNamespace('/ai-domain'))

def io_run():
    socketio.run(app, host='0.0.0.0', port=5001,  allow_unsafe_werkzeug=True)

if __name__ == '__main__':
    io_run()
