问题描述
我想知道是否可以使用Watson Python SDK在特定时间段内提取Watson对话日志?还有办法避免在日志末尾添加分页吗?我想提取给定时间段内的所有日志.以下是我当前使用的代码,用于提取特定工作区的日志:
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)
推荐答案
如您在官方文档,您可以使用filter
参数列出日志并使用很多选项.
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/string
一个可缓存的参数,将结果限制为与指定过滤器匹配的结果.有关更多信息,请参阅过滤查询参考.
Filter: filter/string
A cacheable parameter that limits the results to those matching the specified filter. For more information, see Filter query reference.
response_timestamp<2016-11-01T04:00:00.000Z
因此,您需要替换为response_timestamp
:
list_logs(workspace_id, sort=None, filter=paste here, page_limit=None, cursor=None)
- 使用详细了解过滤器参数日志-Watson对话.
- 有关使用Python的日志,请参见官方API参考关于.
- See more about the filter parameter using Logs - Watson Conversation.
- See the Official API Reference about Logs using Python.
这篇关于Watson会话日志(按日期)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!