remove:无用代码

pull/1356/head
SengokuCola 2025-11-10 12:46:27 +08:00
parent 71a2a4282b
commit 837ecf702b
5 changed files with 0 additions and 408 deletions

View File

@ -1,34 +0,0 @@
{
"manifest_version": 1,
"name": "Deep Think插件 (Deep Think Actions)",
"version": "1.0.0",
"description": "可以深度思考",
"author": {
"name": "SengokuCola",
"url": "https://github.com/MaiM-with-u"
},
"license": "GPL-v3.0-or-later",
"host_application": {
"min_version": "0.11.0"
},
"homepage_url": "https://github.com/MaiM-with-u/maibot",
"repository_url": "https://github.com/MaiM-with-u/maibot",
"keywords": ["deep", "think", "action", "built-in"],
"categories": ["Deep Think"],
"default_locale": "zh-CN",
"locales_path": "_locales",
"plugin_info": {
"is_built_in": true,
"plugin_type": "action_provider",
"components": [
{
"type": "action",
"name": "deep_think",
"description": "发送深度思考"
}
]
}
}

View File

@ -1,102 +0,0 @@
from typing import List, Tuple, Type, Any
# 导入新插件系统
from src.plugin_system import BasePlugin, register_plugin, ComponentInfo
from src.plugin_system.base.config_types import ConfigField
from src.person_info.person_info import Person
from src.plugin_system.base.base_tool import BaseTool, ToolParamType
# 导入依赖的系统组件
from src.common.logger import get_logger
# from src.plugins.built_in.relation.relation import BuildRelationAction
from src.plugin_system.apis import llm_api
logger = get_logger("relation_actions")
class DeepThinkTool(BaseTool):
"""获取用户信息"""
name = "deep_think"
description = "深度思考,对某个知识,概念或逻辑问题进行全面且深入的思考,当面临复杂环境或重要问题时,使用此获得更好的解决方案。"
parameters = [
("question", ToolParamType.STRING, "需要思考的问题,越具体越好(从上下文中总结)", True, None),
]
available_for_llm = True
async def execute(self, function_args: dict[str, Any]) -> dict[str, Any]:
"""执行比较两个数的大小
Args:
function_args: 工具参数
Returns:
dict: 工具执行结果
"""
question: str = function_args.get("question") # type: ignore
print(f"question: {question}")
prompt = f"""
请你思考以下问题以简洁的一段话回答
{question}
"""
models = llm_api.get_available_models()
chat_model_config = models.get("replyer") # 使用字典访问方式
success, thinking_result, _, _ = await llm_api.generate_with_model(
prompt, model_config=chat_model_config, request_type="deep_think"
)
logger.info(f"{question}: {thinking_result}")
thinking_result =f"思考结果:{thinking_result}\n**注意** 因为你进行了深度思考,最后的回复内容可以回复的长一些,更加详细一些,不用太简洁。\n"
return {"content": thinking_result}
@register_plugin
class DeepThinkPlugin(BasePlugin):
"""关系动作插件
系统内置插件提供基础的聊天交互功能
- Reply: 回复动作
- NoReply: 不回复动作
- Emoji: 表情动作
注意插件基本信息优先从_manifest.json文件中读取
"""
# 插件基本信息
plugin_name: str = "deep_think" # 内部标识符
enable_plugin: bool = True
dependencies: list[str] = [] # 插件依赖列表
python_dependencies: list[str] = [] # Python包依赖列表
config_file_name: str = "config.toml"
# 配置节描述
config_section_descriptions = {
"plugin": "插件启用配置",
"components": "核心组件启用配置",
}
# 配置Schema定义
config_schema: dict = {
"plugin": {
"enabled": ConfigField(type=bool, default=False, description="是否启用插件"),
"config_version": ConfigField(type=str, default="2.0.0", description="配置文件版本"),
}
}
def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]:
"""返回插件包含的组件列表"""
# --- 根据配置注册组件 ---
components = []
components.append((DeepThinkTool.get_tool_info(), DeepThinkTool))
return components

View File

