Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release 0.2.6 #1815

Merged
merged 37 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
61c4000
更新上agent提示词代码 (#1626)
zRzRzRzRzRzRzR Sep 29, 2023
77d38db
修改部分错误的文档,加长了历史记录(for 32k Models) (#1629)
zRzRzRzRzRzRzR Sep 29, 2023
332f8be
fix: windows下bind_host设为0.0.0.0时,将fschat_xx_address指向127.0.0.1,避免请求错误…
liunux4odoo Oct 3, 2023
fc6a3b0
Dev (#1652)
zRzRzRzRzRzRzR Oct 4, 2023
4833820
修复代理为空的问题
glide-the Oct 4, 2023
37500b8
指定transformers==4.33.3版本
glide-the Oct 4, 2023
038f2eb
修复代理为空的问题
glide-the Oct 4, 2023
0304279
fix #1656: rename kb_config.py.exmaple to kb_config.py.example
liunux4odoo Oct 5, 2023
387b4cb
fix #1638: baichuan-api未正确配置
liunux4odoo Oct 5, 2023
2c8fc95
Agent大更新合并 (#1666)
zRzRzRzRzRzRzR Oct 7, 2023
7475205
Agent提示词更改,增加图片 (#1667)
zRzRzRzRzRzRzR Oct 7, 2023
111bc45
Wiki完善和Agent完善计划 (#1680)
zRzRzRzRzRzRzR Oct 7, 2023
01577d6
只启动在server_config中配置的在线API模型
liunux4odoo Oct 12, 2023
1ac1739
fix #1737: MakeFastAPIOffline函数内代码编写错误
liunux4odoo Oct 12, 2023
cd74812
add paramter `max_tokens` to 4 chat api with default value 1024 (#1744)
liunux4odoo Oct 12, 2023
94977c7
修复:切换embed_model时,FAISS向量库未正确释放,导致`d == self.d assert (#1766)
liunux4odoo Oct 16, 2023
9ce328f
实现Api和WEBUI的前后端分离 (#1772)
liunux4odoo Oct 17, 2023
69e5da4
北京黑客松更新 (#1785)
zRzRzRzRzRzRzR Oct 18, 2023
b9b4299
- 支持metaphor搜索引擎(无需代理,key申请简单,目前不支持中文)
liunux4odoo Oct 18, 2023
7e28291
Merge pull request #1792 from liunux4odoo/fix
liunux4odoo Oct 18, 2023
d053950
新功能: (#1801)
liunux4odoo Oct 19, 2023
1b3bd44
update model_config.py.example (#1784)
liunux4odoo Oct 19, 2023
0b25d7b
fix: correct model_worker's logger and semaphor
liunux4odoo Oct 20, 2023
83e25f8
remove xformers from requirements*.txt; check llm_model before change…
liunux4odoo Oct 20, 2023
e920cd0
合并分支,支持 (#1808)
zRzRzRzRzRzRzR Oct 20, 2023
1d9d9df
update baichuan-api: 修正messages参数;支持流式;添加测试用例
liunux4odoo Oct 20, 2023
195929b
支持加载p-tuning,详细步骤见docs/chatchat加载ptuing.md
hzg0601 Oct 20, 2023
6e9acfc
Merge branch 'dev' of https://github.com/chatchat-space/Langchain-Cha…
hzg0601 Oct 20, 2023
a81bd82
根据系统指定binding_host
hzg0601 Oct 20, 2023
109bb7f
Merge pull request #1810 from hzg0601/dev
hzg0601 Oct 20, 2023
46225ad
Dev (#1811)
zRzRzRzRzRzRzR Oct 20, 2023
86ee6fe
更新readme (#1813)
zRzRzRzRzRzRzR Oct 20, 2023
dd7223b
merge master to dev
liunux4odoo Oct 20, 2023
ce54414
update readme: remove partners
liunux4odoo Oct 20, 2023
df0ee99
update readme: remove milestone
liunux4odoo Oct 20, 2023
c41d7ad
Dev (#1814)
zRzRzRzRzRzRzR Oct 20, 2023
0e7f0e1
update readme: remove milestone
liunux4odoo Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions CONTRIBUTING.md

This file was deleted.

481 changes: 64 additions & 417 deletions README.md

Large diffs are not rendered by default.

438 changes: 98 additions & 340 deletions README_en.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from .prompt_config import *


VERSION = "v0.2.5"
VERSION = "v0.2.6"
29 changes: 24 additions & 5 deletions configs/kb_config.py.exmaple → configs/kb_config.py.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

# 默认使用的知识库
DEFAULT_KNOWLEDGE_BASE = "samples"

# 默认向量库类型。可选:faiss, milvus, pg.
# 默认向量库类型。可选:faiss, milvus(离线) & zilliz(在线), pg.
DEFAULT_VS_TYPE = "faiss"

# 缓存向量库数量(针对FAISS)
Expand All @@ -19,6 +21,9 @@ VECTOR_SEARCH_TOP_K = 3
# 知识库匹配相关度阈值,取值范围在0-1之间,SCORE越小,相关度越高,取到1相当于不筛选,建议设置在0.5左右
SCORE_THRESHOLD = 1

# 默认搜索引擎。可选:bing, duckduckgo, metaphor
DEFAULT_SEARCH_ENGINE = "duckduckgo"

# 搜索引擎匹配结题数量
SEARCH_ENGINE_TOP_K = 3

Expand All @@ -36,19 +41,26 @@ BING_SEARCH_URL = "https://api.bing.microsoft.com/v7.0/search"
# 是因为服务器加了防火墙,需要联系管理员加白名单,如果公司的服务器的话,就别想了GG
BING_SUBSCRIPTION_KEY = ""

# metaphor搜索需要KEY
METAPHOR_API_KEY = ""


# 是否开启中文标题加强,以及标题增强的相关配置
# 通过增加标题判断,判断哪些文本为标题,并在metadata中进行标记;
# 然后将文本与往上一级的标题进行拼合,实现文本信息的增强。
ZH_TITLE_ENHANCE = False


# 每个知识库的初始化介绍,用于在初始化知识库时显示和Agent调用,没写则没有介绍,不会被Agent调用。
KB_INFO = {
"知识库名称": "知识库介绍",
"samples": "关于本项目issue的解答",
}
# 通常情况下不需要更改以下内容

# 知识库默认存储路径
KB_ROOT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "knowledge_base")
if not os.path.exists(KB_ROOT_PATH):
os.mkdir(KB_ROOT_PATH)

# 数据库默认存储路径。
# 如果使用sqlite,可以直接修改DB_ROOT_PATH;如果使用其它数据库,请直接修改SQLALCHEMY_DATABASE_URI。
DB_ROOT_PATH = os.path.join(KB_ROOT_PATH, "info.db")
Expand All @@ -65,6 +77,13 @@ kbs_config = {
"password": "",
"secure": False,
},
"zilliz": {
"host": "in01-a7ce524e41e3935.ali-cn-hangzhou.vectordb.zilliz.com.cn",
"port": "19530",
"user": "",
"password": "",
"secure": True,
},
"pg": {
"connection_uri": "postgresql://postgres:postgres@127.0.0.1:5432/langchain_chatchat",
}
Expand All @@ -74,11 +93,11 @@ kbs_config = {
text_splitter_dict = {
"ChineseRecursiveTextSplitter": {
"source": "huggingface", ## 选择tiktoken则使用openai的方法
"tokenizer_name_or_path": "gpt2",
"tokenizer_name_or_path": "",
},
"SpacyTextSplitter": {
"source": "huggingface",
"tokenizer_name_or_path": "",
"tokenizer_name_or_path": "gpt2",
},
"RecursiveCharacterTextSplitter": {
"source": "tiktoken",
Expand Down
30 changes: 24 additions & 6 deletions configs/model_config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ MODEL_PATH = {
"chatglm2-6b-int4": "THUDM/chatglm2-6b-int4",
"chatglm2-6b-32k": "THUDM/chatglm2-6b-32k",

"baichuan2-13b": "baichuan-inc/Baichuan-13B-Chat",
"baichuan2-13b": "baichuan-inc/Baichuan2-13B-Chat",
"baichuan2-7b":"baichuan-inc/Baichuan2-7B-Chat",

"baichuan-7b": "baichuan-inc/Baichuan-7B",
Expand Down Expand Up @@ -90,9 +90,8 @@ MODEL_PATH = {
"Qwen-14B-Chat":"Qwen/Qwen-14B-Chat",
},
}

# 选用的 Embedding 名称
EMBEDDING_MODEL = "m3e-base" # 可以尝试最新的嵌入式sota模型:piccolo-large-zh
EMBEDDING_MODEL = "m3e-base" # 可以尝试最新的嵌入式sota模型:bge-large-zh-v1.5


# Embedding 模型运行设备。设为"auto"会自动检测,也可手动设定为"cuda","mps","cpu"其中之一。
Expand All @@ -112,7 +111,8 @@ TEMPERATURE = 0.7
# TOP_P = 0.95 # ChatOpenAI暂不支持该参数


ONLINE_LLM_MODEL = {
LANGCHAIN_LLM_MODEL = {
# 不需要走Fschat封装的,Langchain直接支持的模型。
# 调用chatgpt时如果报出: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openai.com', port=443):
# Max retries exceeded with url: /v1/chat/completions
# 则需要将urllib3版本修改为1.25.11
Expand All @@ -128,11 +128,29 @@ ONLINE_LLM_MODEL = {
# 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI.
# 需要添加代理访问(正常开的代理软件可能会拦截不上)需要设置配置openai_proxy 或者 使用环境遍历OPENAI_PROXY 进行设置
# 比如: "openai_proxy": 'http://127.0.0.1:4780'
"gpt-3.5-turbo": {

# 这些配置文件的名字不能改动
"Azure-OpenAI": {
"deployment_name": "your Azure deployment name",
"model_version": "0701",
"openai_api_type": "azure",
"api_base_url": "https://your Azure point.azure.com",
"api_version": "2023-07-01-preview",
"api_key": "your Azure api key",
"openai_proxy": "",
},
"OpenAI": {
"model_name": "your openai model name(such as gpt-4)",
"api_base_url": "https://api.openai.com/v1",
"api_key": "your OPENAI_API_KEY",
"openai_proxy": "your OPENAI_PROXY",
"openai_proxy": "",
},
"Anthropic": {
"model_name": "your claude model name(such as claude2-100k)",
"api_key":"your ANTHROPIC_API_KEY",
}
}
ONLINE_LLM_MODEL = {
# 线上模型。请在server_config中为每个在线API设置不同的端口
# 具体注册及api key获取请前往 http://open.bigmodel.cn
"zhipu-api": {
Expand Down
121 changes: 93 additions & 28 deletions configs/prompt_config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,106 @@
# - context: 从检索结果拼接的知识文本
# - question: 用户提出的问题

# Agent对话支持的变量:

PROMPT_TEMPLATES = {
# LLM对话模板
"llm_chat": "{{ input }}",
# - tools: 可用的工具列表
# - tool_names: 可用的工具名称列表
# - history: 用户和Agent的对话历史
# - input: 用户输入内容
# - agent_scratchpad: Agent的思维记录

# 基于本地知识问答的提示词模板
"knowledge_base_chat":
"""
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。 </指令>
<已知信息>{{ context }}</已知信息>、
<问题>{{ question }}</问题>""",
PROMPT_TEMPLATES = {}

PROMPT_TEMPLATES["llm_chat"] = {
"default": "{{ input }}",

# 基于agent的提示词模板
"agent_chat":
"py":
"""
Answer the following questions as best you can. You have access to the following tools:
你是一个聪明的代码助手,请你给我写出简单的py代码。 \n
{{ input }}
"""
,
}

PROMPT_TEMPLATES["knowledge_base_chat"] = {
"default":
"""
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。 </指令>
<已知信息>{{ context }}</已知信息>、
<问题>{{ question }}</问题>
""",
"text":
"""
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>
<已知信息>{{ context }}</已知信息>、
<问题>{{ question }}</问题>
""",
}
PROMPT_TEMPLATES["search_engine_chat"] = {
"default":
"""
<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 </指令>
<已知信息>{{ context }}</已知信息>、
<问题>{{ question }}</问题>
""",

"search":
"""
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>
<已知信息>{{ context }}</已知信息>、
<问题>{{ question }}</问题>
""",
}
PROMPT_TEMPLATES["agent_chat"] = {
"default":
"""
Answer the following questions as best you can. If it is in order, you can use some tools appropriately.You have access to the following tools:

{tools}

Please note that the "知识库查询工具" is information about the "西交利物浦大学" ,and if a question is asked about it, you must answer with the knowledge base,
Please note that the "天气查询工具" can only be used once since Question begin.

Use the following format:
Question: the input question you must answer1
Thought: you should always think about what to do and what tools to use.
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question

{tools}
Use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
history:
{history}
Question: {input}
Thought: {agent_scratchpad}
""",
"ChatGLM":
"""
请请严格按照提供的思维方式来思考。你的知识不一定正确,所以你一定要用提供的工具来思考,并给出用户答案。
你有以下工具可以使用:
{tools}
```
Question: 用户的提问或者观察到的信息,
Thought: 你应该思考该做什么,是根据工具的结果来回答问题,还是决定使用什么工具。
Action: 需要使用的工具,应该是在[{tool_names}]中的一个。
Action Input: 传入工具的内容
Observation: 工具给出的答案(不是你生成的)
... (this Thought/Action/Action Input/Observation can be repeated zero or more times)
Thought: 通过工具给出的答案,你是否能回答Question。
Final Answer是你的答案

Begin!
现在,我们开始!
你和用户的历史记录:
History:
{history}

history:
{history}
用户开始以提问:
Question: {input}
Thought: {agent_scratchpad}

Question: {input}
Thought: {agent_scratchpad}
"""
""",
}
39 changes: 22 additions & 17 deletions configs/server_config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ HTTPX_DEFAULT_TIMEOUT = 300.0
OPEN_CROSS_DOMAIN = False

# 各服务器默认绑定host。如改为"0.0.0.0"需要修改下方所有XX_SERVER的host
DEFAULT_BIND_HOST = "0.0.0.0"
DEFAULT_BIND_HOST = "0.0.0.0" if sys.platform != "win32" else "127.0.0.1"

# webui.py server
WEBUI_SERVER = {
Expand All @@ -32,14 +32,16 @@ FSCHAT_OPENAI_API = {
# fastchat model_worker server
# 这些模型必须是在model_config.MODEL_PATH或ONLINE_MODEL中正确配置的。
# 在启动startup.py时,可用通过`--model-worker --model-name xxxx`指定模型,不指定则为LLM_MODEL
# 必须在这里添加的模型才会出现在WEBUI中可选模型列表里(LLM_MODEL会自动添加)
FSCHAT_MODEL_WORKERS = {
# 所有模型共用的默认配置,可在模型专项配置中进行覆盖。
"default": {
"host": DEFAULT_BIND_HOST,
"port": 20002,
"device": LLM_DEVICE,
# False,'vllm',使用的推理加速框架,使用vllm如果出现HuggingFace通信问题,参见doc/FAQ
"infer_turbo": "vllm" if sys.platform.startswith("linux") else False,
# vllm对一些模型支持还不成熟,暂时默认关闭
"infer_turbo": False,

# model_worker多卡加载需要配置的参数
# "gpus": None, # 使用的GPU,以str的格式指定,如"0,1",如失效请使用CUDA_VISIBLE_DEVICES="0,1"等形式指定
Expand Down Expand Up @@ -97,21 +99,24 @@ FSCHAT_MODEL_WORKERS = {
"zhipu-api": { # 请为每个要运行的在线API设置不同的端口
"port": 21001,
},
"minimax-api": {
"port": 21002,
},
"xinghuo-api": {
"port": 21003,
},
"qianfan-api": {
"port": 21004,
},
"fangzhou-api": {
"port": 21005,
},
"qwen-api": {
"port": 21006,
},
# "minimax-api": {
# "port": 21002,
# },
# "xinghuo-api": {
# "port": 21003,
# },
# "qianfan-api": {
# "port": 21004,
# },
# "fangzhou-api": {
# "port": 21005,
# },
# "qwen-api": {
# "port": 21006,
# },
# "baichuan-api": {
# "port": 21007,
# },
}

# fastchat multi model worker server
Expand Down
Loading