diff --git a/README.md b/README.md index ad26dc30..681152b0 100644 --- a/README.md +++ b/README.md @@ -236,11 +236,11 @@ Here's a troubleshooting guide: Please carefully check if the GROUP_LIST is corr To use the document question and answer feature, you must first enable the history record. You can turn on the history record through the `/info` command, or by setting the environment variable `PASS_HISTORY` to `True` to enable the history record by default. Please note that enabling the history record will incur additional costs, so this project does not enable the history record by default. This means that the question and answer feature cannot be used under the default settings. Before using this feature, you need to manually enable the history record. -- What is gpt4free in the `/info` command? Do I need to enable it? + - After setting the `NICK`, there's no response when I @ the bot, and it only replies when the message starts with the nick. How can I make it respond to both the nick and @botname? diff --git a/bot.py b/bot.py index 78f82734..c0c651c7 100644 --- a/bot.py +++ b/bot.py @@ -74,9 +74,9 @@ async def command_bot(update, context, language=None, prompt=translator_prompt, if message: if "claude" in config.GPT_ENGINE and config.ClaudeAPI: robot = config.claudeBot - if not config.API or config.PLUGINS["USE_G4F"]: - import utils.gpt4free as gpt4free - robot = gpt4free + # if not config.API or config.PLUGINS["USE_G4F"]: + # import utils.gpt4free as gpt4free + # robot = gpt4free if image_url: robot = config.GPT4visionbot title = "`🤖️ gpt-4-vision-preview`\n\n" @@ -282,16 +282,16 @@ def update_first_buttons_message(): [ InlineKeyboardButton("更换问答模型", callback_data="更换问答模型"), InlineKeyboardButton(language, callback_data="language"), + InlineKeyboardButton(f"历史记录 {history}", callback_data="PASS_HISTORY"), ], [ - InlineKeyboardButton(f"历史记录 {history}", callback_data="PASS_HISTORY"), InlineKeyboardButton(f"搜索 {get_plugins_status('SEARCH_USE_GPT')}", callback_data='SEARCH_USE_GPT'), InlineKeyboardButton(f"当前时间 {get_plugins_status('DATE')}", callback_data='DATE'), ], [ InlineKeyboardButton(f"URL 总结 {get_plugins_status('URL')}", callback_data='URL'), InlineKeyboardButton(f"版本信息 {get_plugins_status('VERSION')}", callback_data='VERSION'), - InlineKeyboardButton(f"gpt4free {get_plugins_status('USE_G4F')}", callback_data='USE_G4F'), + # InlineKeyboardButton(f"gpt4free {get_plugins_status('USE_G4F')}", callback_data='USE_G4F'), ], ] return first_buttons diff --git a/config.py b/config.py index 4152c4fe..0c92e4e9 100644 --- a/config.py +++ b/config.py @@ -57,7 +57,7 @@ PLUGINS = { "SEARCH_USE_GPT": (os.environ.get('SEARCH_USE_GPT', "True") == "False") == False, - "USE_G4F": (os.environ.get('USE_G4F', "False") == "False") == False, + # "USE_G4F": (os.environ.get('USE_G4F', "False") == "False") == False, "DATE": True, "URL": True, "VERSION": True, diff --git a/requirements.txt b/requirements.txt index a1132c77..b699b22d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ duckduckgo-search==4.1.0 langchain==0.0.271 oauth2client==3.0.0 pdfminer.six -g4f==0.1.9.6 +# g4f==0.1.9.6 # plugin pytz \ No newline at end of file diff --git a/utils/plugins.py b/utils/plugins.py index 296d76df..6d666017 100644 --- a/utils/plugins.py +++ b/utils/plugins.py @@ -24,26 +24,26 @@ from langchain.tools import DuckDuckGoSearchResults from langchain.chains import LLMChain -from typing import Optional, List -from langchain.llms.base import LLM -import g4f -class EducationalLLM(LLM): - - @property - def _llm_type(self) -> str: - return "custom" - - def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str: - out = g4f.ChatCompletion.create( - model=config.GPT_ENGINE, - messages=[{"role": "user", "content": prompt}], - ) # - if stop: - stop_indexes = (out.find(s) for s in stop if s in out) - min_stop = min(stop_indexes, default=-1) - if min_stop > -1: - out = out[:min_stop] - return out +# from typing import Optional, List +# from langchain.llms.base import LLM +# import g4f +# class EducationalLLM(LLM): + +# @property +# def _llm_type(self) -> str: +# return "custom" + +# def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str: +# out = g4f.ChatCompletion.create( +# model=config.GPT_ENGINE, +# messages=[{"role": "user", "content": prompt}], +# ) # +# if stop: +# stop_indexes = (out.find(s) for s in stop if s in out) +# min_stop = min(stop_indexes, default=-1) +# if min_stop > -1: +# out = out[:min_stop] +# return out class ThreadWithReturnValue(threading.Thread): def run(self): @@ -264,10 +264,11 @@ def get_url_text_list(prompt): start_time = record_time.time() yield "🌐 正在搜索您的问题,提取关键词..." - if config.PLUGINS["USE_G4F"]: - chainllm = EducationalLLM() - else: - chainllm = ChatOpenAI(temperature=config.temperature, openai_api_base=config.bot_api_url.v1_url, model_name=config.GPT_ENGINE, openai_api_key=config.API) + # if config.PLUGINS["USE_G4F"]: + # chainllm = EducationalLLM() + # else: + # chainllm = ChatOpenAI(temperature=config.temperature, openai_api_base=config.bot_api_url.v1_url, model_name=config.GPT_ENGINE, openai_api_key=config.API) + chainllm = ChatOpenAI(temperature=config.temperature, openai_api_base=config.bot_api_url.v1_url, model_name=config.GPT_ENGINE, openai_api_key=config.API) url_set_list, url_pdf_set_list = yield from get_search_url(prompt, chainllm)