diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index aa3a422e2..50000bdd8 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -69,7 +69,9 @@ DEFAULT_CONFIG = { "internal_keywords": {"enable": True, "extra_keywords": []}, "baidu_aip": {"enable": False, "app_id": "", "api_key": "", "secret_key": ""}, }, - "admins_id": [], + "admins_id": [ + "astrbot" + ], "t2i": False, "t2i_word_threshold": 150, "http_proxy": "", diff --git a/astrbot/core/pipeline/result_decorate/stage.py b/astrbot/core/pipeline/result_decorate/stage.py index b44dc7ea9..8c4033907 100644 --- a/astrbot/core/pipeline/result_decorate/stage.py +++ b/astrbot/core/pipeline/result_decorate/stage.py @@ -39,9 +39,8 @@ class ResultDecorateStage: handlers = star_handlers_registry.get_handlers_by_event_type(EventType.OnDecoratingResultEvent) for handler in handlers: - # TODO: 如何让这里的 handler 也能使用 LLM 能力。也许需要将 LLMRequestSubStage 提取出来。 await handler.handler(event) - + if len(result.chain) > 0: # 回复前缀 if self.reply_prefix: diff --git a/astrbot/core/platform/astr_message_event.py b/astrbot/core/platform/astr_message_event.py index 7e3df73e2..d650ba840 100644 --- a/astrbot/core/platform/astr_message_event.py +++ b/astrbot/core/platform/astr_message_event.py @@ -8,7 +8,7 @@ from typing import List, Union from astrbot.core.message.components import Plain, Image, BaseMessageComponent, Face, At, AtAll, Forward from astrbot.core.utils.metrics import Metric from astrbot.core.provider.entites import ProviderRequest - +from astrbot.core.db.po import Conversation @dataclass class MessageSesion: @@ -305,9 +305,10 @@ class AstrMessageEvent(abc.ABC): prompt: str, func_tool_manager = None, session_id: str = None, - image_urls: List[str] = None, - contexts: List = None, - system_prompt: str = "" + image_urls: List[str] = [], + contexts: List = [], + system_prompt: str = "", + conversation: Conversation = None ) -> ProviderRequest: ''' 创建一个 LLM 请求。 @@ -316,10 +317,12 @@ class AstrMessageEvent(abc.ABC): ```py yield event.request_llm(prompt="hi") ``` - + prompt: 提示词 + session_id: 已经过时,留空即可 image_urls: 可以是 base64:// 或者 http:// 开头的图片链接,也可以是本地图片路径。 - contexts: 当指定 contexts 时,将会**只**使用 contexts 作为上下文。 + contexts: 当指定 contexts 时,将会使用 contexts 作为上下文。 func_tool_manager: 函数工具管理器,用于调用函数工具。用 self.context.get_llm_tool_manager() 获取。 + conversation: 可选。如果指定,将在指定的对话中进行 LLM 请求。对话的人格会被用于 LLM 请求,并且结果将会被记录到对话中。 ''' return ProviderRequest( prompt = prompt, @@ -327,5 +330,6 @@ class AstrMessageEvent(abc.ABC): image_urls = image_urls, func_tool = func_tool_manager, contexts = contexts, - system_prompt = system_prompt + system_prompt = system_prompt, + conversation=conversation ) \ No newline at end of file diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index cabd40849..931423963 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -111,7 +111,7 @@ class ProviderOpenAIOfficial(Provider): self, prompt: str, session_id: str=None, - image_urls: List[str]=None, + image_urls: List[str]=[], func_tool: FuncCall=None, contexts=[], system_prompt=None, diff --git a/packages/astrbot/main.py b/packages/astrbot/main.py index 66d43feca..a5a812fec 100644 --- a/packages/astrbot/main.py +++ b/packages/astrbot/main.py @@ -649,7 +649,8 @@ UID: {user_id} 此 ID 可用于设置管理员。/op 授权管理员, /deo prompt=prompt, func_tool_manager=self.context.get_llm_tool_manager(), session_id=event.session_id, - contexts=history if history else [] + contexts=history if history else [], + conversation=conv, ) except BaseException as e: logger.error(f"主动回复失败: {e}")