当前位置:   article > 正文

【智能交互】OPPO接入小布语音技能通关教程:个人开发者实现接口调用_小布智能语音助手api

小布智能语音助手api

在这里插入图片描述

前言

适用人群:本教程适合大赛接入小布语音技能的同学以及初次使用小布助手的开发者
本篇文章是博主弄了多次测试才勉强弄明白的,OPPO的开发文档和没有没啥区别
很多人会问:“为啥有更成熟的其他语音技能平台放着不用?”
答:“因为我在参加的比赛是由oppo主办方举办的,若要想进决赛,必须要接入OPPO开放平台”
所以,我为了冲一冲决赛,昨晚在喝了咖啡的加持下,硬是把代码逻辑弄明白了,文章分为两部分:猜想测试部分实际操作部分,请根据你的需要进行跳过选择


实际操作

由于部分注册图片博主未截图故采用站外的

注册OPPO平台账号

在这里插入图片描述

点我注册oppo开放平台账号,注册有两种资质选项:

在这里插入图片描述

  • 个人开发者:
    需要手持身份证认证
    权限没有URL(开发文档有,咨询后个人没有)
    有APP、卡片、文字等技能能力
  • 企业开发者:
    需要对公账户等
    全部都有

打开创建技能界面

注册成功后,在开放能力中找到并点击【小布语音技能】【发布技能】,如图所示:

在这里插入图片描述
博主这里没有条件认证企业,认证的是个人开发者,所以URL接口能力没有,但是后面发现是我没有仔细看,无论有没有URL接口能力,我们都可以通过代码来进行构造,请继续往下看

创建技能

在这里插入图片描述
说明:

名称说明
技能名称用于开发者标识且能识别的字符
技能调用名用于技能调用的名称,例如:小布小布,打开{云联印}

个人开发者,需要接口能力,请选择【代码编译


创建意图

点击创建意图,输入中英文意图名称,我们以==今天是多少号?==来进行意图说明,方便更直观的槽位解析
在这里插入图片描述
选中槽位解析后,找到下方输入框,将多种意图表达方式输入其中,进行解析,不要的可以进行删除

在这里插入图片描述

完成后,点击保存即可

槽位解析

在刚刚的意图创建中,我们对时间进行了一个提问,在小布技能助手这里开放日期查询接口,打开即可输出当前的日期
在这里插入图片描述

对话管理

对话管理,这里显示一个IDE窗口,我猜测他是获取用户说的话,这里有个奇怪的问题,这里开发文档并没有说,测试验证请看下面猜想测试部分
在这里插入图片描述

 args = request.get_json()["params"]["query"]
 print("=………===……===……………………… ")
 print(args)
  • 1
  • 2
  • 3

 args = request.get_json()["params"]
 print("=………===……===……………………… ")
 print(args["query"])
  • 1
  • 2
  • 3

返回竟然不相同?第二个报错?所以我建议还是按第一种方式来

对话测试

刚刚建立了“今天几号”的意图,在询问后会返回当前时间

“现在是几点”相关意图并未建立,所以找不到配置过的回复
在这里插入图片描述

接口代码编写

由于URL不对我们开放,所以我们需要自己编写python代码
在这里插入图片描述

接口创建

在后端新建一个接口

'''get_config.php'''
<?php

  die(
        json_encode(
            array(
            'code' => 200,
            'msg' => '请求成功',
            'data' => 'hahahahahah'
        ),480)
);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

新建一个python的requests get请求

import requests

url = "http://web.taila.club/get_config.php"

response = requests.get(url)

data = response.json()  # 如果返回的是JSON数据,则使用response.json()解析
print(data)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

整合封装到对话管理中去

#!/usr/bin/env python  
# -*- coding:utf-8 _*-
"""
     ____                                    _   ____    ____
   / __ )________  ___  ____  ____         / | / / /   / __ \
  / __  / ___/ _ \/ _ \/ __ \/ __ \       /  |/ / /   / /_/ /
 / /_/ / /  /  __/  __/ / / / /_/ /      / /|  / /___/ ____/
/_____/_/   \___/\___/_/ /_/\____/      /_/ |_/_____/_/

"""
from flask import request, jsonify
from flask import current_app
import requests


