mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 21:37:20 +08:00
新功能:
- 支持在线 Embeddings:zhipu-api, qwen-api, minimax-api, qianfan-api
- API 增加 /other/embed_texts 接口
- init_database.py 增加 --embed-model 参数,可以指定使用的嵌入模型(本地或在线均可)
- 对于 FAISS 知识库,支持多向量库,默认位置:{KB_PATH}/vector_store/{embed_model}
- Lite 模式支持所有知识库相关功能。此模式下最主要的限制是:
- 不能使用本地 LLM 和 Embeddings 模型
- 知识库不支持 PDF 文件
- init_database.py 重建知识库时不再默认情况数据库表,增加 clear-tables 参数手动控制。
- API 和 WEBUI 中 score_threshold 参数范围改为 [0, 2],以更好的适应在线嵌入模型
问题修复:
- API 中 list_config_models 会删除 ONLINE_LLM_MODEL 中的敏感信息,导致第二轮API请求错误
开发者:
- 统一向量库的识别:以(kb_name,embed_model)为判断向量库唯一性的依据,避免 FAISS 知识库缓存加载逻辑错误
- KBServiceFactory.get_service_by_name 中添加 default_embed_model 参数,用于在构建新知识库时设置 embed_model
- 优化 kb_service 中 Embeddings 操作:
- 统一加载接口: server.utils.load_embeddings,利用全局缓存避免各处 Embeddings 传参
- 统一文本嵌入接口:server.knowledge_base.kb_service.base.[embed_texts, embed_documents]
- 重写 normalize 函数,去除对 scikit-learn/scipy 的依赖
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
import streamlit as st
|
||
from webui_pages.utils import *
|
||
from streamlit_option_menu import option_menu
|
||
from webui_pages.dialogue.dialogue import dialogue_page, chat_box
|
||
from webui_pages.knowledge_base.knowledge_base import knowledge_base_page
|
||
import os
|
||
import sys
|
||
from configs import VERSION
|
||
from server.utils import api_address
|
||
|
||
|
||
api = ApiRequest(base_url=api_address())
|
||
|
||
if __name__ == "__main__":
|
||
is_lite = "lite" in sys.argv
|
||
|
||
st.set_page_config(
|
||
"Langchain-Chatchat WebUI",
|
||
os.path.join("img", "chatchat_icon_blue_square_v2.png"),
|
||
initial_sidebar_state="expanded",
|
||
menu_items={
|
||
'Get Help': 'https://github.com/chatchat-space/Langchain-Chatchat',
|
||
'Report a bug': "https://github.com/chatchat-space/Langchain-Chatchat/issues",
|
||
'About': f"""欢迎使用 Langchain-Chatchat WebUI {VERSION}!"""
|
||
}
|
||
)
|
||
|
||
pages = {
|
||
"对话": {
|
||
"icon": "chat",
|
||
"func": dialogue_page,
|
||
},
|
||
"知识库管理": {
|
||
"icon": "hdd-stack",
|
||
"func": knowledge_base_page,
|
||
},
|
||
}
|
||
|
||
with st.sidebar:
|
||
st.image(
|
||
os.path.join(
|
||
"img",
|
||
"logo-long-chatchat-trans-v2.png"
|
||
),
|
||
use_column_width=True
|
||
)
|
||
st.caption(
|
||
f"""<p align="right">当前版本:{VERSION}</p>""",
|
||
unsafe_allow_html=True,
|
||
)
|
||
options = list(pages)
|
||
icons = [x["icon"] for x in pages.values()]
|
||
|
||
default_index = 0
|
||
selected_page = option_menu(
|
||
"",
|
||
options=options,
|
||
icons=icons,
|
||
# menu_icon="chat-quote",
|
||
default_index=default_index,
|
||
)
|
||
|
||
if selected_page in pages:
|
||
pages[selected_page]["func"](api=api, is_lite=is_lite)
|