Beispiel #1
0
 def get_initial(self):
     """Returns the initial data to use for forms on this view."""
     initial = super(SkillsView, self).get_initial()
     ai = get_ai(self.request.session.get('token', False),
                 self.kwargs['aiid'])
     initial = {'skills': ai['linked_bots']}
     return initial
Beispiel #2
0
    def get_initial(self):
        """Returns the initial data to use for forms on this view."""

        initial = super(PublishView, self).get_initial()
        initial = get_ai(self.request.session.get('token', False),
                         self.kwargs['aiid'])
        return initial
Beispiel #3
0
    def get(self, request, aiid, *args, **kwargs):
        ai = get_ai(self.request.session.get('token', False), aiid)

        if ai['training']['status'] == 'error':
            template = loader.get_template('messages/retrain_error.html')
            ai['training']['message'] = template.render({'aiid': aiid})

        return JsonResponse(ai, status=ai['status']['code'])
Beispiel #4
0
    def get_initial(self):
        """Returns the initial data to use for forms on this view."""

        initial = super(AIUpdateView, self).get_initial()
        initial = get_ai(self.request.session.get('token', False),
                         self.kwargs['aiid'])
        initial['default_chat_responses'] = settings.TOKENFIELD_DELIMITER.join(
            initial['default_chat_responses'])

        initial['handover_reset_timeout_seconds'] = int(
            initial['handover_reset_timeout_seconds'] / 60)
        return initial
Beispiel #5
0
    def get_initial(self, **kwargs):
        # Get AI data
        ai = get_ai(self.request.session.get('token', False),
                    self.kwargs['aiid'])

        ai['name'] = 'Copy of {name}'.format(name=ai['name'])
        ai['default_chat_responses'] = settings.TOKENFIELD_DELIMITER.join(
            ai['default_chat_responses'])

        self.initial = ai

        return super(AICloneView, self).get_initial(**kwargs)
Beispiel #6
0
    def get_context_data(self, **kwargs):
        """Get AI information for studio navigation and training progress"""

        context = super(StudioViewMixin, self).get_context_data(**kwargs)
        context['ai'] = get_ai(self.request.session.get('token', False),
                               self.kwargs['aiid'])
        context['ai_details'] = get_ai_details(
            self.request.session.get('token', False), self.kwargs['aiid'])
        context['chatable'] = bool(context['ai_details']['training_file']
                                   or context['ai_details']['skills']
                                   or context['ai_details']['intents'])

        if not context['chatable']:
            messages.info(
                self.request,
                _('To start chatting with your bot '
                  'either upload a training file, add a '
                  'skill, or add an intent.'))

        return context
Beispiel #7
0
    def get_context_data(self, **kwargs):
        """Get AI information for studio navigation and training progress"""

        context = super(StudioViewMixin, self).get_context_data(**kwargs)
        context['ai'] = get_ai(self.request.session.get('token', False),
                               self.kwargs['aiid'])
        context['ai_details'] = get_ai_details(
            self.request.session.get('token', False), self.kwargs['aiid'])
        context['chatable'] = context['ai']['can_chat']
        context['show_kb'] = get_experiments_list(
            self.request.session.get('token', False),
            self.kwargs.get('aiid', False), 'show_knowledge_base').get('state')

        if not context['chatable']:
            messages.info(
                self.request,
                _('To start chatting with your bot '
                  'either upload a training file, add a '
                  'skill, or add an intent.'))

        return context