gpt4 book ai didi

python-2.7 - 如何为wit.ai中的 'wit$location'等内置实体添加值

转载 作者:行者123 更新时间:2023-12-01 06:01:18 26 4
gpt4 key购买 nike

我曾尝试使用 API 服务:

response = requests.post('https://api.wit.ai/entities/wit$location/values?v=20160526', 
headers={'Authorization':'Bearer xxx'},
data=json.dumps({ "value":"London",
"expressions":["London"],
"metadata":"CITY_1234"}))

但我得到的回应是:
{'code': 'not-found',
'error': "Entity '535a80ff-6399-4653-8b2a-c770dd014965' not found"}

我很确定名为 wit$location 的实体存在。
response = requests.get('https://api.wit.ai/entities/wit$location?v=20160526', 
headers={'Authorization':'Bearer xxx'})

回应是:
{'builtin': True,
'doc': '{"spanless":false,"short_desc":"specific position or '
'address","long_desc":"Capture free text that\'s a typical location, '
'place or address like `350 Cambridge Ave Palo Alto`, `925 Alma '
'Street`, `SFO`, and `Sausalito, CA`.\\nUse wit/local_search_query for '
'local place like `my flower shopt` and '
'`Peet\'s`","examples":[{"expression":["meet me at","350 Cambridge Ave '
'Palo Alto","at noon"],"response":"\\"entities\\" : {\\n '
'\\"location\\" : [ {\\n \\"value\\" : \\"350 Cambridge Ave '
'Palo Alto\\"\\n } ]\\n '
'}","$$hashKey":"070"},{"expression":["go to","925 Alma '
'street",""],"response":"\\"entities\\" : {\\n \\"location\\" : [ '
'{\\n \\"value\\" : \\"925 Alma street\\"\\n } ]\\n '
'}","$$hashKey":"07Z"},{"expression":["i need a ride to","Sausalito, '
'CA",""],"response":"\\"entities\\" : {\\n \\"location\\" : [ '
'{\\n \\"value\\" : \\"Sausalito, CA\\"\\n } ]\\n '
'}","$$hashKey":"081"},{"expression":["I came '
'from","SFO","?"],"response":"\\"entities\\" : {\\n '
'\\"location\\" : [ {\\n \\"value\\" : \\"SFO\\"\\n } '
']\\n '
'}","$$hashKey":"083"}],"similar_wisps":[{"name":"wit/local_search_query","$$hashKey":"072"}]}',
'exotic': False,
'id': '535a80ff-6399-4653-8b2a-c770dd014965',
'lang': 'en',
'lookups': ['free-text'],
'name': 'location',
'values': []}

我希望能够为 wit$location 添加值实体。

最佳答案

据我所知,您无法编辑/添加到内置实体。原因是,也许您想在星球大战中添加所有城市,或者在您不知名的区域中添加所有城市,但其他人不希望它们弹出。

我的解决方法是添加一个名为“my_city”的实体,并将您特别想要识别的城市添加到该实体中。在您的代码中,您只需在检查位置时检查两个实体之一...

希望这会有所帮助,祝你好运!

关于python-2.7 - 如何为wit.ai中的 'wit$location'等内置实体添加值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45115719/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com