Files
lc_stylist_agent/app/main.py

31 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import logging.config
import os
import litserve as ls
from app.config import settings
from app.server.ChatbotAgent.agent_server import LCAgent
from app.server.ChatbotAgent.chatbot_server import LCChatBot
from app.server.ReFace.server import ReFace
from logging_env import LOGGER_CONFIG_DICT
logger = logging.getLogger(__name__)
# 判断目录是否存在
logs = 'logs'
if not os.path.exists(logs):
# 不存在则创建目录parents=True 允许创建多级目录exist_ok=True 避免目录已存在时报错)
os.makedirs(logs, exist_ok=True)
logger.info(f"目录 {logs} 创建成功")
else:
logger.info(f"目录 {logs} 已存在")
logging.config.dictConfig(LOGGER_CONFIG_DICT)
# STEP 2: START THE SERVER
if __name__ == "__main__":
logger.info(f"运行环境 1表示本地运行0表示生产环境运行 -> :{settings.LOCAL}")
logger.info(f"VECTOR_DB_DIR -> :{settings.VECTOR_DB_DIR}")
chat_boot_api = LCChatBot(enable_async=True, stream=True, api_path='/api/v1/chatbot')
agent_api = LCAgent(enable_async=True, api_path='/api/v1/agent')
reface_api = ReFace(api_path='/api/v1/reface')
server = ls.LitServer([chat_boot_api, agent_api, reface_api])
server.run(port=8000)