123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from abc import ABCMeta, abstractmethod
- class Msg(object):
- def __init__(self, **kwargs):
- self.code = kwargs.get("code")
- self.question = kwargs.get("question")
- self.option = kwargs.get("option")
- self.asr = kwargs.get("asr")
- self.session = kwargs.get("session")
- self.record = kwargs.get("record")
- # event = kwargs.get("event")
- self.interruptable = kwargs.get("interruptable")
- self.wait_time = kwargs.get("wait_time")
- self.action = kwargs.get("action")
- self.talk_time = kwargs.get("talk_time")
- self.inputType = kwargs.get("inputType")
- class Scene(metaclass=ABCMeta):
- """
- 会话场景基类
- """
- @abstractmethod
- def dialogue(self, msg, bid, uid, session_id) -> Msg:
- """
- @param msg: 消息
- @param bid: 机器人id
- @param uid: 用户id
- @param session_id: 对话id
- @return:
- """
- pass
- class Kernel(metaclass=ABCMeta):
- """
- 会话场景驱动类,每个场景都有内部驱动逻辑
- """
- @abstractmethod
- def next(self, bot_id, uid, session_id):
- """
- 获取下一个数据
- """
- pass
- @abstractmethod
- def parse(self, msg, bot_id, uid, session_id) -> None:
- """
- 解析获取到的数据
- """
- pass
|