KevinHuSh
commited on
Commit
·
1daa4bd
1
Parent(s):
0957ae0
refine log format (#312)
Browse files### What problem does this PR solve?
Issue link:#264
### Type of change
- [x] Documentation Update
- [x] Refactoring
- README.md +1 -1
- README_ja.md +1 -1
- README_zh.md +1 -1
- api/db/db_models.py +1 -1
- api/settings.py +6 -10
- api/utils/log_utils.py +2 -1
- rag/app/book.py +1 -1
- rag/app/laws.py +1 -1
- rag/llm/chat_model.py +1 -1
README.md
CHANGED
@@ -65,7 +65,7 @@
|
|
65 |
|
66 |
- CPU >= 2 cores
|
67 |
- RAM >= 8 GB
|
68 |
-
- Docker >= 24.0.0
|
69 |
> If you have not installed Docker on your local machine (Windows, Mac, or Linux), see [Install Docker Engine](https://docs.docker.com/engine/install/).
|
70 |
|
71 |
### 🚀 Start up the server
|
|
|
65 |
|
66 |
- CPU >= 2 cores
|
67 |
- RAM >= 8 GB
|
68 |
+
- Docker >= 24.0.0 & Docker Compose >= v2.26.1
|
69 |
> If you have not installed Docker on your local machine (Windows, Mac, or Linux), see [Install Docker Engine](https://docs.docker.com/engine/install/).
|
70 |
|
71 |
### 🚀 Start up the server
|
README_ja.md
CHANGED
@@ -65,7 +65,7 @@
|
|
65 |
|
66 |
- CPU >= 2 cores
|
67 |
- RAM >= 8 GB
|
68 |
-
- Docker >= 24.0.0
|
69 |
> ローカルマシン(Windows、Mac、または Linux)に Docker をインストールしていない場合は、[Docker Engine のインストール](https://docs.docker.com/engine/install/) を参照してください。
|
70 |
|
71 |
### 🚀 サーバーを起動
|
|
|
65 |
|
66 |
- CPU >= 2 cores
|
67 |
- RAM >= 8 GB
|
68 |
+
- Docker >= 24.0.0 & Docker Compose >= v2.26.1
|
69 |
> ローカルマシン(Windows、Mac、または Linux)に Docker をインストールしていない場合は、[Docker Engine のインストール](https://docs.docker.com/engine/install/) を参照してください。
|
70 |
|
71 |
### 🚀 サーバーを起動
|
README_zh.md
CHANGED
@@ -65,7 +65,7 @@
|
|
65 |
|
66 |
- CPU >= 2 核
|
67 |
- RAM >= 8 GB
|
68 |
-
- Docker >= 24.0.0
|
69 |
> 如果你并没有在本机安装 Docker(Windows、Mac,或者 Linux), 可以参考文档 [Install Docker Engine](https://docs.docker.com/engine/install/) 自行安装。
|
70 |
|
71 |
### 🚀 启动服务器
|
|
|
65 |
|
66 |
- CPU >= 2 核
|
67 |
- RAM >= 8 GB
|
68 |
+
- Docker >= 24.0.0 & Docker Compose >= v2.26.1
|
69 |
> 如果你并没有在本机安装 Docker(Windows、Mac,或者 Linux), 可以参考文档 [Install Docker Engine](https://docs.docker.com/engine/install/) 自行安装。
|
70 |
|
71 |
### 🚀 启动服务器
|
api/db/db_models.py
CHANGED
@@ -695,7 +695,7 @@ class Dialog(DataBaseModel):
|
|
695 |
language = CharField(
|
696 |
max_length=32,
|
697 |
null=True,
|
698 |
-
default="
|
699 |
help_text="English|Chinese")
|
700 |
llm_id = CharField(max_length=32, null=False, help_text="default llm ID")
|
701 |
llm_setting = JSONField(null=False, default={"temperature": 0.1, "top_p": 0.3, "frequency_penalty": 0.7,
|
|
|
695 |
language = CharField(
|
696 |
max_length=32,
|
697 |
null=True,
|
698 |
+
default="Chinese",
|
699 |
help_text="English|Chinese")
|
700 |
llm_id = CharField(max_length=32, null=False, help_text="default llm ID")
|
701 |
llm_setting = JSONField(null=False, default={"temperature": 0.1, "top_p": 0.3, "frequency_penalty": 0.7,
|
api/settings.py
CHANGED
@@ -13,15 +13,8 @@
|
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
#
|
16 |
-
import logging
|
17 |
-
|
18 |
-
from rag.utils import ELASTICSEARCH
|
19 |
-
from rag.nlp import search
|
20 |
import os
|
21 |
-
|
22 |
from enum import IntEnum, Enum
|
23 |
-
|
24 |
-
from api.utils import get_base_config, decrypt_database_config
|
25 |
from api.utils.file_utils import get_project_base_directory
|
26 |
from api.utils.log_utils import LoggerFactory, getLogger
|
27 |
|
@@ -32,13 +25,16 @@ LoggerFactory.set_directory(
|
|
32 |
"logs",
|
33 |
"api"))
|
34 |
# {CRITICAL: 50, FATAL:50, ERROR:40, WARNING:30, WARN:30, INFO:20, DEBUG:10, NOTSET:0}
|
35 |
-
LoggerFactory.LEVEL =
|
36 |
|
37 |
stat_logger = getLogger("stat")
|
38 |
access_logger = getLogger("access")
|
39 |
database_logger = getLogger("database")
|
40 |
chat_logger = getLogger("chat")
|
41 |
-
|
|
|
|
|
|
|
42 |
|
43 |
API_VERSION = "v1"
|
44 |
RAG_FLOW_SERVICE_NAME = "ragflow"
|
@@ -79,7 +75,7 @@ default_llm = {
|
|
79 |
"image2text_model": "glm-4v",
|
80 |
"asr_model": "",
|
81 |
},
|
82 |
-
"
|
83 |
"chat_model": "qwen-14B-chat",
|
84 |
"embedding_model": "flag-embedding",
|
85 |
"image2text_model": "",
|
|
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
#
|
|
|
|
|
|
|
|
|
16 |
import os
|
|
|
17 |
from enum import IntEnum, Enum
|
|
|
|
|
18 |
from api.utils.file_utils import get_project_base_directory
|
19 |
from api.utils.log_utils import LoggerFactory, getLogger
|
20 |
|
|
|
25 |
"logs",
|
26 |
"api"))
|
27 |
# {CRITICAL: 50, FATAL:50, ERROR:40, WARNING:30, WARN:30, INFO:20, DEBUG:10, NOTSET:0}
|
28 |
+
LoggerFactory.LEVEL = 30
|
29 |
|
30 |
stat_logger = getLogger("stat")
|
31 |
access_logger = getLogger("access")
|
32 |
database_logger = getLogger("database")
|
33 |
chat_logger = getLogger("chat")
|
34 |
+
|
35 |
+
from rag.utils import ELASTICSEARCH
|
36 |
+
from rag.nlp import search
|
37 |
+
from api.utils import get_base_config, decrypt_database_config
|
38 |
|
39 |
API_VERSION = "v1"
|
40 |
RAG_FLOW_SERVICE_NAME = "ragflow"
|
|
|
75 |
"image2text_model": "glm-4v",
|
76 |
"asr_model": "",
|
77 |
},
|
78 |
+
"Ollama": {
|
79 |
"chat_model": "qwen-14B-chat",
|
80 |
"embedding_model": "flag-embedding",
|
81 |
"image2text_model": "",
|
api/utils/log_utils.py
CHANGED
@@ -26,7 +26,8 @@ from api.utils import file_utils
|
|
26 |
|
27 |
class LoggerFactory(object):
|
28 |
TYPE = "FILE"
|
29 |
-
LOG_FORMAT = "[%(levelname)s] [%(asctime)s] [
|
|
|
30 |
LEVEL = logging.DEBUG
|
31 |
logger_dict = {}
|
32 |
global_handler_dict = {}
|
|
|
26 |
|
27 |
class LoggerFactory(object):
|
28 |
TYPE = "FILE"
|
29 |
+
LOG_FORMAT = "[%(levelname)s] [%(asctime)s] [%(module)s.%(funcName)s] [line:%(lineno)d]: %(message)s"
|
30 |
+
logging.basicConfig(format=LOG_FORMAT)
|
31 |
LEVEL = logging.DEBUG
|
32 |
logger_dict = {}
|
33 |
global_handler_dict = {}
|
rag/app/book.py
CHANGED
@@ -110,7 +110,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
|
|
110 |
[t for t in random_choices([t for t, _ in sections], k=100)])
|
111 |
if bull >= 0:
|
112 |
chunks = ["\n".join(ck)
|
113 |
-
for ck in hierarchical_merge(bull, sections,
|
114 |
else:
|
115 |
sections = [s.split("@") for s, _ in sections]
|
116 |
sections = [(pr[0], "@" + pr[1]) for pr in sections if len(pr) == 2]
|
|
|
110 |
[t for t in random_choices([t for t, _ in sections], k=100)])
|
111 |
if bull >= 0:
|
112 |
chunks = ["\n".join(ck)
|
113 |
+
for ck in hierarchical_merge(bull, sections, 5)]
|
114 |
else:
|
115 |
sections = [s.split("@") for s, _ in sections]
|
116 |
sections = [(pr[0], "@" + pr[1]) for pr in sections if len(pr) == 2]
|
rag/app/laws.py
CHANGED
@@ -133,7 +133,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
|
|
133 |
|
134 |
make_colon_as_title(sections)
|
135 |
bull = bullets_category(sections)
|
136 |
-
chunks = hierarchical_merge(bull, sections,
|
137 |
if not chunks:
|
138 |
callback(0.99, "No chunk parsed out.")
|
139 |
|
|
|
133 |
|
134 |
make_colon_as_title(sections)
|
135 |
bull = bullets_category(sections)
|
136 |
+
chunks = hierarchical_merge(bull, sections, 5)
|
137 |
if not chunks:
|
138 |
callback(0.99, "No chunk parsed out.")
|
139 |
|
rag/llm/chat_model.py
CHANGED
@@ -98,7 +98,7 @@ class QWenChat(Base):
|
|
98 |
tk_count = 0
|
99 |
if response.status_code == HTTPStatus.OK:
|
100 |
ans += response.output.choices[0]['message']['content']
|
101 |
-
tk_count += response.usage.
|
102 |
if response.output.choices[0].get("finish_reason", "") == "length":
|
103 |
ans += "...\nFor the content length reason, it stopped, continue?" if is_english(
|
104 |
[ans]) else "······\n由于长度的原因,回答被截断了,要继续吗?"
|
|
|
98 |
tk_count = 0
|
99 |
if response.status_code == HTTPStatus.OK:
|
100 |
ans += response.output.choices[0]['message']['content']
|
101 |
+
tk_count += response.usage.total_tokens
|
102 |
if response.output.choices[0].get("finish_reason", "") == "length":
|
103 |
ans += "...\nFor the content length reason, it stopped, continue?" if is_english(
|
104 |
[ans]) else "······\n由于长度的原因,回答被截断了,要继续吗?"
|