|
|
|
|
|
|
|
|
# |
|
|
# |
|
|
import logging |
|
|
import logging |
|
|
import os |
|
|
import os |
|
|
|
|
|
import re |
|
|
from collections import defaultdict, Counter |
|
|
from collections import defaultdict, Counter |
|
|
from concurrent.futures import ThreadPoolExecutor |
|
|
from concurrent.futures import ThreadPoolExecutor |
|
|
from copy import deepcopy |
|
|
from copy import deepcopy |
|
|
|
|
|
|
|
|
if response: |
|
|
if response: |
|
|
return response |
|
|
return response |
|
|
response = self._llm.chat(system, hist, conf) |
|
|
response = self._llm.chat(system, hist, conf) |
|
|
|
|
|
response = re.sub(r"<think>.*</think>", "", response) |
|
|
if response.find("**ERROR**") >= 0: |
|
|
if response.find("**ERROR**") >= 0: |
|
|
raise Exception(response) |
|
|
raise Exception(response) |
|
|
set_llm_cache(self._llm.llm_name, system, response, history, gen_conf) |
|
|
set_llm_cache(self._llm.llm_name, system, response, history, gen_conf) |