コード例 #1
0
ファイル: test_chatbot.py プロジェクト: GenetH/HEAD
 def test_chat_agent(self):
     from chatbot.server.chatbot_agent import session_manager, ask
     sid = session_manager.start_session('test', test=True)
     sess = session_manager.get_session(sid)
     sess.sdata.botname = 'sophia'
     sess.sdata.user = '******'
     response, ret = ask('what is your name', 'en', sid)
     self.assertEqual(ret, 0)
     response, ret = ask('', 'en', sid)
     self.assertEqual(ret, 4)
     response, ret = ask(None, 'en', sid)
     self.assertEqual(ret, 4)
コード例 #2
0
ファイル: test_chatbot.py プロジェクト: hansonrobotics/HEAD
 def test_chat_agent(self):
     from chatbot.server.chatbot_agent import session_manager, ask
     sid = session_manager.start_session(user='******', key='key', test=True)
     sess = session_manager.get_session(sid)
     sess.sdata.botname = 'sophia'
     sess.sdata.user = '******'
     response, ret = ask('what is your name', 'en', sid)
     self.assertEqual(ret, 0)
     response, ret = ask('', 'en', sid)
     self.assertEqual(ret, 4)
     response, ret = ask(None, 'en', sid)
     self.assertEqual(ret, 4)
コード例 #3
0
ファイル: run_server.py プロジェクト: yenat/HEAD
def _chat():
    data = request.args
    question = data.get('question')
    session = data.get('session')
    lang = data.get('lang', 'en')
    response, ret = ask(question, lang, session)
    return Response(json_encode({'ret': ret, 'response': response}),
        mimetype="application/json")
コード例 #4
0
ファイル: run_server.py プロジェクト: GenetH/HEAD
def _chat():
    data = request.args
    question = data.get('question')
    session = data.get('session')
    lang = data.get('lang', 'en')
    response, ret = ask(question, lang, session)
    return Response(json_encode({
        'ret': ret,
        'response': response
    }),
                    mimetype="application/json")
コード例 #5
0
ファイル: run_server.py プロジェクト: linas/HEAD
def _chat():
    data = request.args
    question = data.get('question')
    session = data.get('session')
    lang = data.get('lang', 'en')
    query = data.get('query', 'false')
    query = query.lower() == 'true'
    request_id = request.headers.get('X-Request-Id')
    marker = data.get('marker', 'default')
    response, ret = ask(
        question, lang, session, query, request_id=request_id, marker=marker)
    return Response(json_encode({'ret': ret, 'response': response}),
                    mimetype="application/json")
コード例 #6
0
ファイル: run_server.py プロジェクト: temaled/HEAD
def _chat():
    data = request.args
    question = data.get('question')
    session = data.get('session')
    lang = data.get('lang', 'en')
    query = data.get('query', 'false')
    query = query.lower() == 'true'
    response, ret = ask(question, lang, session, query)
    return Response(json_encode({
        'ret': ret,
        'response': response
    }),
                    mimetype="application/json")
コード例 #7
0
def _chat():
    data = request.args
    question = data.get('question')
    session = data.get('session')
    lang = data.get('lang', 'en-US')
    query = data.get('query', 'false')
    query = query.lower() == 'true'
    request_id = request.headers.get('X-Request-Id')
    marker = data.get('marker', 'default')
    run_id = data.get('run_id', '')
    response, ret = ask(
        question, lang, session, query,
        request_id=request_id, marker=marker, run_id=run_id)
    return Response(json_encode({'ret': ret, 'response': response}),
                    mimetype="application/json")
コード例 #8
0
def _batch_chat():
    auth = request.form.get('Auth')
    if not auth or not check_auth(auth):
        return authenticate()

    questions = request.form.get('questions')
    questions = json.loads(questions)
    session = request.form.get('session')
    lang = request.form.get('lang', 'en-US')
    responses = []
    for idx, question in questions:
        response, ret = ask(str(question), lang, session)
        responses.append((idx, response, ret))
    return Response(json_encode({'ret': 0, 'response': responses}),
                    mimetype="application/json")
コード例 #9
0
ファイル: run_server.py プロジェクト: linas/HEAD
def _batch_chat():
    auth = request.form.get('Auth')
    if not auth or not check_auth(auth):
        return authenticate()

    questions = request.form.get('questions')
    questions = json.loads(questions)
    session = request.form.get('session')
    lang = request.form.get('lang', 'en')
    responses = []
    for idx, question in questions:
        response, ret = ask(str(question), lang, session)
        responses.append((idx, response, ret))
    return Response(json_encode({'ret': 0, 'response': responses}),
                    mimetype="application/json")
コード例 #10
0
def _chat():
    data = request.args
    question = data.get('question')
    session = data.get('session')
    lang = data.get('lang', 'en-US')
    query = data.get('query', 'false')
    query = query.lower() == 'true'
    request_id = request.headers.get('X-Request-Id')
    marker = data.get('marker', 'default')
    run_id = data.get('run_id', '')
    try:
        logger.warn("Chat request: %s", data)
        response = ask(question,
                       lang,
                       session,
                       query,
                       request_id=request_id,
                       marker=marker,
                       run_id=run_id)
    except Exception as ex:
        logger.exception(ex)
        raise ex
    return Response(response.toJSON(), mimetype="application/json")