示例#1
0
    def get(self, page_number, page_size):

        logging.debug('getting Data from DB')

        result = ConversationsModel.get_all_conversations(page_number, page_size)
        r.set("conversations", json.dumps(result), ex=GLOBAL_EXPIRY)

        return result
    def get(self):

        # check if result can be served from cache
        if r.exists("conversations"):
            return json.loads(r.get("conversations"))

        else:
            # Get results and update the cache with new values
            logging.debug('getting Data from DB')

            result = ConversationsModel.get_all_conversations()
            r.set("conversations", json.dumps(result), ex=GLOBAL_EXPIRY)

            return result
    def post(self):

        out_message = {}
        json_data = request.get_json(force=True)
        input_text = json_data['message']
        session_id = json_data['sessionId']

        responses = LoadModel.handle_text(input_text, session_id)

        result = ConversationsModel.get_conversations(session_id)

        if 'message' not in responses:
            out_message['tracker-store'] = result
            print('out_message', out_message)
            return out_message
        else:
            for response in responses:
                print("--------- BOT Response {}".format(response))
                response['tracker-store'] = result
                print('response', response)
                return response
    def get(self, conversation_id):

        result = ConversationsModel.get_conversations(conversation_id)
        return result
    ValidateData
from export import Export
from rasa.run import create_agent
import asyncio

# Set logger
logger = logging.getLogger('flask.app')
logging.basicConfig(level=logging.DEBUG)

# Init model classes

CustomActionsModel = CustomActionsModel()
ProjectsModel = ProjectsModel()
CopyProjectModel = CopyProjectModel()
DomainsModel = DomainsModel()
ConversationsModel = ConversationsModel()
RefreshDbModel = RefreshDbModel()
IntentsModel = IntentsModel()
IntentDetailModel = IntentDetailModel()
ResponseModel = ResponseModel()
ResponseDetailModel = ResponseDetailModel()
StoryDetailModel = StoryDetailModel()
StoryModel = StoryModel()
EntityModel = EntityModel()
ExportProjectModel = ExportProjectModel()
ImportProjectModel = ImportProjectModel()
Export = Export()

# Setting Expiry for redis cache

GLOBAL_EXPIRY = 60