分享

图灵机器人( 智能回复微信)及(智能聊天)

 新用户79878317 2022-12-10 发布于河南

一、什么是图灵机器人?

1、 图灵机器人简介: 是中文语境下智能度最高的“机器人大脑”,是全球较为先进的机器人中文语言认知与计算平台,图灵机器人对中文语义理解准确率已达90%,可为智能化软硬件产品提供中文语义分析、自然语言对话、深度问答等人工智能技术服务
据了解,“图灵机器人”本身并非机器人,而是加载在机器人身上的类似于Siri的一整套语音语义系统。而在活动现场,多款安装了“图灵机器人”系统的机器人纷纷亮相。而装备了该系统的机器人已经能实现机器人足球赛和拳击赛等的动作。据介绍,接入了图灵机器人大脑机器人在联网的情况下可做到和人自如的对话,就像是真人一样。人机对话像人类一样顺畅是因为图灵机器人采用当前主流框架DeepQA深度问答、自然语言处理及语义分析等技术,从而保证了中文语义理解准确率高达90%以上,而图灵机器人自身的学习能力可让机器人每天以0.8%的速度在不断进步。

进入图灵官网注册账号,官网地址:http://www.

在这里插入图片描述
2、注册一个你自己的机器人,然后将获得apikey
在这里插入图片描述
3、图灵机器人更多使用用法见: 图灵机器人参考文档

二、帮你自动微信回复(Python版)

在这里插入图片描述
找了小伙伴测试一下:
在这里插入图片描述 在这里插入图片描述
源码:

import requests
import itchat

KEY = '********************'  # KEY为图灵机器人的api密钥,自己可以去官网申请


def get_response(msg):
    apiUrl = 'http://www./openapi/api'
    data = {
        'userid': 'wechat-robot',
        'key': KEY,
        'info': msg,
    }
    try:
        r = requests.post(apiUrl, data=data).json()
        return r.get('text')
    except:
        return


@itchat.msg_register(itchat.content.TEXT)
def tuling_reply(msg):
    defaultReply = 'I received: ' + msg['Text']
    reply = get_response(msg['Text'])
    return reply or defaultReply


itchat.auto_login(hotReload=True)
itchat.run()

源码参考:20行代码搭建聊天机器人

三、图灵机器人智能聊天(微信小程序版)

在这里插入图片描述
源码集合:
小程序的demo.wxml

<view class='top'>{{tittle}}</view>
 
<view class='que' >
<block wx:for='{{syas}}'  wx:for-item='item' wx:key='{{syas}}' >
<view class='con'>
  <view class='isay'>
  <view class='r-t'>
    <text>{{item.isay}}</text>
 </view>
 <view class='r-i'>
     <image src='{{headRight}}'></image>
</view>
  
  </view>
  <view class='robort'>
   <view class='l-i'>
    <image src='{{headLeft}}'></image>
    </view>
    <view class='l-t'>
    <text>{{item.robot}}</text>
    </view>
  </view>
</view>
</block>
</view>
<view class='send'>
 
  <view class='input' >
  <form bindsubmit='converSation'>
   <input type='text' class='text' placeholder='说点什么吧~' name='says'></input>
    <button class='btn' id='btn' form-type='submit'>发送</button>
    </form>
    <button class='btn-d' bindtap='delectChat' >清空</button>
  </view>
  
</view>

demo.wxss

.top{
  position: fixed;
  top: 0;
  height: 6vh;
  width: 100%;
  line-height: 40px;
  background-color: #ffffff;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  color:rgba(2, 2, 5, 0.87);
  box-shadow: 8px -2px 15px rgb(209, 204, 204)
 
}
 
.top-r{
  position: fixed;
  left: 15px;
  color: #7c22d6;
  font-size: 15px
}
.send{
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 12vh;
  line-height: 140px;
  background-color:#ffffff;
  text-align: center;
  box-shadow: 6px -2px 15px rgb(209, 204, 204)
 
}
.input{
  position: fixed;
  width: 100%;
 
  bottom: 10px;
  
 
 
}
.text{
  float: left;
  margin-left: 10px;
  width: 61%;
  height: 33px;
  border-radius:29px;
  font-size: 12px;
  background-color: rgb(239, 243, 243);
  text-align: center;
  color: #505050
  }
