Exemple #1
0
def get_categories(token=False, start=0, offset=8):
    """Returns a list of categories, with a list bots in each of them"""
    return fetch_api(
        '/ui/botstore/per_category?startFrom={start}&pageSize={offset}',
        token=token,
        start=start,
        offset=offset)
Exemple #2
0
def post_import_ai(token, ai_data, aiid=''):
    """Creates a new AI instance based on provided JSON file"""
    return fetch_api('/ai/import',
                     token=token,
                     method='post',
                     json=ai_data,
                     timeout=config.API_LONG_POLLING)
Exemple #3
0
def post_chat(token, aiid, payload):
    """Send chat message"""
    return fetch_api('/ai/{aiid}/chat',
                     token=token,
                     aiid=aiid,
                     params=payload,
                     timeout=config.API_CHAT_TIMEOUT)
Exemple #4
0
def delete_intent(token, aiid, intent_name):
    """Delete an Intent"""
    return fetch_api('/intent/{aiid}?intent_name={intent_name}',
                     token=token,
                     aiid=aiid,
                     intent_name=intent_name,
                     method='delete')
Exemple #5
0
def post_intent_bulk(token, aiid, intents_file):
    """Save bulk intents in CSV format"""
    return fetch_api('/intents/{aiid}/csv',
                     token=token,
                     aiid=aiid,
                     files={'file': intents_file},
                     method='post')
Exemple #6
0
def post_context_reset(token, aiid, chatId):
    """Reset chat context"""
    return fetch_api('/ai/{aiid}/chat/reset?chatId={chatId}',
                     token=token,
                     aiid=aiid,
                     chatId=chatId,
                     method='post')
Exemple #7
0
def delete_entity(token, aiid, entity_name):
    """Delete an entity"""
    return fetch_api('/entity/{aiid}?entity_name={entity_name}',
                     aiid=aiid,
                     token=token,
                     entity_name=entity_name,
                     method='delete')
Exemple #8
0
def post_intent(payload, token, aiid):
    """Create or update an Intent"""
    return fetch_api('/intent/{aiid}',
                     token=token,
                     aiid=aiid,
                     json=payload,
                     method='post')
Exemple #9
0
def post_training(token, aiid, training_file):
    """Updates bot Training file"""
    return fetch_api('/ai/{aiid}/training?source_type=0',
                     token=token,
                     aiid=aiid,
                     files={'file': training_file},
                     method='post')
Exemple #10
0
def put_training_update(token, aiid):
    """Update AI training"""
    return fetch_api('/ai/{aiid}/training/update',
                     token=token,
                     aiid=aiid,
                     method='put',
                     timeout=config.API_LONG_POLLING)
Exemple #11
0
def delete_ai(token, aiid):
    """Deletes a particular AI"""
    return fetch_api('/ai/{aiid}',
                     token=token,
                     aiid=aiid,
                     method='delete',
                     timeout=config.API_LONG_POLLING)
Exemple #12
0
def post_handover_reset(token, aiid, chatId, target='ai'):
    """Reset handover status"""
    return fetch_api('/ai/{aiid}/chat/target?chatId={chatId}&target={target}',
                     token=token,
                     aiid=aiid,
                     chatId=chatId,
                     target=target,
                     method='post')
Exemple #13
0
def post_entity(payload, token, aiid, **kwargs):
    """Create an entity for an AI"""
    return fetch_api('/entity/{aiid}?entity_name={entity_name}',
                     token=token,
                     aiid=aiid,
                     entity_name=payload.get('entity_name'),
                     json=payload,
                     method='post')
Exemple #14
0
def put_entity(payload, entity_name, token, aiid):
    """Updates an entity"""
    return fetch_api('/entity/{aiid}?entity_name={entity_name}',
                     token=token,
                     aiid=aiid,
                     json=payload,
                     entity_name=entity_name,
                     method='put')
Exemple #15
0
def post_facebook_customisations(token, aiid, payload):
    """save customisations for the page"""
    return fetch_api('/ai/{aiid}/facebook/custom',
                     token=token,
                     aiid=aiid,
                     json=payload,
                     timeout=config.API_FACEBOOK_TIMEOUT,
                     method='post')
Exemple #16
0
def put_intent(payload, intent_name, token, aiid):
    """Updates an Intent"""
    return fetch_api('/intent/{aiid}/{intent_name}',
                     token=token,
                     aiid=aiid,
                     json=payload,
                     intent_name=intent_name,
                     method='put')
Exemple #17
0
def put_facebook_action(token, aiid, params):
    """take some action on the facebook connection"""
    return fetch_api('/ai/{aiid}/facebook?{query_string}',
                     token=token,
                     aiid=aiid,
                     query_string=urllib.parse.urlencode(params),
                     timeout=config.API_FACEBOOK_TIMEOUT,
                     method='put')
