前言

自从chatgpt火了之后,一直想把智障的天猫精灵对接个chatgpt,奈何天猫精灵不提供接口,终于在github上找到大佬做的小爱同学对接chatgpt的教程,于是根据他的原理,也搞出了个简陋的版本

成功展示

开发中遇到的问题

1.获取天猫精灵的对话记录,卡了我好几天,采取的frida远程调用,参数都对,就检验不通过,原来是转义字符的问题,还有没注意到变量重复赋值。

2.天猫的接口文档自我感觉也是一套糊涂,写的很粗糙。可能我能力不够吧。

3.chatgpt用的都是镜像站,一不注意,免费的就收费了,引流太严重啊。

部分代码展示

# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import asyncio
import sysfrom alibabacloud_aligenieiap_1_0.client import Client as AliGenieiap_1_0Client
from alibabacloud_aligenieiap_1_0.models import PushNotificationsRequestNotificationUnicastRequest, \PushNotificationsRequestTenantInfo, PushNotificationsRequestNotificationUnicastRequestSendTarget
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_aligenieiap_1_0 import models as ali_genieiap__1__0_models
import requests
import json
from urllib import parse
import frida
import time
import datetimelast_timestamp = int(time.time())class Aligenie:@staticmethoddef create_client(access_key_id: str,access_key_secret: str,) -> AliGenieiap_1_0Client:"""使用AK&SK初始化账号Client@param access_key_id:@param access_key_secret:@return: Client@throws Exception"""config = open_api_models.Config(# 您的AccessKey ID,access_key_id=access_key_id,# 您的AccessKey Secret,access_key_secret=access_key_secret)# 访问的域名config.endpoint = 'openapi.aligenie.com'return AliGenieiap_1_0Client(config)@staticmethoddef push_message(content):client = Aligenie.create_client('access_key_id', 'access_key_secret')notificationUnicastRequest = PushNotificationsRequestNotificationUnicastRequest()notificationUnicastRequest.encode_key = "98223"notificationUnicastRequest.encode_type = "SKILL_ID"notificationUnicastRequest.organization_id = "1398082853812549793"place_holder = {'content': content}notificationUnicastRequest.place_holder = place_holdernotificationUnicastRequest.message_template_id = "2DPRcMi97Qiwofsj"notificationUnicastRequest.is_debug = TruerequestSendTarget = PushNotificationsRequestNotificationUnicastRequestSendTarget()requestSendTarget.target_type = 'DEVICE_OPEN_ID'requestSendTarget.target_identity = 'JqyRCF91nuWRCTdk5dbOKVjRWMRBzL2jjI+xkIG3U2gLVoH5nvRw9w=='notificationUnicastRequest.send_target = requestSendTargetrequestTenantInfo = PushNotificationsRequestTenantInfo()push_notifications_request = ali_genieiap__1__0_models.PushNotificationsRequest(notificationUnicastRequest,requestTenantInfo)try:response = client.push_notifications(push_notifications_request)print(response)except Exception as err:print(err)class Chat:@staticmethoddef one(content):#换成自己的chatgpt或者自己找免费的接口pass@staticmethoddef two(content):#换成自己的chatgpt或者自己找免费的接口passclass AliGenieFrida:def __init__(self):self.last_timestamp = int(time.time())def get_frida_rpc_script(self):js = open('tmjl.js', 'r', encoding='utf-8').read()session = frida.get_usb_device().attach("com.alibaba.ailabs.tg")script = session.create_script(js)script.load()return scriptdef get_data(self):for _ in range(2):try:#换成抓包的datadata = '{"limit":"10","uuid":"uuid","deviceInfo":"{' \'\\"bizGroup\\":\\"X1\\",' \'\\"bizType\\":\\"AILABS\\",\\"botId\\":10,' \'\\"uuid\\":\\"uuid\\"}",' \'"authInfo":"{\\"accessToken\\":\\"2zyAfPN+bJdMzh5dUtiWqDtLLL/KnlYJCjsMujjz' \'+xYeTwqhbS2JvHGWAg7K' \'+nTyip' \'/vBXf83wZXe+wBdmHUWqs8OhxFYToW\\",\\"deviceIds\\":[],\\"isAuthenticated\\":false,' \'\\"isNew\\":true,' \'\\"isTempUser\\":false,\\"userId\\":\\"userId\\",' \'\\"utdId\\":\\"ZGOM/fF/pVkDADEloBB6B5tx\\"}"}'api = 'mtop.alibaba.aicloud.index.listsentences'appKey = '23904773'timestamp = str(int(time.time()))res = json.loads(self.get_frida_rpc_script().exports.callgetsign(data, timestamp, api, appKey))res['timestamp'] = timestampres['x-sgext'] = parse.quote(res['x-sgext'])res['x-mini-wua'] = parse.quote(res['x-mini-wua'])res['x-sign'] = parse.quote(res['x-sign'])res['x-t'] = parse.quote(res['timestamp'])requests.get("http://43.142.90.87:8610/rs?key=sign&vaule=" + json.dumps(res) + "&time_out=100")# print("调用frida获取", res)headers = {'x-sid': 'sid','x-uid': 'uid','x-nettype': 'WIFI','x-pv': '6.3','x-nq': 'WIFI','x-features': '27','x-app-conf-v': '0','content-type': 'application/x-www-form-urlencoded;charset=UTF-8','cache-control': 'no-cache','x-t': '1684334633','x-bx-version': '6.5.24','f-refer': 'mtop','x-extdata': 'openappkey%3DDEFAULT_AUTH','x-ttid': '702008%40genieapp_android_6.0.1','x-app-ver': '6.0.1','x-c-traceid': 'ZGOM%2FfF%2FpVkDADEloBB6B5tx1684334633416073015885','x-umt': 'GI8Bdk5LPPgZIwKIJIE1O6HP%2F11f01e2','x-utdid': 'ZGOM%2FfF%2FpVkDADEloBB6B5tx','x-appkey': '23904773','x-devid': 'Amqv8wxkiFMLQwGHcw6DOrRUeg7B3s693f8iah0kXC6E','user-agent': 'MTOPSDK%2F3.1.1.7+%28Android%3B8.1.0%3BGoogle%3BPixel%29','Host': 'acs.m.taobao.com',}headers['x-sgext'] = res['x-sgext']headers['x-mini-wua'] = res['x-mini-wua']headers['x-sign'] = res['x-sign']headers['x-t'] = res['timestamp']params = {'data': data,}response = requests.get('https://acs.m.taobao.com/gw/mtop.alibaba.aicloud.index.listsentences/1.0/',params=params,headers=headers,).json()# print(response)for _ in response['data']['model']:if _['query'] != '' and _['cateName'] == '百科':return _return response['data']['model'][0]except Exception as e:print(e)async def print_every_two_seconds():while True:aliGenieFrida = AliGenieFrida()qa = aliGenieFrida.get_data()query = qa['query']reply = qa['reply']queryTime = qa['queryTime']last = int(time.mktime(datetime.datetime.strptime(queryTime, '%Y-%m-%d %H:%M:%S.%f').timetuple()))global last_timestampprint(last_timestamp, query, last)if query != '' and last > last_timestamp:last_timestamp = lastcontent = Chat.two(query)print(f"问题:{query},天猫精灵的回答:{reply},chat的回答:{content}")Aligenie.push_message(content)await asyncio.sleep(2)async def main():task = asyncio.create_task(print_every_two_seconds())await taskif __name__ == '__main__':asyncio.run(main())

给天猫精灵赋予chatgpt相关推荐

  1. 阿里AI解锁车场景:达摩院技术输出,天猫精灵进驻奔驰、奥迪和沃尔沃

    李根 发自 大山子  量子位 报道 | 公众号 QbitAI 阿里AI今日又解锁了新场景,首次进入车空间. 首批合作伙伴也来头不小:奔驰.奥迪和沃尔沃.今年6月开始,奔驰.沃尔沃相关的车中,就会集成阿 ...

  2. AI测试|天猫精灵智能音箱测试策略与方法

    一.业务介绍 2014年11月,亚马逊推出了一款全新概念的智能音箱:Echo,这款产品最大的亮点是将智能语音交互技术植入到传统音箱中,从而赋予了音箱人工智能的属性.这个被称为"Alexa&q ...

  3. java对接天猫精灵语音助手实现对公司其下的智能设备进行控制(附上源码)

    java对接天猫精灵语音助手实现对公司其下的智能设备进行控制 前言当初刚来广州 公司上一任java已经离职半年 ,项目已经跑不动了,才招人的,所以我获得的是一个连跑都跑不起来的项目源码并且对项目一无所 ...

  4. 转:阿里智能音箱天猫精灵发布,联发科成了背后大赢家

    原文网址:http://www.icsmart.cn/12719/ 上周五,芯智讯写了一篇题为<AI智能音箱市场火爆,阿里巴巴开始进场收割!>的文章.在看今天这篇文章之前,建议大家再去看下 ...

  5. 【TB-02模组专题②】学习如何对接天猫精灵语音控制的过程;

    本<安信可ble mesh蓝牙模组TB-02模组专题>系列博客学习由官方博客 CSDN安信可博客 潜心所力所写.如有不对之处,请留言,我们及时更改. 1.BLE MESH开发环境linux ...

  6. 天猫精灵java开发工程师工资_李双印-天猫精灵2020年校招(对话系统方向)

    帮转: 天猫精灵是阿里巴巴打造的人工智能语音助手,目前排名国内第一,世界第三,是全球最大的中文人工智能助手,我们团队负责天猫精灵的基础语音交互体验,包括自然语言理解.语音语义一体化.多轮对话.多模态人 ...

  7. Telink ble mesh天猫精灵应用

    文章目录 1 前言 2 完美对接天猫精灵平台 2.1 创建新产品 2.1.1 添加产品类型 2.1.2 添加产品信息 2.1.3 添加产品功能 2.2 设置人机交互 2.2.1 设置控制口令 2.2. ...

  8. 名派照明连接天猫精灵_统一的动态精灵照明

    名派照明连接天猫精灵 Sprites in Daedalus make use of Unity's lighting system to appear with 3D-like properties ...

  9. 阿里AI labs发布两大天猫精灵新品,将与平头哥共同定制智能语音芯片

    作者 | 夕颜 出品 | AI科技大本营(ID:rgznai100) 2019 年,去年刮起的一阵智能音箱热浪似乎稍微冷却下来,新产品不再像雨后春笋一样层出不穷,挺过市场洗礼的产品更是凤毛麟角,这些产 ...

最新文章

  1. Python opencv 获取图像形状大小
  2. 解决浏览器下载excel文件时显示“文件已损坏”
  3. 两条线段的夹角 cesium_《原本》命题1.10 一条线段可以被分成两条相等的线段
  4. Source Code Library 源代码收集器
  5. PartitionMotionSearch()
  6. 利用python提取abaqus节点坐标的脚本_用于在Abaqus中提取结点力的Python程序
  7. Python——eventlet.wsgi
  8. lua代码格式化工具_lua的代码覆盖率工具
  9. ssh 切换用户_从零开始学习华为路由交换 | 配置ssh远程管理
  10. 使用koa托管静态资源文件
  11. java游戏毕业论文参考文献全面论文100个
  12. (补)2021.1.22
  13. Hustoj mdui Web界面修改
  14. Windows安装Svn客户端
  15. 北京优质农产品入驻苏宁小店 实现“农超对接”
  16. 联想昭阳e43l笔记本配置
  17. Android 12 双击power键启动相机源码解析
  18. 测试框架 Mocha 实例教程
  19. SDK对接遇到的问题与解决
  20. 论文阅读 点云动态图卷积(DGCNN)

热门文章

  1. C++设计模式之模板模式(template)(行为型)
  2. 自媒体视频剪辑中的素材都是在哪里找的?
  3. 猎头推荐成功一个人竟然收年薪一半,也太赚了吧
  4. 数据库系统概念 | 第七章:使用E-R模型的数据库设计 | ER图设计| ER图转化为关系模型 | 强实体和弱实体
  5. 一文读懂无线信道传播的各种特性
  6. 试卷分析的四个度:难度、区分度、信度、效度
  7. Windows系统更新完后进不去Microsoft Store,报错:需要使用新应用以打开此ms-windows-store链接
  8. JavaScript - demo - 两点之间画线
  9. 学校校园网联网计算机统计,xx学校校园网建设情况总结(简介或汇报)很有用
  10. PHP是核心思路,PHP_模拟OICQ的实现思路和核心程序(二),3 在线用户的信息扫描和更新 - phpStudy...