.btn{
  float:left;
  margin-left: 10px;
  height: 31px;
  width: 53px;
  background-color: rgba(17, 208, 192, 0.88);
  line-height: 31px;
font-size: 12px;
  color: #ffffff;
  cursor: pointer;
  border-radius:18px;
  box-shadow:3px 3px 12px -1px #968f96db;
}
.btn-d{
  float:left;
  margin-left: 8px;
  height: 31px;
  width: 52px;
  background-color: rgb(0, 0, 0);
  line-height: 31px;
  color: #fafafa;
  cursor: pointer;
  border-radius:18px;
  box-shadow:3px 3px 12px -1px #968f96db;
  font-size: 12px
}
 
.say{
  float: right;
  margin-right: 30px;
  width: 30px;
  height: 29px;
  font-size: 16px;
  font-weight: bold;
  line-height: 29px;
  color: #9f2dee;
  cursor: pointer;
  border-radius:7px;
 
}
 
 
.que{
  margin-top: 7vh;
 
  width: 98%;
  margin-left: 1%;
 line-height: 32px;
 margin-bottom: 13vh
 
 
}
 
.robort{
 
  width: 65%;
 
  margin-top: 0px
 
 
}
.robort image{
 margin-bottom: -60px;
  width: 30px;
  height: 30px;
  border-radius: 7px;
 
}
.robort text{
  margin-left: 4px;
  border-radius: 10px;
 font-size: 14px;
 color:  rgba(226, 19, 115, 0.788);
 margin-bottom: -32px;
 
 
}
.isay{
 
  margin-top: 5px
}
.isay image{
  float: right;
  margin-right: -86vw;
 width: 30px;
 height: 30px;
 border-radius: 7px;
 background: darkblue 
 
}
.isay text{
  margin-right: 5px;
  float: right;
  border-radius: 8px;
 font-size: 14px;
 
 color: rgba(136, 13, 194, 0.664);
 
 
 
}
.con{
  margin-top: 1%;
  margin-left: 1%;
  width: 98%;
 
  
}
.l-i{
 
  width: 30px;
}
.l-t{
  margin-top: 15px;
  margin-left: 35px;
 
  border-radius: 15px;
  
 
}
.r-i{
  width: 30px;
 
}
.r-t{
  
  float: right;
  margin-right: 41px;
 
  border-radius: 15px;
  
}

demo.js(注意:key='apikey'//这里填入你得到的图灵机器人的apikey

const app = getApp()
 
 
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    tittle: 'Let's Chat',
    syas: [{
        'robot': '我是XX,来跟我聊天吧!'
        
      }
    ],
    headLeft: 'https://ss0./70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=4139308026,2925331886&fm=26&gp=0.jpg',
    headRight: '',
 
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function() {
    let that = this
      wx.getUserInfo({
        success:function(e){
          let header = e.userInfo.avatarUrl
          that.setData({
            headRight:header
          })
        }
      })
 
  },
 
 
  converSation: function(e) {
    let that = this
    var obj = {},
   isay = e.detail.value.says,
     syas=that.data.syas,
    length = syas.length,
    key='apikey'//这里填入你得到的图灵机器人的apikey
    
    console.log(length)
    wx.request({
      url: 'http://www./openapi/api?key='+key+'&info='+isay,
      success:function(res){
        let tuling = res.data.text;
        obj.robot=tuling;
        obj.isay=isay;
        syas[length] = obj;
        that.setData({
          syas:syas
        })
    }})
    
   
  },
  delectChat:function(){
    let that = this
    that.setData({
      syas:[]
    })
  }
 
})

源码参考:微信小程序连接图灵API实现智能聊天(超级简单)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约