def main():
    # 获取 request 中相关参数
    args = request.get_json()["params"]
    #current_app.logger.info(f"\n\n输入参数:{args}")
    print("=………===……===……………………… ")
    url = "http://web.taila.club/get_config.php"

    response = requests.get(url)
	data = response.json()
    print(data)
    print(args)
    # 拼接返回结果
    

    # 返回 JSON Response
    #return args

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

这里很遗憾,在我做了测试后发现requests模块报错,看了文档《代码编辑-开发文档.pdf》才知道对方只支持:

1、flask ~= 1.0.4
2 、bjoern
3、 python-dateutil
4 、redis
5 、hiredis
6 、gevent
7、 xlrd
8、 pandas
9 、sentry-sdk[flask]
10、 scikit-learn

无奈,为了能参加比赛绞劲脑汁,我联系了平台开发者看能不能添加下这个库,这里暂时跳过,我们来对一些逻辑进行验证,使小布助手能够回答:

新建意图

在这里插入图片描述

对话管理

from flask import request, current_app, jsonify
data = {
     "文件": "正在发送[我的文件]到打印机",
      "消息": "已绑定账户",
    }

def main():
    args = request.get_json()["params"]
    nlu = args['nlu'][0]    # 获取nlu(意图分类)的结果
    current_app.logger.info(f"nlu 结果:\n{str(nlu)}\n")
    tts = "没有查询到相关结果"
    if nlu["intent_list"]:
        intent = nlu["intent_list"][0]
        intent_name = intent["intent_name"]# 获取
        if intent_name == "send":
            tts = data['文件']# 根据槽位值从数据中选择回复
        if intent_name == "add":
            tts = data['消息']# 根据槽位值从数据中选择回复
    text_card = {
    "type": "textCard",
    "title": "云联印+",
    "content": tts,
    "recommend": []
    }
     # 拼接返回结构体
    response = {
    "dialog_type": "completed", # 对话状态
    "response": text_card,
    "permanent_state": {}, # 永久存储 DS
    "dialog_state": {} # 临时 DS
    }
    current_app.logger.info(f"intent_name:\n{str(text_card)}\n")
     # 将文本卡片转换为 json 对象
    response = jsonify(response)
    return response
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

测试

【智能交互】OPPO接入小布语音技能通关教程

ps:这个仅仅能够使小布助手进行指定对话回复,并不能触发接口,为了完成比赛设计,这个是没有办法的办法了,演示的时候找一个人进行模拟即可伪造

猜想测试

通过打印args 发现,返回的竟是一个json数据
通过打印print("=………===……===……………………… ")来确定代码位置

 args = request.get_json()["params"]
 print("=………===……===……………………… ")
 print(args)
  • 1
  • 2
  • 3

通过模拟对话测试,看一下日志
在这里插入图片描述

