From a5e758bf82b37497b238810a28446735b154ef1e Mon Sep 17 00:00:00 2001 From: liunux4odoo Date: Mon, 22 Jan 2024 14:36:01 +0800 Subject: [PATCH] fix: set default score_threshold to 1; add weather api key to kb_config --- configs/kb_config.py.example | 9 +++++---- configs/model_config.py.example | 2 +- server/agent/tools/weather_check.py | 6 +++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/configs/kb_config.py.example b/configs/kb_config.py.example index f1b5d1a0..23e06bdc 100644 --- a/configs/kb_config.py.example +++ b/configs/kb_config.py.example @@ -21,10 +21,9 @@ OVERLAP_SIZE = 50 # 知识库匹配向量数量 VECTOR_SEARCH_TOP_K = 3 -# 知识库匹配的距离阈值,取值范围在0-1之间,SCORE越小,距离越小从而相关度越高, -# 取到1相当于不筛选,实测bge-large的距离得分大部分在0.01-0.7之间, -# 相似文本的得分最高在0.55左右,因此建议针对bge设置得分为0.6 -SCORE_THRESHOLD = 0.6 +# 知识库匹配的距离阈值,一般取值范围在0-1之间,SCORE越小,距离越小从而相关度越高。 +# 但有用户报告遇到过匹配分值超过1的情况,为了兼容性默认设为1,在WEBUI中调整范围为0-2 +SCORE_THRESHOLD = 1.0 # 默认搜索引擎。可选:bing, duckduckgo, metaphor DEFAULT_SEARCH_ENGINE = "duckduckgo" @@ -49,6 +48,8 @@ BING_SUBSCRIPTION_KEY = "" # metaphor搜索需要KEY METAPHOR_API_KEY = "" +# 心知天气 API KEY,用于天气Agent。申请:https://www.seniverse.com/ +SENIVERSE_API_KEY = "" # 是否开启中文标题加强,以及标题增强的相关配置 # 通过增加标题判断,判断哪些文本为标题,并在metadata中进行标记; diff --git a/configs/model_config.py.example b/configs/model_config.py.example index 09a019a6..8746f098 100644 --- a/configs/model_config.py.example +++ b/configs/model_config.py.example @@ -201,7 +201,7 @@ MODEL_PATH = { "agentlm-70b": "THUDM/agentlm-70b", "falcon-7b": "tiiuae/falcon-7b", - "falcon-40b": "tiiuae/falcon-40,b", + "falcon-40b": "tiiuae/falcon-40b", "falcon-rw-7b": "tiiuae/falcon-rw-7b", "aquila-7b": "BAAI/Aquila-7B", diff --git a/server/agent/tools/weather_check.py b/server/agent/tools/weather_check.py index 8e9f3c6b..20f009a5 100644 --- a/server/agent/tools/weather_check.py +++ b/server/agent/tools/weather_check.py @@ -3,6 +3,8 @@ """ from pydantic import BaseModel, Field import requests +from configs.kb_config import SENIVERSE_API_KEY + def weather(location: str, api_key: str): url = f"https://api.seniverse.com/v3/weather/now.json?key={api_key}&location={location}&language=zh-Hans&unit=c" @@ -20,6 +22,8 @@ def weather(location: str, api_key: str): def weathercheck(location: str): - return weather(location, "your keys") + return weather(location, SENIVERSE_API_KEY) + + class WeatherInput(BaseModel): location: str = Field(description="City name,include city and county")