mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-02-03 05:03:12 +08:00
* provider_configuration init of MODEL_PLATFORMS * 开发手册 * 兼容model_providers,集成webui及API中平台配置的初始化
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
import argparse
|
|
import asyncio
|
|
import logging
|
|
|
|
from model_providers import BootstrapWebBuilder
|
|
from model_providers.core.utils.utils import get_config_dict, get_log_file, get_timestamp_ms
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
"--model-providers",
|
|
type=str,
|
|
default="D:\\project\\Langchain-Chatchat\\model-providers\\model_providers.yaml",
|
|
help="run model_providers servers",
|
|
dest="model_providers",
|
|
)
|
|
args = parser.parse_args()
|
|
try:
|
|
logging_conf = get_config_dict(
|
|
"DEBUG",
|
|
get_log_file(log_path="logs", sub_dir=f"local_{get_timestamp_ms()}"),
|
|
122,
|
|
111,
|
|
)
|
|
boot = (
|
|
BootstrapWebBuilder()
|
|
.model_providers_cfg_path(
|
|
model_providers_cfg_path=args.model_providers
|
|
)
|
|
.host(host="127.0.0.1")
|
|
.port(port=20000)
|
|
.build()
|
|
)
|
|
boot.set_app_event(started_event=None)
|
|
boot.serve(logging_conf=logging_conf)
|
|
|
|
|
|
async def pool_join_thread():
|
|
await boot.join()
|
|
|
|
|
|
asyncio.run(pool_join_thread())
|
|
except SystemExit:
|
|
logger.info("SystemExit raised, exiting")
|
|
raise
|