mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-10 07:46:02 +00:00
refactor: 重构openai包基础组件架构
This commit is contained in:
38
pkg/pipeline/process/process.py
Normal file
38
pkg/pipeline/process/process.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ...core import app, entities as core_entities
|
||||
from . import handler
|
||||
from .handlers import chat, command
|
||||
from .. import entities
|
||||
from .. import stage, entities, stagemgr
|
||||
from ...core import entities as core_entities
|
||||
from ...config import manager as cfg_mgr
|
||||
|
||||
|
||||
@stage.stage_class("MessageProcessor")
|
||||
class Processor(stage.PipelineStage):
|
||||
|
||||
cmd_handler: handler.MessageHandler
|
||||
|
||||
chat_handler: handler.MessageHandler
|
||||
|
||||
async def initialize(self):
|
||||
self.cmd_handler = command.CommandHandler(self.ap)
|
||||
self.chat_handler = chat.ChatMessageHandler(self.ap)
|
||||
|
||||
await self.cmd_handler.initialize()
|
||||
await self.chat_handler.initialize()
|
||||
|
||||
async def process(
|
||||
self,
|
||||
query: core_entities.Query,
|
||||
stage_inst_name: str,
|
||||
) -> entities.StageProcessResult:
|
||||
"""处理
|
||||
"""
|
||||
message_text = str(query.message_chain).strip()
|
||||
|
||||
if message_text.startswith('!') or message_text.startswith('!'):
|
||||
return self.cmd_handler.handle(query)
|
||||
else:
|
||||
return self.chat_handler.handle(query)
|
||||
Reference in New Issue
Block a user