wangrongding / wechat-bot

🤖一个基于 WeChaty 结合 OpenAi ChatGPT / Kimi / 讯飞等Ai服务实现的微信机器人 ,可以用来帮助你自动回复微信消息,或者管理微信群/好友,检测僵尸粉等...
MIT License
4.96k stars 710 forks source link

有没有办法做到连续语境呢 #10

Closed king19990102 closed 5 months ago

wangrongding commented 1 year ago

可以的,这么写

const api = new ChatGPTAPI({
  sessionToken: process.env.SESSION_TOKEN
})

const conversation = api.getConversation()

// send a message and wait for the response
const response0 = await conversation.sendMessage('What is OpenAI?')

// send a follow-up prompt to the previous message and wait for the response
const response1 = await conversation.sendMessage('Can you expand on that?')

// send another follow-up to the same conversation
const response2 = await conversation.sendMessage('Oh cool; thank you')
king19990102 commented 1 year ago

这是官方的例子,但是实际用的时候一般只发一次,没有起到作用

king19990102 commented 1 year ago

哦,我知道,因为每次都会new新的会话所以不连续

wangrongding commented 1 year ago

对的,把那个单独放最外面

Alex-Shen1121 commented 1 year ago
image

这个api是被移除了吗

ottocsb commented 1 year ago

@Alex-Shen1121 更新依赖,默认的版本没有这个api

liuliuzx commented 1 year ago

@Alex-Shen1121 更新依赖,默认的版本没有这个api

@ottocsb 请问更新哪个依赖啊?

ottocsb commented 1 year ago

@liuliuzx chatgpt

wangrongding commented 1 year ago

哦哦, 最新的提交已经更新依赖了~上一个版本缺少部分 api

yn-ayw commented 1 year ago

对的,把那个单放最外面

放最外面啥意思阿?放在哪里?

wangrongding commented 1 year ago

放最外面啥意思阿?放在哪里?

哦哦,就是把 api 的声明放到函数外面。 已经更新代码了,重新 pull 下

183673639 commented 1 year ago

现在的上下文语意好像还是没有连续起来

hh0318 commented 1 year ago

现在的上下文语意好像还是没有连续起来

是因为现在问答依赖不是chatGpt 变成openAi 了

hushicai commented 1 year ago

接入最新版chatgpt,加上conversation支持就好了。

https://github.com/hushicai/wechat-bot/commit/dee4761f27699f70cd33ac4ea085bacec1af83dd

image