7

为什么不接ChatGPT到微信公号?

 1 year ago
source link: https://finisky.github.io/chatgpt-for-official-account/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

为什么不接ChatGPT到微信公号?

ChatGPT火爆全网,要是能接到自己的微信公众号后台,岂不美哉?

想必有此想法的同志不止我一人,上周末就研究了一下,有几个问题需要解决。

首先就是ChatGPT API,最关键的问题没有之一,OpenAI并没有官方API支持。不过github上早有人反向工程破解了此API,Python实现:

revChatGPT

使用方法很简单:pip3 install --upgrade revChatGPT

写了个demo chatgpt.py:

#!/usr/bin/python3

import logging
from revChatGPT.revChatGPT import Chatbot

logger = logging.getLogger('meng')

config = {
    "email": "your_email",
    "password": "your_password"
}

chatbot = Chatbot(config, conversation_id=None)

def chat(history, query):
    response = chatbot.get_chat_response(query, output="text")
    print (response)
    return response['message']

if __name__ == '__main__':
    response = chat([], '你懂python吗?')
    print (response)
    response = chat([], '你懂go吗?')
    print (response)

不过由于不是官方API,稳定性不太好,加上每次API调用都需要重登录,速度也不太快,更不必提生成一段长文本所需要的时间了,获取结果基本在15秒以上。

于是这就引发了另一个问题,微信要求5秒内回复消息,否则提示“该公众号暂时无法提供服务,请稍后再试”,考虑到ChatGPT的生成时间,就给接入微信公众号带来了困难。

虽然有其他方案,比如记录上下文,先在5秒内返回一条文本消息“请15秒后输入‘xxx’获取结果”,后台将生成的结果缓存,然后让用户再发一条定制消息"xxx",再将缓存的文本返回,但整个聊天体验就非常差了。

所以聪明的开发者们考虑了另外两个方案来解决问题:

  • 自己开发小程序,不受5秒回复限制,不过已经被微信官方认定为违规下线
  • "ChatGPT"公众号,用阅读原文的方式导流到一个破解ChatGPT API的网站,不过由于用的人过多,这个网站已无法正常返回,目测被OpenAI限制使用了

此外上周末revChatGPT还好使,今天再访问这个repo发现也被archived,原因不言自明。

所以,本公众号还是使用开放的WeLM API与大家聊天吧,关注公众号,直接留言,小菲就可以跟您唠上了。 不过由于WeLM采用Prompt的方式进行上下文补全,有可能进行错误放大,所以不支持上下文指代,只能单轮对话。

小菲陪您唠唠磕

finiskybot1.png

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK