🎈 perf: 优化 openai_source 方法默认参数

This commit is contained in:
Soulter
2025-05-06 23:15:11 +08:00
parent 9cc4e97a53
commit c5bc709898
2 changed files with 31 additions and 10 deletions
+12 -10
View File
@@ -21,7 +21,7 @@ from astrbot import logger
from astrbot.core.provider.func_tool_manager import FuncCall
from typing import List, AsyncGenerator
from ..register import register_provider_adapter
from astrbot.core.provider.entities import LLMResponse
from astrbot.core.provider.entities import LLMResponse, ToolCallsResult
@register_provider_adapter(
@@ -221,14 +221,16 @@ class ProviderOpenAIOfficial(Provider):
self,
prompt: str,
session_id: str = None,
image_urls: List[str] = [],
image_urls: list[str] = None,
func_tool: FuncCall = None,
contexts=[],
system_prompt=None,
tool_calls_result=None,
contexts: list=None,
system_prompt: str=None,
tool_calls_result: ToolCallsResult=None,
**kwargs,
) -> tuple:
"""准备聊天所需的有效载荷和上下文"""
if contexts is None:
contexts = []
new_record = await self.assemble_context(prompt, image_urls)
context_query = [*contexts, new_record]
if system_prompt:
@@ -337,11 +339,11 @@ class ProviderOpenAIOfficial(Provider):
async def text_chat(
self,
prompt: str,
session_id: str = None,
image_urls: List[str] = [],
func_tool: FuncCall = None,
contexts=[],
prompt,
session_id = None,
image_urls = None,
func_tool = None,
contexts=None,
system_prompt=None,
tool_calls_result=None,
**kwargs,
+19
View File
@@ -0,0 +1,19 @@
from astrbot.api.event import filter, AstrMessageEvent
from astrbot.api.star import Context, Star, register
from astrbot.api import logger
@register("vpet", "AstrBot Team", "虚拟桌宠", "0.0.1")
class VPet(Star):
def __init__(self, context: Context):
super().__init__(context)
async def initialize(self):
"""可选择实现异步的插件初始化方法,当实例化该插件类之后会自动调用该方法。"""
@filter.llm_tool("screenshot")
async def screenshot(self, event: AstrMessageEvent):
"""Capture the screen and return the image."""
async def terminate(self):
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""