Langchain-Chatchat 在 AutoDL 环境如何用 tools 下脚本完成模型注册与一键启动

发布时间:2026/9/10 18:52:33
Langchain-Chatchat 在 AutoDL 环境如何用 tools 下脚本完成模型注册与一键启动 Langchain-Chatchat 在 AutoDL 环境如何用 tools 下脚本完成模型注册与一键启动【免费下载链接】Langchain-ChatchatLangchain-Chatchat原Langchain-ChatGLM基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain项目地址: https://gitcode.com/GitHub_Trending/la/Langchain-Chatchat目标是在 AutoDL 实例上把 Langchain-Chatchat 跑起来用 Xinference 托管本地 GLM-4-9B-ChatLLM和 bge-large-zh-v1.5embedding再让 chatchat 连上这两个模型提供 RAG 对话。仓库的 tools/autodl_start_script 目录提供了一组针对 AutoDL 的 bash 脚本把下载模型 → 启动 Xinference → 启动模型 → 启动 chatchat串成一条命令docs/install/README_xinference.md 则给出了同一套流程的逐条手动命令两者可以互相对照。准备条件conda 环境与模型文件脚本本身只负责启动环境要提前按 Xinference 环境配置手册 建好。脚本里用到的 conda 环境名分别是base、chatchat、xinference文档中 chatchat 与 xinference 环境均要求 Python 3.8# chatchat 环境 conda create -p ~/miniconda3/envs/chatchat python3.8 conda activate ~/miniconda3/envs/chatchat pip install langchain-chatchat -U pip install xinference_client faiss-gpu unstructured[pdf] # xinference 环境 conda create -p ~/miniconda3/envs/xinference python3.8 conda activate ~/miniconda3/envs/xinference pip install xinference --force pip install tiktoken sentence-transformers模型文件方面脚本内写死了两处路径LLM/root/autodl-tmp/glm-4-9b-chat由 download_model.sh 下载无需手动准备embedding/root/model/bge-large-zh下载脚本不会处理它需要你自行把模型放到该目录或按文档说明修改注册脚本里的model_uri——文档在注册脚本一节明确标注模型路径需要根据实际情况修改。把脚本放到 /root 并核对注册脚本startup.sh 中调用的是bash /root/download_model.sh、bash /root/start_xinference.sh、bash /root/start_chatchat.shstart_xinference.sh 内部还会调用bash /root/start_models.sh和bash /root/start_models_emb.sh。也就是说这一组脚本必须放在 AutoDL 实例的/root目录下才能按原样运行把 tools/autodl_start_script 里的全部.sh拷过去即可。先检查 model_registrations.sh 和 model_registrations_emb.sh 中的model_uri是否与你的模型实际位置一致。LLM 注册内容的关键字段{ model_name: autodl-tmp-glm-4-9b-chat, context_length: 2048, model_family: glm4-chat, model_specs: [ { model_uri: /root/autodl-tmp/glm-4-9b-chat, model_size_in_billions: 9, model_format: pytorch, quantizations: [none] } ], prompt_style: { style_name: CHATGLM3 } }embedding 注册的关键字段model_name为autodl-tmp-bge-large-zhdimensions768、max_tokens512、model_uri为/root/model/bge-large-zh。一次性模型注册注册接口是 Xinference 的http://127.0.0.1:9997/v1/model_registrations/LLM和/v1/model_registrations/embedding请求体里带persist:true即注册会持久保存。注册不在一键启动流程里startup.sh不会调用这两个脚本按文档给出的顺序在 Xinference 服务可用后手动执行一次即可bash /root/model_registrations.sh bash /root/model_registrations_emb.sh注册只做一次之后每次重启实例直接走一键启动如果换了模型名或路径再重新注册。一键启动bash startup.sh在/root下执行bash /root/startup.sh执行前需要了解这个脚本的副作用删除xinference-output.log、chatchat-output.log两个日志文件及对应 pid 文件杀掉本机上 xinference 和 chatchat 的残留进程——先按 pid 文件kill再用ps -ef | grep -w兜底kill -9在base环境中执行pip install codewithgpu并下载模型有网络下载动作拉起两个常驻服务进程。它随后按固定顺序执行三步第一步下载模型。download_model.sh 的内容是cd /root/autodl-tmp conda run -n base pip install codewithgpu conda run -n base cg down xxxiu/glm-4-9b-chat即通过 codewithgpu 的cg down把 glm-4-9b-chat 下载到/root/autodl-tmp。第二步启动 Xinference 并拉起模型。start_xinference.sh 在xinference环境后台运行xinference-local日志写入xinference-output.log然后阻塞等待日志出现Uvicorn running on http://127.0.0.1:9997确认服务就绪后才执行start_models.sh和start_models_emb.shstart_models.shPOST /v1/models启动 LLMmodel_name为autodl-tmp-glm-4-9b-chatmodel_engine为 Transformersmodel_format为 pytorchquantization为 nonen_gpu为 autoreplica为 1start_models_emb.shPOST /v1/models启动 embeddingmodel_uid为bge-large-zh-v1.5注册名autodl-tmp-bge-large-zhreplica为 1。第三步启动 chatchat。start_chatchat.sh 在chatchat环境执行export CHATCHAT_ROOT/root/chatchat-data chatchat start -a日志写入chatchat-output.log阻塞等待日志出现URL: http://0.0.0.0:6006后把进程号写入chatchat.pid并输出chatchat started。验证启动结果脚本自带了验证逻辑正常跑完后依次会有xinference-output.log中出现Uvicorn running on http://127.0.0.1:9997脚本输出xinference-local started successfully和model started successfullyxinference.pid与chatchat.pid两个文件生成chatchat-output.log中出现URL: http://0.0.0.0:6006脚本输出chatchat started。如果脚本卡在某个等待循环里不往下走说明对应服务没有输出预期标记先看对应的xinference-output.log或chatchat-output.log排查。手动执行路径可选如果不想整包运行startup.sh可以完全按 README_xinference.md 的步骤手动走一遍顺序为# 1. 启动 Xinference xinference-local # 2. 注册与启动模型各脚本内容见上文的两个注册、两个启动脚本 bash ./model_registrations.sh bash ./model_registrations_emb.sh bash ./start_models.sh bash ./start_models_emb.sh # 3. 初始化 chatchat 配置chatchat 环境内 chatchat-config basic --verbose true chatchat-config basic --data ~/chatchat-data chatchat-config model --set_model_platforms [{ \platform_name\: \xinference\, \platform_type\: \xinference\, \api_base_url\: \http://127.0.0.1:9997/v1\, \api_key\: \EMPT\, \api_concurrencies\: 5, \llm_models\: [ \autodl-tmp-glm-4-9b-chat\ ], \embed_models\: [ \bge-large-zh-v1.5\ ], \image_models\: [], \reranking_models\: [], \speech2text_models\: [], \tts_models\: [] }] chatchat-kb -r chatchat -a其中--set_model_platforms把 chatchat 指到本机 Xinferencehttp://127.0.0.1:9997/v1LLM 用注册名autodl-tmp-glm-4-9b-chatembedding 用bge-large-zh-v1.5。手动路径中 chatchat 配置的数据目录是~/chatchat-data与一键脚本里CHATCHAT_ROOT/root/chatchat-data指向同一位置AutoDL 实例的 home 即/root。限制与差异脚本内的调用路径全部硬编码为/root/*.sh日志、pid 文件也落在/root工作目录换机器或换目录需要先改脚本。注册和启动脚本固定了模型组合GLM-4-9B-Chatpytorch、非量化 bge-large-zh-v1.5。要换其他模型需按文档提示修改model_uri等字段后重新注册、重新下发/v1/models请求并同步改--set_model_platforms中的模型列表。两处命令写法不完全一致仓库脚本 start_chatchat.sh 用的是chatchat start -a而 README_xinference.md 手动步骤写的是chatchat -a。一键流程以脚本实际内容为准。startup.sh会kill -9名称匹配 xinference / chatchat 的进程并删除旧日志只应在专用 AutoDL 实例上运行不要在有同名片名进程的其他机器上直接执行。【免费下载链接】Langchain-ChatchatLangchain-Chatchat原Langchain-ChatGLM基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain项目地址: https://gitcode.com/GitHub_Trending/la/Langchain-Chatchat创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考