1
私はどの項目の株価も取得したいと思います。私は商品の価格を返す関数getPrice
を持っています。 wit ai
を使用しようとしています。 これは私が試みたものです。私は取得していますPythonでアクション関数wit apiを呼び出す
from wit import Wit
def getPrice(request):
#statements
return price
def send(request, response):
print request['text']
print('Sending to user...', response['text'])
actions = {
'send': send,
'getPrice':getPrice
}
client = Wit(access_token="<token>", actions=actions)
resp = client.message('what is the stock price of xyz')
print('Result: ' + str(resp))
と結果は次のとおりです。
Result: {
u 'entities': {
u 'search_query': [{
u 'suggested': True,
u 'confidence': 0.578445451443443,
u 'type': u 'value',
u 'value': u 'stock of xyz'
}],
u 'item': [{
u 'confidence': 0.9613219630126943,
u 'value': u 'xyz'
}]
},
u 'msg_id': u '5ac1a450-7c5d-3190-8666-5d88a1884f94',
u '_text': u 'what is the stock of xyz?'
}
私はボットが価格を表示したいです。このアクションをどのように呼び出すことができますか?
:リストインデックスは整数でなければなりません、ないも – HunterrJ
をstr'、'試し
をxyz'は結果ではありません。それは私が手に入れようとしている株式です。 – HunterrJ
申し訳ありませんが、リストではありませんでした。更新しました。 –