Exemple #18
0
def post_info(token, dev_id, info_data):
    """Save developer info"""
    return fetch_api(
        '/developer/{dev_id}',
        token=token,
        dev_id=dev_id,
        data=info_data,
        method='post'
    )
Exemple #19
0
def get_bots(category, token=False, start=0, offset=24):
    """Returns a list of bots, filtered by category"""
    return fetch_api(
        '/ui/botstore?filter={filter}&startFrom={start}&pageSize={offset}',
        token=token,
        filter=urllib.parse.quote_plus(
            'category=\'{category}\''.format(category=category)),
        start=start,
        offset=offset)
Exemple #20
0
def get_insights_chatlogs(token, aiid, fromDate, toDate):
    """Gets chat logs for the specified dates"""
    return fetch_api(
        '/insights/{aiid}/chatlogs?format=csv&from={fromDate}&to={toDate}',
        token=token,
        aiid=aiid,
        fromDate=fromDate,
        toDate=toDate,
        timeout=config.API_LOGS_TIMEOUT,
        raw=True)
Exemple #21
0
def post_ai_skill(token, aiid, skills_data):
    """Updates skills linked with an AI"""
    return fetch_api(
        '/ai/{aiid}/bots?bot_list={bot_list}',
        token=token,
        aiid=aiid,
        bot_list=','.join(skills_data['skills']),
        method='post',
        headers={'Content-type': 'application/json'},
    )
Exemple #22
0
def get_insights_chart(token, aiid, metric, fromDate, toDate):
    """get chart data for the specified dates"""
    return fetch_api(
        '/insights/{aiid}/graph/{metric}?from={fromDate}&to={toDate}',
        token=token,
        aiid=aiid,
        metric=metric,
        fromDate=fromDate,
        toDate=toDate,
        timeout=config.API_LOGS_TIMEOUT,
    )
Exemple #23
0
def post_facebook_connect_token(token, aiid, payload):
    """
        Registers a connect token once the user has completed a
        connect operation on the front-end
    """
    return fetch_api('/ai/{aiid}/facebook/connect',
                     token=token,
                     aiid=aiid,
                     json=payload,
                     timeout=config.API_FACEBOOK_TIMEOUT,
                     method='post')
Exemple #24
0
def post_bot(token, aiid, bot_data):
    """Publish a bot"""
    defaults = {
        'publishing_type': 1,
        'aiid': aiid,
    }

    return fetch_api('/botstore',
                     token=token,
                     data={
                         **defaults,
                         **bot_data
                     },
                     method='post')
Exemple #25
0
def post_ai(token, ai_data, aiid=''):
    """Creates or updates an AI instance"""
    ai_default = {
        'voice': 1,
        'is_private': False,
        'personality': 0,
        'confidence': 0.3,
        'locale': 'en-US'
    }

    return fetch_api('/ai/{aiid}',
                     token=token,
                     aiid=aiid,
                     method='post',
                     data={
                         **ai_default,
                         **ai_data
                     })
Exemple #26
0
def post_clone_ai(token, ai_data, aiid=''):
    """Creates or updates an AI instance"""
    ai_default = {
        'voice': 1,
        'is_private': False,
        'personality': 0,
        'confidence': 0.4,
        'locale': 'en-US'
    }

    # Monkey patching API request details:
    # https://hutoma.visualstudio.com/Hutoma%20API/_workitems/edit/5649
    ai_data['default_responses'] = ai_data.get('default_chat_responses')

    return fetch_api('/ai/{aiid}/clone',
                     token=token,
                     aiid=aiid,
                     method='post',
                     data={
                         **ai_default,
                         **ai_data
                     })
Exemple #27
0
def get_intent(token, aiid, intent_name):
    """Returns a particular intent data"""
    return fetch_api('/intent/{aiid}?intent_name={intent_name}',
                     token=token,
                     aiid=aiid,
                     intent_name=intent_name)
Exemple #28
0
def get_intent_list(token, aiid):
    """Returns a list of all intents for a particular AI"""
    return fetch_api('/intents/{aiid}', token=token, aiid=aiid)
Exemple #29
0
def get_experiments_list(token, aiid, feature_name):
    """Get all the experiments toggled for a single AI"""
    return fetch_api('/experiment/{aiid}?feature={feature_name}',
                     token=token,
                     aiid=aiid,
                     feature_name=feature_name)
Exemple #30
0
def get_entity(token, aiid, entity_name):
    """Returns a particular entity data"""
    return fetch_api('/entity/{aiid}?entity_name={entity_name}',
                     token=token,
                     aiid=aiid,
                     entity_name=entity_name)