Watson Conversation Logs by Date

天涯浪子 提交于 2019-12-11 07:35:20

问题


I wanted to know if there is a way to pull Watson conversation logs for a specific time period using Watson Python SDK? Also is there a way to avoid the pagination added at the end of the logs? I want to pull all the logs for a given time period. Below is the code I am currently using which pulls logs for a specific workspace:

import json
import watson_developer_cloud

conversation = watson_developer_cloud.ConversationV1(
    username='xxxxxxxxxx',
    password- 'xxxxxxxx',
    version='2017-05-26'
)

response = conversation.list_logs(
    workspace_id = 'xxxxxxx'
)

js = json.dumps(response,indent=2)

with open('data.txt', 'w') as outfile:
    json.dump(response, outfile)

回答1:


As you can see on the Official documentation, you can use the filter parameter to list logs and have a lot of options to use.

Filter: filter/string A cacheable parameter that limits the results to those matching the specified filter. For more information, see Filter query reference.

The timestamp of the response is earlier than 2016-11-01T04:00:00.000Z.

response_timestamp<2016-11-01T04:00:00.000Z

So you need to replace with your response_timestamp:

list_logs(workspace_id, sort=None, filter=paste here, page_limit=None, cursor=None)
  • See more about the filter parameter using Logs - Watson Conversation.
  • See the Official API Reference about Logs using Python.


来源:https://stackoverflow.com/questions/48648791/watson-conversation-logs-by-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!