chatgpt-on-wechat icon indicating copy to clipboard operation
chatgpt-on-wechat copied to clipboard

修改为使用chatgpt

Open xyc0123456789 opened this issue 1 year ago • 10 comments

修改为使用https://github.com/acheong08/ChatGPT/blob/main/src/revChatGPT/Official.py的chatgpt

xyc0123456789 avatar Feb 05 '23 08:02 xyc0123456789

已经可以成功运行了嘛,需要什么环境 和 配置项呢? 可以讨论下是否需要把 official.py 全部拷贝过来,直接把revChatGPT的包import进来是否可行呢

zhayujie avatar Feb 05 '23 08:02 zhayujie

这个可以稳定运行,就是回复依旧比较慢,但是比起之前浏览器版本稳定非常多。不支持图片。用下来直觉上还是与之前的chatgpt不一样,但是相似,感觉是一个分支。另外这个是免费的,我看了两天,没看到账户被扣钱

环境就是需要在之前环境上额外 pip install tiktoken 配置项我在之前config.json上没看到有模型选项,我看到代码里是直接写死的,所以我在bridge.bridge.Bridge.py里直接修改成chatGPT了

关于“可以讨论下是否需要把 official.py 全部拷贝过来,直接把revChatGPT的包import进来是否可行呢” 我是直接copy的official.py,然后加了若干行来实现你这里bot需要的接口。就下面这些代码

def Singleton(cls): instance = {}

def _singleton_wrapper(*args, **kargs):
    if cls not in instance:
        instance[cls] = cls(*args, **kargs)
    return instance[cls]

return _singleton_wrapper

@Singleton class ChatGPTBot(Bot):

def __init__(self):
    print("create")
    self.bot = Chatbot(conf().get('open_ai_api_key'))

def reply(self, query, context=None):
    if not context or not context.get('type') or context.get('type') == 'TEXT':
        if len(query) < 10 and "reset" in query:
            self.bot.reset()
            return "reset OK"
        return self.bot.ask(query)["choices"][0]["text"]

xyc @.***

 

