这篇博客给大家介绍一个python库 tencent (https://pypi.org/project/tencent/) 以及对应三方API的开发流程,以公众号后台通过服务器接入自动系统回复为例。基于微信公众号后台开发自动回复,或者利用多模态信息回复用户输入,需要自己有独立服务器和相关的后端框架才能验证成功。这样用户给公众号/订阅号发信息的时候,公众号后台会给你填写的服务器地址发送POST请求,经过验证之后你的服务端就可以给公众号提供自动回复的服务了。 可以在 github repo (https://github.com/AI-Hub-Admin/tencent) 创建MR,Repo管理员会检查API的目标和安全性决定是否合并。具体的开发 guidelines参考 (http://www.deepnlp.org/blog?category=tencent)
声明 Disclaimer: tencent python库和腾讯官方没有任何直接关联。是开源社区开源项目和三方API集合,贡献包通过 contrib目录进行区分。
1. python库tencent安装
安装 tencent 库
pip install tencent
验证是否安装成功
import tencent
如果可以看到一个"tencent"的logo或者是小马哥和企鹅的灰度图就代表成功了。
2. 三方API 开发Guidelines
2.1 新开发的API 继承基类 BaseAPI
假设我们要实现一个名字为 "api_demo"的API,输入参数和输出参数支持可变长。
入参:
*args: 位置参数的元组
**kwargs: key-value类型入参
出参:
result: dict
class BaseAPI(object):
"""docstring for ClassName"""
def __init__(self, configs):
self.configs = configs
self.name = API_NAME_BASE
def api(self, args, kwargs):
"""
"""
class DemoAPI(BaseAPI):
"""docstring for ClassName"""
def __init__(self, configs):
super(DemoAPI, self).__init__(configs)
self.name = API_NAME_DEMO
def api(self, args, kwargs):
"""
Args:
args: tuple of args, (input)
kwargs: key value dict
Return:
res_dict: dict, multi-modal text text, image, audio and video
"""
api_input = ""
if len(args) > 0:
api_input = args[0]
res_dict = {}
res_dict["output"] = api_input
return res_dict
2.2 在__init__.py文件中注册你的API
在文件 "/tencent/__init__.py" 中你可以 import 你的API,然后添加一行代码来注册你的API,之后就可以调用了。
注意:API类的name属性 (DemoAPI.name) 是区分你的API的唯一标识符号,admin 会检查命名冲突,不能影响。
from .base import *
SUPPORTED_APIS[DemoAPI(None).name] = {KEY_IMPL: DemoAPI}
2.3 通过统一接口调用你的API
import tencent
your_api_name="xxx"
res = tencent.api(your_api_name)
2.4 单元测试
在顶层tencent目录的 tests目录下 (/tencent/tests/*.py),需要写你的单元测试,缺少单元测试的MR不会被考虑合并到 master分支。参考下面的 github的tests地址 github repo (https://github.com/AI-Hub-Admin/tencent/tree/main/tests)
代码库和地址
https://github.com/AI-Hub-Admin/tencent
https://github.com/AI-Hub-Admin/FinanceAgent
https://github.com/AI-Hub-Admin/HealthcareAgent
https://github.com/AI-Hub-Admin/AI-Agents-Visualization
http://www.deepnlp.org/workspace/dialogue_visualization
http://www.deepnlp.org/workspace/agent_visualization
http://www.deepnlp.org/store/pub/pub-openai-o1
http://www.deepnlp.org/store/pub/pub-chatgpt-openai
http://www.deepnlp.org/blog/introduction-to-multimodal-generative-models
OpenAI o1
OpenAI o1 Reviews, Ratings and Communities on DeepNLP AI App Store
ChatGPT User Reviews
http://www.deepnlp.org/store/pub/pub-chatgpt-openai
Gemini User Reviews
http://www.deepnlp.org/store/pub/pub-gemini-google
Perplexity User Reviews
http://www.deepnlp.org/store/pub/pub-perplexity
Claude User Reviews
Claude Reviews, Ratings and Communities on DeepNLP AI App Store
Grok User Reviews
Grok Reviews, Ratings and Communities on DeepNLP AI App Store
Midjourney User Reviews
Midjourney Reviews, Ratings and Communities on DeepNLP AI App Store
Stable Diffusion User Reviews
Stable Diffusion Reviews, Ratings and Communities on DeepNLP AI App Store
Runway User Reviews
Runway User Reviews
Canva User Reviews
Canva Reviews, Ratings and Communities on DeepNLP AI App Store
GPT-5 Forecast
GPT-5 Reviews, Ratings and Communities on DeepNLP AI App Store
SearchGPT Reviews
SearchGPT Reviews, Ratings and Communities on DeepNLP AI App Store
Kling AI Reviews
Kling AI Reviews, Ratings and Communities on DeepNLP AI App Store
Dreamina AI Reviews
Dreamina Reviews, Ratings and Communities on DeepNLP AI App Store
Luma AI
Luma AI Reviews, Ratings and Communities on DeepNLP AI App Store
Pika AI Reviews
Pika Reviews, Ratings and Communities on DeepNLP AI App Store
Runway AI Reviews
http://www.deepnlp.org/store/pub/pub-runway
Flux AI Reviews
Flux AI Reviews, Ratings and Communities on DeepNLP AI App Store
Qwen AI Reviews
http://www.deepnlp.org/store/pub/pub-qwen-alibaba
Zhipu AI Reviews
Zhipu Reviews, Ratings and Communities on DeepNLP AI App Store
Doubao Reviews
http://www.deepnlp.org/store/pub/pub-doubao-douyin
Kimi Chat Reviews
Kimi Chat Reviews, Ratings and Communities on DeepNLP AI App Store
Coursera Reviews
Coursera Reviews, Ratings and Communities on DeepNLP AI App Store
Udacity Reviews
Udacity Reviews, Ratings and Communities on DeepNLP AI App Store
Grammarly Reviews
Grammarly Reviews, Ratings and Communities on DeepNLP AI App Store
ChatGPT Strawberry
ChatGPT Strawberry Reviews, Ratings and Communities on DeepNLP AI App Store
Google AR VR Headsets
Google AR VR Headset Reviews, Ratings and Communities on DeepNLP AI App Store
DeepNLP AI Tools
DeepNLP AI Tools Reviews, Ratings and Communities on DeepNLP AI App Store
## Robotics
Tesla Cybercab Robotaxi
Tesla Cybercab Reviews, Ratings and Communities on DeepNLP AI App Store
Tesla Optimus
Tesla Optimus Reviews, Ratings and Communities on DeepNLP AI App Store
Figure AI
Figure AI Reviews, Ratings and Communities on DeepNLP AI App Store
Unitree Robotics Reviews
Unitree Reviews, Ratings and Communities on DeepNLP AI App Store
Waymo User Reviews
Waymo Reviews, Ratings and Communities on DeepNLP AI App Store
ANYbotics Reviews
ANYbotics Reviews, Ratings and Communities on DeepNLP AI App Store
Boston Dynamics
Boston Dynamics Reviews, Ratings and Communities on DeepNLP AI App Store
## AI Widgets
Apple Glasses
Apple Glasses Reviews, Ratings and Communities on DeepNLP AI App Store
Meta Glasses
Meta Glasses Reviews, Ratings and Communities on DeepNLP AI App Store
Apple AR VR Headset
Apple AR VR Headset Reviews, Ratings and Communities on DeepNLP AI App Store
Google Glass
Google Glass Reviews, Ratings and Communities on DeepNLP AI App Store
Meta VR Headset
Meta VR HeadSet Reviews, Ratings and Communities on DeepNLP AI App Store
## Social
Character AI
http://www.deepnlp.org/store/pub/pub-character-ai
## Self-Driving
BYD Seal
BYD Seal Reviews, Ratings and Communities on DeepNLP AI App Store
Tesla Model 3
Tesla Model 3 Reviews, Ratings and Communities on DeepNLP AI App Store
BMW i4
BMW i4 Reviews, Ratings and Communities on DeepNLP AI App Store
Baidu Apollo Reviews
Baidu Reviews, Ratings and Communities on DeepNLP AI App Store
Hyundai IONIQ 6
Hyundai IONIQ 6 Reviews, Ratings and Communities on DeepNLP AI App Store