@ -1,36 +0,0 @@
{
"manifest_version": 1,
"name": "Jargon插件",
"version": "1.0.0",
"description": "记录和管理jargon黑话/俚语)的解释",
"author": {
"name": "Mai",
"url": "https://github.com/MaiM-with-u"
},
"license": "GPL-v3.0-or-later",
"host_application": {
"min_version": "0.10.4"
},
"homepage_url": "https://github.com/MaiM-with-u/maibot",
"repository_url": "https://github.com/MaiM-with-u/maibot",
"keywords": ["jargon", "slang", "built-in"],
"categories": ["Jargon"],
"default_locale": "zh-CN",
"locales_path": "_locales",
"plugin_info": {
"is_built_in": true,
"plugin_type": "tool_provider",
"components": [
{
"type": "record_jargon_explanation",
"name": "record_jargon_explanation",
"description": "记录聊天中明确解释的jargon词义"
}
]
}
}

View File

@ -1,180 +0,0 @@
from typing import Any, Dict, List, Tuple
from src.common.logger import get_logger
from src.common.database.database_model import Jargon
from src.plugin_system import BaseTool, ToolParamType
logger = get_logger("jargon_explanation")
class RecordJargonExplanationTool(BaseTool):
"""记录jargon解释工具
检测聊天记录中是否有对某个词义的明确解释如果有则记录到jargon表中
"""
name: str = "record_explanation"
description: str = (
"当检测到有人明确解释了某个缩写,拼音缩写,中文缩写,英文缩写的含义时(例如:'xxx是yyy的意思''xxx指的是yyy'等)"
"当某人明确纠正了对某个词汇的错误解释时(例如:'xxx不是yyy的意思''xxx不是指的是yyy'等)"
)
parameters: List[Tuple[str, ToolParamType, str, bool, None]] = [
("content", ToolParamType.STRING, "被解释的目标词汇(黑话/俚语/缩写例如yyds、内卷、社死等", True, None),
("translation", ToolParamType.STRING, "词汇的翻译或简称,例如:永远的神、社会性死亡等", True, None),
("meaning", ToolParamType.STRING, "词汇的详细含义说明", True, None),
]
available_for_llm: bool = True
async def execute(self, function_args: Dict[str, Any]) -> Dict[str, str]:
"""执行jargon解释检测和记录
Args:
function_args: 工具参数包含contenttranslationmeaning
Returns:
dict: 工具执行结果
"""
if not self.chat_id:
return {"name": self.name, "content": "无法记录jargon解释缺少chat_id"}
try:
# 从参数中获取信息
content = str(function_args.get("content", "")).strip()
translation = str(function_args.get("translation", "")).strip()
meaning = str(function_args.get("meaning", "")).strip()
if not content:
return {"name": self.name, "content": "目标词汇不能为空"}
if not translation and not meaning:
return {"name": self.name, "content": "翻译和含义至少需要提供一个"}
# 检查是否已存在相同的jargon
query = Jargon.select().where(
(Jargon.chat_id == self.chat_id) &
(Jargon.content == content)
)
if query.exists():
# 已存在更新translation和meaning追加用/分隔)
obj = query.get()
existing_translation = obj.translation or ""
existing_meaning = obj.meaning or ""
# 追加新内容
if translation:
if existing_translation:
obj.translation = f"{existing_translation}/{translation}"
else:
obj.translation = translation
if meaning:
if existing_meaning:
obj.meaning = f"{existing_meaning}/{meaning}"
else:
obj.meaning = meaning
# 确保is_jargon为True
obj.is_jargon = True
obj.save()
logger.info(f"更新jargon解释: {content}, translation={obj.translation}, meaning={obj.meaning}")
# 优先使用meaning如果没有则使用translation
explanation = obj.meaning or obj.translation or ""
return {"name": self.name, "content": f"你了解到 {content}的含义应该是 {explanation}"}
else:
# 新建记录
Jargon.create(
content=content,
chat_id=self.chat_id,
translation=translation,
meaning=meaning,
is_jargon=True,
is_global=False,
count=0,
)
logger.info(f"记录新jargon解释: {content}, translation={translation}, meaning={meaning}")
# 优先使用meaning如果没有则使用translation
explanation = meaning or translation or ""
return {"name": self.name, "content": f"你了解到 {content}的含义应该是 {explanation}"}
except Exception as exc:
logger.error(f"记录jargon解释失败: {exc}", exc_info=True)
return {"name": self.name, "content": f"记录jargon解释失败: {exc}"}
class LookupJargonMeaningTool(BaseTool):
"""查询jargon含义工具
输入一个可能意义不明的词或缩写查询数据库中是否已有匹配且带有含义或翻译的记录
命中则返回解释字符串优先meaning其次translation未命中返回空字符串
"""
name: str = "lookup_jargon_meaning"
description: str = (
"查询是否存在已知的jargon解释含meaning或translation若存在返回解释否则返回空字符串"
)
parameters: List[Tuple[str, ToolParamType, str, bool, None]] = [
("content", ToolParamType.STRING, "待查询的目标词汇(黑话/俚语/缩写)", True, None),
]
available_for_llm: bool = True
async def execute(self, function_args: Dict[str, Any]) -> Dict[str, str]:
if not self.chat_id:
# 和其它工具保持一致的返回结构
return {"name": self.name, "content": ""}
try:
content = str(function_args.get("content", "")).strip()
if not content:
return {"name": self.name, "content": ""}
# 优先在当前会话或global中查找该content且需要meaning或translation非空
# Peewee 条件:
# (content == 输入) AND ((chat_id == 当前chat) OR is_global) AND ((meaning非空) OR (translation非空))
candidates = (
Jargon.select()
.where(
(Jargon.content == content)
& ((Jargon.chat_id == self.chat_id) | Jargon.is_global)
& (
((Jargon.meaning.is_null(False)) & (Jargon.meaning != ""))
| ((Jargon.translation.is_null(False)) & (Jargon.translation != ""))
)
)
.limit(1)
)
if candidates.exists():
obj = candidates.get()
translation = (obj.translation or "").strip()
meaning = (obj.meaning or "").strip()
formatted = f"{content}可能为黑话或者网络简写,翻译为:{translation},含义为:{meaning}"
return {"name": self.name, "content": formatted}
# 未命中允许退化为全库搜索不限chat_id以提升命中率
fallback = (
Jargon.select()
.where(
(Jargon.content == content)
& (
((Jargon.meaning.is_null(False)) & (Jargon.meaning != ""))
| ((Jargon.translation.is_null(False)) & (Jargon.translation != ""))
)
)
.limit(1)
)
if fallback.exists():
obj = fallback.get()
translation = (obj.translation or "").strip()
meaning = (obj.meaning or "").strip()
formatted = f"{content}可能为黑话或者网络简写,翻译为:{translation},含义为:{meaning}"
return {"name": self.name, "content": formatted}
# 彻底未命中
return {"name": self.name, "content": ""}
except Exception as exc:
logger.error(f"查询jargon解释失败: {exc}", exc_info=True)
return {"name": self.name, "content": ""}

