diff --git a/configs/kb_config.py.example b/configs/kb_config.py.example index 9c727b7..c9ff431 100644 --- a/configs/kb_config.py.example +++ b/configs/kb_config.py.example @@ -106,7 +106,7 @@ kbs_config = { # TextSplitter配置项,如果你不明白其中的含义,就不要修改。 text_splitter_dict = { "ChineseRecursiveTextSplitter": { - "source": "huggingface", ## 选择tiktoken则使用openai的方法 + "source": "huggingface", # 选择tiktoken则使用openai的方法 "tokenizer_name_or_path": "", }, "SpacyTextSplitter": { diff --git a/configs/model_config.py.example b/configs/model_config.py.example index 06d7323..40d7d77 100644 --- a/configs/model_config.py.example +++ b/configs/model_config.py.example @@ -115,7 +115,7 @@ ONLINE_LLM_MODEL = { # 昆仑万维天工 API https://model-platform.tiangong.cn/ "tiangong-api": { - "version":"SkyChat-MegaVerse", + "version": "SkyChat-MegaVerse", "api_key": "", "secret_key": "", "provider": "TianGongWorker", @@ -166,9 +166,9 @@ MODEL_PATH = { "chatglm3-6b-base": "THUDM/chatglm3-6b-base", "Qwen-1_8B": "Qwen/Qwen-1_8B", - "Qwen-1_8B-Chat":"Qwen/Qwen-1_8B-Chat", - "Qwen-1_8B-Chat-Int8":"Qwen/Qwen-1_8B-Chat-Int8", - "Qwen-1_8B-Chat-Int4":"Qwen/Qwen-1_8B-Chat-Int4", + "Qwen-1_8B-Chat": "Qwen/Qwen-1_8B-Chat", + "Qwen-1_8B-Chat-Int8": "Qwen/Qwen-1_8B-Chat-Int8", + "Qwen-1_8B-Chat-Int4": "Qwen/Qwen-1_8B-Chat-Int4", "Qwen-7B": "Qwen/Qwen-7B", "Qwen-7B-Chat": "Qwen/Qwen-7B-Chat", @@ -180,8 +180,8 @@ MODEL_PATH = { "Qwen-72B": "Qwen/Qwen-72B", "Qwen-72B-Chat": "Qwen/Qwen-72B-Chat", - "Qwen-72B-Chat-Int8":"Qwen/Qwen-72B-Chat-Int8" - "Qwen-72B-Chat-Int4":"Qwen/Qwen-72B-Chat-Int4" + "Qwen-72B-Chat-Int8": "Qwen/Qwen-72B-Chat-Int8", + "Qwen-72B-Chat-Int4": "Qwen/Qwen-72B-Chat-Int4", "baichuan2-13b": "baichuan-inc/Baichuan2-13B-Chat", "baichuan2-7b": "baichuan-inc/Baichuan2-7B-Chat", @@ -254,11 +254,11 @@ VLLM_MODEL_DICT = { "BlueLM-7B-Chat-32k": "vivo-ai/BlueLM-7B-Chat-32k", # 注意:bloom系列的tokenizer与model是分离的,因此虽然vllm支持,但与fschat框架不兼容 - # "bloom":"bigscience/bloom", - # "bloomz":"bigscience/bloomz", - # "bloomz-560m":"bigscience/bloomz-560m", - # "bloomz-7b1":"bigscience/bloomz-7b1", - # "bloomz-1b7":"bigscience/bloomz-1b7", + # "bloom": "bigscience/bloom", + # "bloomz": "bigscience/bloomz", + # "bloomz-560m": "bigscience/bloomz-560m", + # "bloomz-7b1": "bigscience/bloomz-7b1", + # "bloomz-1b7": "bigscience/bloomz-1b7", "internlm-7b": "internlm/internlm-7b", "internlm-chat-7b": "internlm/internlm-chat-7b", @@ -286,9 +286,9 @@ VLLM_MODEL_DICT = { "opt-iml-max-30b": "facebook/opt-iml-max-30b", "Qwen-1_8B": "Qwen/Qwen-1_8B", - "Qwen-1_8B-Chat":"Qwen/Qwen-1_8B-Chat", - "Qwen-1_8B-Chat-Int8":"Qwen/Qwen-1_8B-Chat-Int8", - "Qwen-1_8B-Chat-Int4":"Qwen/Qwen-1_8B-Chat-Int4", + "Qwen-1_8B-Chat": "Qwen/Qwen-1_8B-Chat", + "Qwen-1_8B-Chat-Int8": "Qwen/Qwen-1_8B-Chat-Int8", + "Qwen-1_8B-Chat-Int4": "Qwen/Qwen-1_8B-Chat-Int4", "Qwen-7B": "Qwen/Qwen-7B", "Qwen-7B-Chat": "Qwen/Qwen-7B-Chat", @@ -300,8 +300,8 @@ VLLM_MODEL_DICT = { "Qwen-72B": "Qwen/Qwen-72B", "Qwen-72B-Chat": "Qwen/Qwen-72B-Chat", - "Qwen-72B-Chat-Int8":"Qwen/Qwen-72B-Chat-Int8" - "Qwen-72B-Chat-Int4":"Qwen/Qwen-72B-Chat-Int4" + "Qwen-72B-Chat-Int8": "Qwen/Qwen-72B-Chat-Int8", + "Qwen-72B-Chat-Int4": "Qwen/Qwen-72B-Chat-Int4", "agentlm-7b": "THUDM/agentlm-7b", "agentlm-13b": "THUDM/agentlm-13b", diff --git a/configs/prompt_config.py.example b/configs/prompt_config.py.example index 0a7ebbe..130d21c 100644 --- a/configs/prompt_config.py.example +++ b/configs/prompt_config.py.example @@ -16,122 +16,112 @@ # - input: 用户输入内容 # - agent_scratchpad: Agent的思维记录 -PROMPT_TEMPLATES = {} +PROMPT_TEMPLATES = { + "llm_chat": { + "default": + '{{ input }}', -PROMPT_TEMPLATES["llm_chat"] = { -"default": "{{ input }}", -"with_history": -"""The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. + "with_history": + 'The following is a friendly conversation between a human and an AI. ' + 'The AI is talkative and provides lots of specific details from its context. ' + 'If the AI does not know the answer to a question, it truthfully says it does not know.\n\n' + 'Current conversation:\n' + '{history}\n' + 'Human: {input}\n' + 'AI:', -Current conversation: -{history} -Human: {input} -AI:""", -"py": -""" -你是一个聪明的代码助手,请你给我写出简单的py代码。 \n -{{ input }} -""", -} - -PROMPT_TEMPLATES["knowledge_base_chat"] = { -"default": -""" -<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。 -<已知信息>{{ context }}、 -<问题>{{ question }} -""", -"text": -""" -<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 -<已知信息>{{ context }}、 -<问题>{{ question }} -""", -"Empty": # 搜不到知识库的时候使用 -""" -请你回答我的问题: -{{ question }} -\n -""", -} -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} - -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 -Begin! - -history: {history} - -Question: {input} - -Thought: {agent_scratchpad} -""", - -"ChatGLM3": -""" -You can answer using the tools, or answer directly using your knowledge without using the tools.Respond to the human as helpfully and accurately as possible. -You have access to the following tools: -{tools} -Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input). -Valid "action" values: "Final Answer" or [{tool_names}] -Provide only ONE action per $JSON_BLOB, as shown: - -``` -{{{{ - "action": $TOOL_NAME, - "action_input": $INPUT -}}}} -``` - -Follow this format: - -Question: input question to answer -Thought: consider previous and subsequent steps -Action: -``` -$JSON_BLOB -``` -Observation: action result -... (repeat Thought/Action/Observation N times) -Thought: I know what to respond -Action: -``` -{{{{ - "action": "Final Answer", - "action_input": "Final response to human" -}}}} -Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:. - -history: {history} - -Question: {input} - -Thought: {agent_scratchpad} -""", + "py": + '你是一个聪明的代码助手,请你给我写出简单的py代码。 \n' + '{{ input }}', + }, + + + "knowledge_base_chat": { + "default": + '<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,' + '不允许在答案中添加编造成分,答案请使用中文。 \n' + '<已知信息>{{ context }}\n' + '<问题>{{ question }}\n', + + "text": + '<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 \n' + '<已知信息>{{ context }}\n' + '<问题>{{ question }}\n', + + "Empty": # 搜不到知识库的时候使用 + '请你回答我的问题:\n' + '{{ question }}\n\n', + }, + + + "search_engine_chat": { + "default": + '<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。' + '如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 \n' + '<已知信息>{{ context }}\n' + '<问题>{{ question }}\n', + + "search": + '<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 \n' + '<已知信息>{{ context }}\n' + '<问题>{{ question }}\n', + }, + + + "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:\n\n' + '{tools}\n\n' + 'Use the following format:\n' + 'Question: the input question you must answer1\n' + 'Thought: you should always think about what to do and what tools to use.\n' + 'Action: the action to take, should be one of [{tool_names}]\n' + 'Action Input: the input to the action\n' + 'Observation: the result of the action\n' + '... (this Thought/Action/Action Input/Observation can be repeated zero or more times)\n' + 'Thought: I now know the final answer\n' + 'Final Answer: the final answer to the original input question\n' + 'Begin!\n\n' + 'history: {history}\n\n' + 'Question: {input}\n\n' + 'Thought: {agent_scratchpad}\n', + + "ChatGLM3": + 'You can answer using the tools, or answer directly using your knowledge without using the tools. ' + 'Respond to the human as helpfully and accurately as possible.\n' + 'You have access to the following tools:\n' + '{tools}\n' + 'Use a json blob to specify a tool by providing an action key (tool name) ' + 'and an action_input key (tool input).\n' + 'Valid "action" values: "Final Answer" or [{tool_names}]' + 'Provide only ONE action per $JSON_BLOB, as shown:\n\n' + '```\n' + '{{{{\n' + ' "action": $TOOL_NAME,\n' + ' "action_input": $INPUT\n' + '}}}}\n' + '```\n\n' + 'Follow this format:\n\n' + 'Question: input question to answer\n' + 'Thought: consider previous and subsequent steps\n' + 'Action:\n' + '```\n' + '$JSON_BLOB\n' + '```\n' + 'Observation: action result\n' + '... (repeat Thought/Action/Observation N times)\n' + 'Thought: I know what to respond\n' + 'Action:\n' + '```\n' + '{{{{\n' + ' "action": "Final Answer",\n' + ' "action_input": "Final response to human"\n' + '}}}}\n' + 'Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. ' + 'Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.\n' + 'history: {history}\n\n' + 'Question: {input}\n\n' + 'Thought: {agent_scratchpad}', + } }