------------------ 原始邮件 ------------------ 发件人: "zhayujie/chatgpt-on-wechat" @.>; 发送时间: 2023年2月5日(星期天) 下午4:57 @.>; @.@.>; 主题: Re: [zhayujie/chatgpt-on-wechat] 修改为使用chatgpt (PR #39)

已经可以成功运行了嘛,需要什么环境 和 配置项呢? 可以讨论下是否需要把 official.py 全部拷贝过来,直接把revChatGPT的包import进来是否可行呢

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

xyc0123456789 avatar Feb 05 '23 09:02 xyc0123456789

感谢PR!我稍后把你的代码合入master

配置项我在之前config.json上没看到有模型选项,我看到代码里是直接写死的

这个我一会加一个配置项,做成可选的

环境就是需要在之前环境上额外 pip install tiktoken

这句我没看太清楚,是 pip install tiktoken 吗?你是在windows环境上

zhayujie avatar Feb 05 '23 09:02 zhayujie

pip install tiktoken就是在之前openai版本已安装的基础上需要额外安装tiktoken这个库,不需要其他的特殊配置,我是部署到服务器上的

xyc0123456789 avatar Feb 05 '23 09:02 xyc0123456789

1675588621709 附张截图

xyc0123456789 avatar Feb 05 '23 09:02 xyc0123456789

我看了下代码,这段代码底层也是调用的官方接口 (GPT-3模型),但是手动实现了对话,是不错的参考

但是在wx场景,特别是群聊模式下,不支持对每个用户分配独立的上下文会话

我在最新的代码里优化了这一点 https://github.com/zhayujie/chatgpt-on-wechat/commit/7425d9075ae362ef18988e4e1e36ebdfe5de279e

zhayujie avatar Feb 05 '23 10:02 zhayujie

期待优化~ 模型是不一样的,我看到OpenAIBot用的是model="text-davinci-003",每一次调用都是会被计费的,https://github.com/acheong08/ChatGPT/blob/main/src/revChatGPT/Official.py里使用的是"text-chat-davinci-002-20221122",这个目前没看到会被计费

xyc0123456789 avatar Feb 05 '23 10:02 xyc0123456789

这个可以稳定运行,就是回复依旧比较慢,但是比起之前浏览器版本稳定非常多。不支持图片。用下来直觉上还是与之前的chatgpt不一样,但是相似,感觉是一个分支。另外这个是免费的,我看了两天,没看到账户被扣钱

The reason for the different reply is that this model is older from 2022/11/22, essentially the pre-release version

acheong08 avatar Feb 05 '23 11:02 acheong08

pip install tiktoken就是在之前openai版本已安装的基础上需要额外安装tiktoken这个库,不需要其他的特殊配置,我是部署到服务器上的

pip3 install revChatGPT also installs openai and tiktoken as dependencies

acheong08 avatar Feb 05 '23 11:02 acheong08

这个可以稳定运行,就是回复依旧比较慢,但是比起之前浏览器版本稳定非常多。不支持图片。用下来直觉上还是与之前的chatgpt不一样,但是相似,感觉是一个分支。另外这个是免费的,我看了两天,没看到账户被扣钱

The reason for the different reply is that this model is older from 2022/11/22, essentially the pre-release version

yes,I think so

xyc0123456789 avatar Feb 05 '23 11:02 xyc0123456789

davinci

问当前的机器人日期,回答是2020年,

这个老版居然要付费.

davinci-002-20221122 新版却免费?

这么神奇

ynzheng avatar Feb 06 '23 18:02 ynzheng

没了。

acheong08 avatar Feb 07 '23 23:02 acheong08

没了。

yes. That model does not exist...

xyc0123456789 avatar Feb 08 '23 00:02 xyc0123456789

the model "text-chat-davinci-002-20221122" is available now 这会儿又可以用了

xyc0123456789 avatar Feb 08 '23 04:02 xyc0123456789

haha wth

acheong08 avatar Feb 08 '23 04:02 acheong08

bot/chatgpt/chat_gpt_bot.py 中调整为: "text-chat-davinci-002-20221122" 后

这里不需要调整么?

https://github.com/zhayujie/chatgpt-on-wechat/blob/865432c53254ab3ab40850cb62517828055bbdb0/bot/openai/open_ai_bot.py#L41

ynzheng avatar Feb 08 '23 09:02 ynzheng

bot/chatgpt/chat_gpt_bot.py 中调整为: "text-chat-davinci-002-20221122" 后

这里不需要调整么?

https://github.com/zhayujie/chatgpt-on-wechat/blob/865432c53254ab3ab40850cb62517828055bbdb0/bot/openai/open_ai_bot.py#L41

这里不能改,open_ai_bot.py是为了调用gpt-3的,而且gpt-3有图像生成功能,和text-chat-davinci-002-20221122有差别的。如果要使用chat_gpt_bot.py,只要本地修改下面的"openAI"为"chatGPT"就行 https://github.com/zhayujie/chatgpt-on-wechat/blob/865432c53254ab3ab40850cb62517828055bbdb0/bridge/bridge.py#L9

xyc0123456789 avatar Feb 08 '23 13:02 xyc0123456789

为了

大佬,改成chatGPT后,能登录,就是一直抛错The server is overloaded or not ready yet. 是不是没得解啊

damajiang90 avatar Feb 08 '23 13:02 damajiang90

为了

大佬,改成chatGPT后,能登录,就是一直抛错The server is overloaded or not ready yet. 是不是没得解啊

没解...等吧,马上各种类似的大模型都会开放公测了

xyc0123456789 avatar Feb 08 '23 13:02 xyc0123456789

bot/chatgpt/chat_gpt_bot.py 中调整为: "text-chat-davinci-002-20221122" 后 这里不需要调整么? https://github.com/zhayujie/chatgpt-on-wechat/blob/865432c53254ab3ab40850cb62517828055bbdb0/bot/openai/open_ai_bot.py#L41

这里不能改,open_ai_bot.py是为了调用gpt-3的,而且gpt-3有图像生成功能,和text-chat-davinci-002-20221122有差别的。如果要使用chat_gpt_bot.py,只要本地修改下面的"openAI"为"chatGPT"就行

https://github.com/zhayujie/chatgpt-on-wechat/blob/865432c53254ab3ab40850cb62517828055bbdb0/bridge/bridge.py#L9

本地修改下面的"openAI"为"chatGPT"后,报这个

create
[ERROR][2023-02-12 18:08:18][wechat_channel.py:116] - That model does not exist

是不是模型被删除了?

melodyjerry avatar Feb 12 '23 10:02 melodyjerry

bot/chatgpt/chat_gpt_bot.py 中调整为: "text-chat-davinci-002-20221122" 后 这里不需要调整么? https://github.com/zhayujie/chatgpt-on-wechat/blob/865432c53254ab3ab40850cb62517828055bbdb0/bot/openai/open_ai_bot.py#L41

这里不能改,open_ai_bot.py是为了调用gpt-3的,而且gpt-3有图像生成功能,和text-chat-davinci-002-20221122有差别的。如果要使用chat_gpt_bot.py,只要本地修改下面的"openAI"为"chatGPT"就行 https://github.com/zhayujie/chatgpt-on-wechat/blob/865432c53254ab3ab40850cb62517828055bbdb0/bridge/bridge.py#L9

本地修改下面的"openAI"为"chatGPT"后,报这个

create
[ERROR][2023-02-12 18:08:18][wechat_channel.py:116] - That model does not exist

是不是模型被删除了?

是的

xyc0123456789 avatar Feb 12 '23 10:02 xyc0123456789

现在也就只能调用openaitext-davinci-003了把? 我刚去看了一下 我一个下午 就text-davinci-003用了2.3块钱了

melodyjerry avatar Feb 12 '23 10:02 melodyjerry

现在也就只能调用openaitext-davinci-003了把? 我刚去看了一下 我一个下午 就text-davinci-003用了2.3块钱了

是的

xyc0123456789 avatar Feb 12 '23 10:02 xyc0123456789