View File

@ -1,56 +0,0 @@
from typing import List, Tuple, Type
# 导入新插件系统
from src.plugin_system import BasePlugin, ComponentInfo, register_plugin
from src.plugin_system.base.config_types import ConfigField
# 导入依赖的系统组件
from src.common.logger import get_logger
from src.plugins.built_in.jargon.jargon_explanation import RecordJargonExplanationTool, LookupJargonMeaningTool
logger = get_logger("jargon_plugin")
@register_plugin
class JargonPlugin(BasePlugin):
"""Jargon插件
系统内置插件提供jargon相关的功能
- RecordJargonExplanation: 记录聊天中明确解释的jargon词义
- LookupJargonMeaning: 查询未知词是否已有解释
注意插件基本信息优先从_manifest.json文件中读取
"""
# 插件基本信息
plugin_name: str = "jargon" # 内部标识符
enable_plugin: bool = True
dependencies: list[str] = [] # 插件依赖列表
python_dependencies: list[str] = [] # Python包依赖列表
config_file_name: str = "config.toml"
# 配置节描述
config_section_descriptions = {
"plugin": "插件启用配置",
"components": "核心组件启用配置",
}
# 配置Schema定义
config_schema: dict = {
"plugin": {
"enabled": ConfigField(type=bool, default=True, description="是否启用插件"),
"config_version": ConfigField(type=str, default="1.0.0", description="配置文件版本"),
},
}
def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]:
"""返回插件包含的组件列表"""
# --- 根据配置注册组件 ---
components = []
components.append((RecordJargonExplanationTool.get_tool_info(), RecordJargonExplanationTool))
components.append((LookupJargonMeaningTool.get_tool_info(), LookupJargonMeaningTool))
return components