===================================
Function: 759ab2f1-0bc2-4662-b7b6-8cb2f8502f08
Environment: python3
Namespace: python3
Pod: poolmgr-python3-python3-434009664-df7bbcb94-jhrhg
Container: python3
Node: 10.56.168.93
===================================
1
64
*** Starting uWSGI 2.0.20 (64bit) on [Tue Jul 18 11:26:34 2023] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-44) on 07 December 2022 02:08:23
os: Linux-3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019
nodename: poolmgr-python3-python3-434009664-df7bbcb94-jhrhg
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 40
current working directory: /app
detected binary path: /usr/local/python3/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 204800
your memory page size is 4096 bytes
detected max file descriptor number: 2000000
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:8888 fd 3
Python version: 3.7.4 (default, Dec 7 2022, 02:06:06) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Python main interpreter initialized at 0x285cac0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 731648 bytes (714 KB) for 64 cores
*** Operational MODE: threaded ***
WSGI app 0 (mountpoint=‘’) ready in 0 seconds on interpreter 0x285cac0 pid: 8 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 8, cores: 64)
[2023-07-18 14:11:52,547] [INFO] [fnId]= [TraceId]=8dc292ee5d210cab712789e441ec4eab [module]=server recieved specialize request, body: {‘filepath’: ‘/userfunc/deployarchive’, ‘functionName’: ‘user.main’, ‘mPodName’: ‘’, ‘parameters’: None, ‘url’: ‘’, ‘handler’: ‘user.main’, ‘fnId’: ‘759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘fnName’: ‘open-dialog-open.2016060-NEW’, ‘revisionId’: ‘rs-759ab2f1-0bc2-4662-b7b6-8cb2f8502f08-18’, ‘bsoCrdName’: ‘rs-759ab2f1-0bc2-4662-b7b6-8cb2f8502f08-18-up’, ‘bsoCrdNamespace’: ‘python3’, ‘bsoTriggerKey’: ‘trigger-serverless-rs-759ab2f1-0bc2-4662-b7b6-8cb2f8502f08-18’, ‘burrfishDomain’: ‘burrfish-trigger-service.burrfish.svc.uranus-prod001-prod.oke.oppo.local:8084’, ‘monitorReceiverUrl’: ‘metrics.ums.oppo.local/api/v2/metrics’, ‘fnNs’: ‘759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘podId’: ‘13010070-c9fe-4694-b40f-d20772a54421’, ‘podName’: ‘poolmgr-python3-python3-434009664-df7bbcb94-jhrhg’, ‘runtime’: ‘python3’, ‘concurrencyThresholds’: [0.55], ‘maxRequest’: 150, ‘specializePort’: 8888, ‘mqTrigger’: {‘metadata’: {‘creationTimestamp’: None}, ‘spec’: {‘fnId’: ‘’, ‘envns’: ‘’, ‘alias’: ‘’, ‘type’: ‘’, ‘clusterName’: ‘’, ‘clusterId’: ‘’, ‘mqUrl’: ‘’, ‘scaleFramework’: ‘’, ‘tag’: ‘’, ‘lagThreshold’: 0, ‘topic’: ‘’, ‘groupId’: ‘’, ‘respTopic’: ‘’, ‘errorTopic’: ‘’}, ‘status’: {‘status’: ‘’}}, ‘functionType’: ‘web’, ‘envVersion’: 3, ‘isAsync’: False, ‘specializeUrl’: ‘’, ‘bindLayerOrNot’: False, ‘layerRevisionId’: ‘’, ‘debugMode’: False}
[2023-07-18 14:11:52,547] [INFO] [fnId]= [TraceId]=8dc292ee5d210cab712789e441ec4eab [module]=server /v2/specialize called with filepath = “/userfunc/deployarchive” handler = “user.main”
[2023-07-18 14:11:52,547] [DEBUG] [fnId]= [TraceId]=8dc292ee5d210cab712789e441ec4eab [module]=server funcModuleName=“user” funcName=“main”
[2023-07-18 14:11:52,547] [DEBUG] [fnId]= [TraceId]=8dc292ee5d210cab712789e441ec4eab [module]=server package = “”
[2023-07-18 14:11:52,549] [DEBUG] [fnId]= [TraceId]=8dc292ee5d210cab712789e441ec4eab [module]=server specialize success…
[pid: 8|app: 0|req: 1/1] 127.0.0.1 () {36 vars in 548 bytes} [Tue Jul 18 14:11:52 2023] POST /v2/specialize => generated 0 bytes in 7 msecs (HTTP/1.1 200) 2 headers in 78 bytes (1 switches on core 61)
[2023-07-18 14:11:52,592] [DEBUG] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server Function call POST request received, {‘params’: {‘record_id’: ‘fceefcd0-2531-11ee-953e-13211fb1fdc4’, ‘user_id’: ‘df279e30-2524-11ee-953e-13211fb1fdc4’, ‘nlu’: [{‘intent_list’: [{‘match_confidence’: 0.99996, ‘intent_name’: ‘what_is_the_date_today’, ‘slot_list’: [{‘raw_value’: ‘今天’, ‘start’: 0, ‘end’: 2, ‘slot_name’: ‘DATE_TIME’, ‘value’: ‘{“indexArray”:“[0, 1]”,“value”:“[2023-07-18, ]”,“resultType”:“complete”,“key”:“今天”,“keyWord”:“今天”}’}]}], ‘domain_name’: ‘open.2016060’}], ‘query’: ‘打开云联印今天是几号?’, ‘dialog_state’: {}, ‘turn’: 1, ‘permanent_state’: {}}}
[2023-07-18 14:11:52,592] [INFO] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server Function req_context: {‘body’: {‘params’: {‘record_id’: ‘fceefcd0-2531-11ee-953e-13211fb1fdc4’, ‘user_id’: ‘df279e30-2524-11ee-953e-13211fb1fdc4’, ‘nlu’: [{‘intent_list’: [{‘match_confidence’: 0.99996, ‘intent_name’: ‘what_is_the_date_today’, ‘slot_list’: [{‘raw_value’: ‘今天’, ‘start’: 0, ‘end’: 2, ‘slot_name’: ‘DATE_TIME’, ‘value’: ‘{“indexArray”:“[0, 1]”,“value”:“[2023-07-18, ]”,“resultType”:“complete”,“key”:“今天”,“keyWord”:“今天”}’}]}], ‘domain_name’: ‘open.2016060’}], ‘query’: ‘打开云联印今天是几号?’, ‘dialog_state’: {}, ‘turn’: 1, ‘permanent_state’: {}}}, ‘queryString’: {}, ‘headers’: {‘Host’: ‘10.144.181.189:8888’, ‘User-Agent’: ‘Apache-HttpClient/4.5.2 (Java/1.8.0_252)’, ‘Content-Length’: ‘543’, ‘Accept-Encoding’: ‘gzip,deflate’, ‘Content-Type’: ‘application/json’, ‘Fc-Accesskey-Id’: ‘ee52ba67-285e-4059-b1b2-32cc4f18df32’, ‘Fc-Authorization’: ‘FC ee52ba67-285e-4059-b1b2-32cc4f18df32:0HB6Ex+1dGdI4oXpm578H5vUlJu4V6MkCd4Z8/8bdqk=’, ‘Fc-User-Id’: ‘80252515’, ‘Forwarded’: ‘host=serverless-api.cloud.oppo.local;’, ‘Level’: ‘1.10’, ‘Request-Receive-Time’: ‘1689660712515’, ‘T-Domain’: ‘serverless-api.cloud.oppo.local’, ‘T-Req-Ttl’: ‘60000’, ‘Traceid’: ‘16896607125150a9073f305781497365’, ‘X-B3-Sampled’: ‘0’, ‘X-B3-Spanid’: ‘62f5d24fb8aa0462’, ‘X-B3-Traceid’: ‘e2a21fcb0ab131d67d5c46468af009ac’, ‘X-Forwarded-For’: ‘10.90.214.184, 10.56.162.135’, ‘X-Forwarded-Host’: ‘serverless-api.cloud.oppo.local’, ‘X-Forwarded-Proto’: ‘http’, ‘X-Proto’: ‘HTTP’, ‘X-Real-Ip’: ‘10.90.214.184’, ‘X-Uranus-Full-Url’: ‘/uranus-function/759ab2f1-0bc2-4662-b7b6-8cb2f8502f08/759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘X-Uranus-Function-Name’: ‘759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘X-Uranus-Function-Namespace’: ‘759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘X-Uranus-Function-Resourceversion’: ‘747185962’, ‘X-Uranus-Function-Uid’: ‘19d33cd9-4e7f-4829-8a71-26b72d49e219’, ‘X-User-Ip’: ‘10.90.214.184’, ‘Connection’: ‘close’}}
[2023-07-18 14:11:52,592] [DEBUG] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server Start to call userfunc…
=………===……===………………………
{'record_id': 'fceefcd0-2531-11ee-953e-13211fb1fdc4', 'user_id': 'df279e30-2524-11ee-953e-13211fb1fdc4', 'nlu': [{'intent_list': [{'match_confidence': 0.99996, 'intent_name': 'what_is_the_date_today', 'slot_list': [{'raw_value': '今天', 'start': 0, 'end': 2, 'slot_name': 'DATE_TIME', 'value': '{"indexArray":"[0, 1]","value":"[2023-07-18, ]","resultType":"complete","key":"今天","keyWord":"今天"}'}]}], 'domain_name': 'open.2016060'}], 'query': '打开云联印今天是几号?', 'dialog_state': {}, 'turn': 1, 'permanent_state': {}}
[2023-07-18 14:11:52,592] [INFO] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server function call result: None
Exception on / [POST]
Traceback (most recent call last):
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 2077, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 1526, in full_dispatch_request
return self.finalize_request(rv)
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 1545, in finalize_request
response = self.make_response(rv)
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 1702, in make_response
f"The view function for {request.endpoint!r} did not"
TypeError: The view function for ‘f’ did not return a valid response. The function either returned None or ended without a return statement.
[pid: 8|app: 0|req: 2/2] 10.144.185.159 () {76 vars in 1559 bytes} [Tue Jul 18 14:11:52 2023] POST / => generated 265 bytes in 4 msecs (HTTP/1.1 500) 2 headers in 99 bytes (1 switches on core 62)
[2023-07-18 14:11:52,600] [DEBUG] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server Function call POST request received, {‘params’: {‘record_id’: ‘fceefcd0-2531-11ee-953e-13211fb1fdc4’, ‘user_id’: ‘df279e30-2524-11ee-953e-13211fb1fdc4’, ‘nlu’: [{‘intent_list’: [{‘match_confidence’: 0.99996, ‘intent_name’: ‘what_is_the_date_today’, ‘slot_list’: [{‘raw_value’: ‘今天’, ‘start’: 0, ‘end’: 2, ‘slot_name’: ‘DATE_TIME’, ‘value’: ‘{“indexArray”:“[0, 1]”,“value”:“[2023-07-18, ]”,“resultType”:“complete”,“key”:“今天”,“keyWord”:“今天”}’}]}], ‘domain_name’: ‘open.2016060’}], ‘query’: ‘打开云联印今天是几号?’, ‘dialog_state’: {}, ‘turn’: 1, ‘permanent_state’: {}}}
[2023-07-18 14:11:52,601] [INFO] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server Function req_context: {‘body’: {‘params’: {‘record_id’: ‘fceefcd0-2531-11ee-953e-13211fb1fdc4’, ‘user_id’: ‘df279e30-2524-11ee-953e-13211fb1fdc4’, ‘nlu’: [{‘intent_list’: [{‘match_confidence’: 0.99996, ‘intent_name’: ‘what_is_the_date_today’, ‘slot_list’: [{‘raw_value’: ‘今天’, ‘start’: 0, ‘end’: 2, ‘slot_name’: ‘DATE_TIME’, ‘value’: ‘{“indexArray”:“[0, 1]”,“value”:“[2023-07-18, ]”,“resultType”:“complete”,“key”:“今天”,“keyWord”:“今天”}’}]}], ‘domain_name’: ‘open.2016060’}], ‘query’: ‘打开云联印今天是几号?’, ‘dialog_state’: {}, ‘turn’: 1, ‘permanent_state’: {}}}, ‘queryString’: {}, ‘headers’: {‘Host’: ‘10.144.181.189:8888’, ‘User-Agent’: ‘Apache-HttpClient/4.5.2 (Java/1.8.0_252)’, ‘Content-Length’: ‘543’, ‘Accept-Encoding’: ‘gzip,deflate’, ‘Content-Type’: ‘application/json’, ‘Fc-Accesskey-Id’: ‘ee52ba67-285e-4059-b1b2-32cc4f18df32’, ‘Fc-Authorization’: ‘FC ee52ba67-285e-4059-b1b2-32cc4f18df32:0HB6Ex+1dGdI4oXpm578H5vUlJu4V6MkCd4Z8/8bdqk=’, ‘Fc-User-Id’: ‘80252515’, ‘Forwarded’: ‘host=serverless-api.cloud.oppo.local;’, ‘Level’: ‘1.10’, ‘Request-Receive-Time’: ‘1689660712515’, ‘T-Domain’: ‘serverless-api.cloud.oppo.local’, ‘T-Req-Ttl’: ‘60000’, ‘Traceid’: ‘16896607125150a9073f305781497365’, ‘X-B3-Sampled’: ‘0’, ‘X-B3-Spanid’: ‘8d78ca43b1dd583e’, ‘X-B3-Traceid’: ‘d76c9e1c481b9d224847f853bc9eeec3’, ‘X-Forwarded-For’: ‘10.90.214.184, 10.56.162.104’, ‘X-Forwarded-Host’: ‘serverless-api.cloud.oppo.local’, ‘X-Forwarded-Proto’: ‘http’, ‘X-Proto’: ‘HTTP’, ‘X-Real-Ip’: ‘10.90.214.184’, ‘X-Uranus-Full-Url’: ‘/uranus-function/759ab2f1-0bc2-4662-b7b6-8cb2f8502f08/759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘X-Uranus-Function-Name’: ‘759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘X-Uranus-Function-Namespace’: ‘759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘X-Uranus-Function-Resourceversion’: ‘747185962’, ‘X-Uranus-Function-Uid’: ‘19d33cd9-4e7f-4829-8a71-26b72d49e219’, ‘X-User-Ip’: ‘10.90.214.184’, ‘Connection’: ‘close’}}
[2023-07-18 14:11:52,601] [DEBUG] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server Start to call userfunc…
=………===……===………………………
{'record_id': 'fceefcd0-2531-11ee-953e-13211fb1fdc4', 'user_id': 'df279e30-2524-11ee-953e-13211fb1fdc4', 'nlu': [{'intent_list': [{'match_confidence': 0.99996, 'intent_name': 'what_is_the_date_today', 'slot_list': [{'raw_value': '今天', 'start': 0, 'end': 2, 'slot_name': 'DATE_TIME', 'value': '{"indexArray":"[0, 1]","value":"[2023-07-18, ]","resultType":"complete","key":"今天","keyWord":"今天"}'}]}], 'domain_name': 'open.2016060'}], 'query': '打开云联印今天是几号?', 'dialog_state': {}, 'turn': 1, 'permanent_state': {}}
[2023-07-18 14:11:52,601] [INFO] [fnId]=759ab2f1-0bc2-4662-b7b6-8cb2f8502f08 [TraceId]=16896607125150a9073f305781497365 [module]=server function call result: None
Exception on / [POST]
Traceback (most recent call last):
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 2077, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 1526, in full_dispatch_request
return self.finalize_request(rv)
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 1545, in finalize_request
response = self.make_response(rv)
File “/usr/local/python3/lib/python3.7/site-packages/flask/app.py”, line 1702, in make_response
f"The view function for {request.endpoint!r} did not"
TypeError: The view function for ‘f’ did not return a valid response. The function either returned None or ended without a return statement.
[pid: 8|app: 0|req: 3/3] 10.144.176.204 () {76 vars in 1559 bytes} [Tue Jul 18 14:11:52 2023] POST / => generated 265 bytes in 2 msecs (HTTP/1.1 500) 2 headers in 99 bytes (1 switches on core 63)
[2023-07-18 14:11:53,222] [INFO] [fnId]= [TraceId]= [module]=concurrency_algo 指标push线程启动…
[2023-07-18 14:11:56,243] [ERROR] [fnId]= [TraceId]= [module]=concurrency_algo 扩缩容指标推送失败 , url: http://metrics.ums.oppo.local/api/v2/metrics, reqBody: [{‘metric’: ‘function_runtime_active_request’, ‘instance’: ‘rs-759ab2f1-0bc2-4662-b7b6-8cb2f8502f08-18’, ‘value’: 0.0, ‘tags’: {‘category’: ‘FaaS’, ‘function_runtime_max_request’: ‘150’, ‘fnId’: ‘759ab2f1-0bc2-4662-b7b6-8cb2f8502f08’, ‘bsoCrdName’: ‘rs-759ab2f1-0bc2-4662-b7b6-8cb2f8502f08-18-up’, ‘bsoCrdNamespace’: ‘python3’, ‘bsoTriggerKey’: ‘trigger-serverless-rs-759ab2f1-0bc2-4662-b7b6-8cb2f8502f08-18’, ‘hostname’: ‘poolmgr-python3-python3-434009664-df7bbcb94-jhrhg’, ‘concurrencyThresholds’: ‘0.55’}, ‘timestamp’: 1689660713}], Err:HTTPConnectionPool(host=‘metrics.ums.oppo.local’, port=80): Max retries exceeded with url: /api/v2/metrics (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x7f5f846ca910>: Failed to establish a new connection: [Errno 110] Connection timed out’))

json处理后

{
	'record_id': 'fceefcd0-2531-11ee-953e-13211fb1fdc4',
	'user_id': 'df279e30-2524-11ee-953e-13211fb1fdc4',
	'nlu': [{
		'intent_list': [{
			'match_confidence': 0.99996,
			'intent_name': 'what_is_the_date_today',
			'slot_list': [{
				'raw_value': '今天',
				'start': 0,
				'end': 2,
				'slot_name': 'DATE_TIME',
				'value': '{"indexArray":"[0, 1]","value":"[2023-07-18, ]","resultType":"complete","key":"今天","keyWord":"今天"}'
			}]
		}],
		'domain_name': 'open.2016060'
	}],
	'query': '打开云联印今天是几号?',
	'dialog_state': {},
	'turn': 1,
	'permanent_state': {}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

数据都获取到了剩下的不用我教了吧


相关文档

小布技能平台《个人开发者使用手册》

小布技能平台《个人开发者开发文档》

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/121243?site
推荐阅读
相关标签
  

闽ICP备14008679号