當前位置: 首頁>>代碼示例>>Python>>正文


Python watson_developer_cloud.ConversationV1方法代碼示例

本文整理匯總了Python中watson_developer_cloud.ConversationV1方法的典型用法代碼示例。如果您正苦於以下問題:Python watson_developer_cloud.ConversationV1方法的具體用法?Python watson_developer_cloud.ConversationV1怎麽用?Python watson_developer_cloud.ConversationV1使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在watson_developer_cloud的用法示例。


在下文中一共展示了watson_developer_cloud.ConversationV1方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import watson_developer_cloud [as 別名]
# 或者: from watson_developer_cloud import ConversationV1 [as 別名]
def __init__(self, sc, token):
        Config = ConfigParser.ConfigParser()
        Config.read("credentials.ini")
        self.name = Config.get('Slack_Creds', 'name')
        self.sc = sc
        self.messages_processed = 0
        self.slack_token = token
        self.me = self.name
        print slack.get_my_id(self.sc, self.me)
        self.at_bot = "<@" + slack.get_my_id(self.sc, self.me) + ">"
        print "AT " + self.name + ": " + self.at_bot
        self.whitelist = [self.name + "-private"]
         # set up conversation service
        self.conversation = ConversationV1(
            username= Config.get('Conversation_Creds', 'username'),
            password= Config.get('Conversation_Creds', 'password'),
            version= Config.get('Conversation_Creds', 'version'))
        self.conversation_workspace_id = Config.get('Conversation_Creds', 'workspace_id') 
開發者ID:IBM-Cloud,項目名稱:kube-samples,代碼行數:20,代碼來源:responses.py

示例2: run

# 需要導入模塊: import watson_developer_cloud [as 別名]
# 或者: from watson_developer_cloud import ConversationV1 [as 別名]
def run(message=None, context=None):
	conversation = ConversationV1(
		username='28f2a25a-38d1-4f3e-9d02-391bb41edbde',
		password='PEb7dCc2jGrB',
		version='2016-09-20'
	)

	# Replace with the context obtained from the initial request
	if context == None:
		context = {}
	else:
		d = ast.literal_eval(json.dumps(context))
		context = d

	workspace_id = 'f663996e-4c77-4b64-b188-5f10ebbbb27b'

	response = conversation.message(
		workspace_id=workspace_id,
		message_input={'text': message},
		context=context
	)

	# return(json.dumps(response, indent=2))
	return response 
開發者ID:ClassGotcha,項目名稱:ClassGotcha-Backend,代碼行數:26,代碼來源:Conversation.py

示例3: auto_add_comment_basedon_content

# 需要導入模塊: import watson_developer_cloud [as 別名]
# 或者: from watson_developer_cloud import ConversationV1 [as 別名]
def auto_add_comment_basedon_content(input, postid):
    # English version
    conversation = ConversationV1(
        username='69ff24f0-227c-4fbc-9609-5013aac22396',
        password='k2G2ghPqYu4p',
        version='2017-05-26')
    # replace with your own workspace_id
    workspace_id = 'd0841bcb-0861-482b-b87a-96f3f787bacc'

    response = conversation.message(workspace_id=workspace_id, message_input={
        'text': input})

    if len(response['intents']) > 0 and response['intents'][0]['intent'] == 'how_about_this':
        output = response['output']['text']
        entity_list = ['']
        if len(response['entities']) == 1:
            entity_location = response['entities'][0]['location']
            logging.info(entity_location)
            logging.info(type(entity_location[0]))
            entity = response['input']['text'][int(entity_location[0]):int(entity_location[1])]
            entity_list.append(entity)

        logging.info('***output of watson***: ' + output[0])
        user_id = 'operator'
        user_name = 'operator'

        post_id = postid
        post = Post.query.filter_by(id=post_id).first()
        content = random.choice(entity_list) + " "
        content += output[0] + " "
        if random.randint(0, 1):
            content += output[1]
        reply_to = ''
        comment = Comment(user_id, user_name, post_id, reply_to, content)
        post.comments.append(comment)
        db.session.add(comment)
        db.session.commit()
    else:
        logging.info("no intent found from watson") 
開發者ID:kun-qian,項目名稱:buyershow,代碼行數:41,代碼來源:__init__.py


注:本文中的watson_developer_cloud.ConversationV1方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。