Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/ask/__init__.py
Dianliang233 8b4ec1915b Rewrite to use a adapted ReAct model
The vanilla LangChain MKRL proves to be SUPER unreliable.
2023-04-05 16:18:04 +08:00

23 lines
810 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from core.dirty_check import check_bool
from core.builtins import Bot
from core.component import module
from .AkariAgent import agent_executor
from core.exceptions import NoReportException
a = module('ask', developers=['Dianliang233'], desc='{ask.help}', required_superuser=True)
@a.command('<question> {{ask.help.ask}}')
@a.regex(r'^(?:ask|问)[\:]? ?(.+?)[?]$', desc='{{ask.help.ask}}')
async def _(msg: Bot.MessageSession):
if hasattr(msg, 'parsed_msg'):
question = msg.parsed_msg['<question>']
else:
question = msg.matched_msg[0]
if await check_bool(question):
raise NoReportException('https://wdf.ink/6OUp')
res = agent_executor.run(question)
if await check_bool(res):
raise NoReportException('https://wdf.ink/6OUp')
await msg.finish(res)