Spaces:
Running
on
Zero
Running
on
Zero
File size: 2,124 Bytes
1ec348e |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import os
import sys
import subprocess
import logging
from fastapi import FastAPI, Request, HTTPException
import requests
import json
from datetime import datetime
import importlib
import pkgutil
from mysite.libs.utilities import validate_signature, no_process_file
#from mysite.database.database import ride,create_ride
from controllers.gra_04_database.rides import test_set_lide
from mysite.interpreter.prompt import prompt_genalate,test_prompt
from mysite.interpreter.google_chat import send_google_chat_card,send_google_chat_card_thread
#from mysite.interpreter.interpreter import chat_with_interpreter
from controllers.gra_02_openInterpreter.OpenInterpreter import chat_with_interpreter_no_stream
from mysite.appsheet.appsheet import get_senario
logger = logging.getLogger(__name__)
"""
router
"""
def include_routers(app):
package_dir = "/home/user/app/routers"
if not os.path.exists(package_dir):
logger.error(f"Package directory {package_dir} does not exist.")
return
for module_info in pkgutil.iter_modules([package_dir]):
try:
if module_info.ispkg:
sub_package_dir = os.path.join(package_dir, module_info.name)
for sub_module_info in pkgutil.iter_modules([sub_package_dir]):
module_name = (
f"routers.{module_info.name}.{sub_module_info.name}"
if sub_module_info.ispkg
else f"routers.{module_info.name}.{sub_module_info.name}"
)
module = importlib.import_module(module_name)
if hasattr(module, "router"):
app.include_router(module.router)
else:
module_name = f"routers.{module_info.name}"
module = importlib.import_module(module_name)
if hasattr(module, "router"):
app.include_router(module.router)
except ModuleNotFoundError as e:
logger.error(f"Module not found: {e}")
except Exception as e:
logger.error(f"An error occurred: {e}")
|