afe007ca0b
* refactor: code structure for improved readability and maintainability * style: ruff format * Update packages/astrbot/commands/provider.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * Update packages/astrbot/commands/persona.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * Update packages/astrbot/commands/llm.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * Update packages/astrbot/commands/conversation.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * fix: improve error handling message formatting in key switching * fix: update LLM command to use safe get for provider settings * feat: implement ProcessLLMRequest class for handling LLM requests and persona injection --------- Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
21 lines
715 B
Python
21 lines
715 B
Python
import astrbot.api.star as star
|
|
from astrbot.api.event import AstrMessageEvent, MessageChain
|
|
|
|
|
|
class LLMCommands:
|
|
def __init__(self, context: star.Context):
|
|
self.context = context
|
|
|
|
async def llm(self, event: AstrMessageEvent):
|
|
"""开启/关闭 LLM"""
|
|
cfg = self.context.get_config(umo=event.unified_msg_origin)
|
|
enable = cfg["provider_settings"].get("enable", True)
|
|
if enable:
|
|
cfg["provider_settings"]["enable"] = False
|
|
status = "关闭"
|
|
else:
|
|
cfg["provider_settings"]["enable"] = True
|
|
status = "开启"
|
|
cfg.save_config()
|
|
await event.send(MessageChain().message(f"{status} LLM 聊天功能。"))
|