Feature/feat1017 (#2872)

### What problem does this PR solve?

1. fix: mid map show error in knowledge graph, juse because
```@antv/g6```version changed
2. feat: concurrent threads configuration support in graph extractor
3. fix: used tokens update failed for tenant
4. feat: timeout configuration support for llm
5. fix: regex error in graph extractor
6. feat: qwen rerank(```gte-rerank```) support
7. fix: timeout deal in knowledge graph index process. Now chat by
stream output, also, it is configuratable.
8. feat: ```qwen-long``` model configuration

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: chongchuanbing <chongchuanbing@gmail.com>
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
chongchuanbing
2024-10-21 12:11:08 +08:00
committed by GitHub
parent 4bdf3fd48e
commit ac26d09a59
8 changed files with 95 additions and 35 deletions

View File

@ -164,6 +164,7 @@ class GraphExtractor:
text = perform_variable_replacements(self._extraction_prompt, variables=variables)
gen_conf = {"temperature": 0.3}
response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf)
if response.find("**ERROR**") >= 0: raise Exception(response)
token_count = num_tokens_from_string(text + response)
results = response or ""

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
from concurrent.futures import ThreadPoolExecutor
import json
from functools import reduce
@ -64,7 +65,8 @@ def build_knowledge_graph_chunks(tenant_id: str, chunks: List[str], callback, en
texts, graphs = [], []
cnt = 0
threads = []
exe = ThreadPoolExecutor(max_workers=50)
max_workers = int(os.environ.get('GRAPH_EXTRACTOR_MAX_WORKERS', 50))
exe = ThreadPoolExecutor(max_workers=max_workers)
for i in range(len(chunks)):
tkn_cnt = num_tokens_from_string(chunks[i])
if cnt+tkn_cnt >= left_token_count and texts:

View File

@ -16,6 +16,7 @@
import collections
import logging
import os
import re
import logging
import traceback
@ -89,7 +90,8 @@ class MindMapExtractor:
prompt_variables = {}
try:
exe = ThreadPoolExecutor(max_workers=12)
max_workers = int(os.environ.get('MINDMAP_EXTRACTOR_MAX_WORKERS', 12))
exe = ThreadPoolExecutor(max_workers=max_workers)
threads = []
token_count = max(self._llm.max_length * 0.8, self._llm.max_length-512)
texts = []