bing chat
Update deps
Node.js客户端的非官方bing聊天API。就像类固醇上的chatgpt
此软件包是Microsoft周围围绕Bing Chat的Node.js包装器。包括TS电池。
警告此软件包是反向设计的黑客。我不希望它会继续长期工作,也不是用于生产。我正在公开场合建立此内容,您可以在Twitter @Transistion_bs上遵循进度。
(30年代对话演示)
npm install bing-chat确保您使用node >= 18因此fetch 。
您需要访问有访问权限的人的Bing聊天或有效的cookie 。
您需要的cookie是_U cookie(或者只是将所有cookie串联在一起;都可以使用)。
import { BingChat } from 'bing-chat'
async function example ( ) {
const api = new BingChat ( {
cookie : process . env . BING_COOKIE
} )
const res = await api . sendMessage ( 'Hello World!' )
console . log ( res . text )
}您可以跟进消息继续对话。有关一个示例,请参见demos/demo-conversation.ts 。
请注意,Bing聊天对话大约20分钟后到期,因此它们并不是要长期对象。
您可以通过onProgress处理程序添加流媒体:
const res = await api . sendMessage ( 'Write a 500 word essay on frogs.' , {
// print the partial response as the AI is "typing"
onProgress : ( partialResponse ) => console . log ( partialResponse . text )
} )
// print the full text at the end
console . log ( res . text )有关流媒体支持的完整示例,请参见demos/demo-on-progress.ts 。
您还可以将参数variant添加到sendMessage函数中以更改AI的变体。默认值是Balanced ,但是您也可以使用Precise或Creative 。
const res = await api . sendMessage ( 'Write a 500 word essay on frogs.' , {
// change the variant to 'Precise'
variant : 'Creative'
} ) 如果您创建一个凉爽的集成,请随时打开PR并将其添加到列表中。
node >= 18 。fetch是在全球安装的。bing-chat构建网站,我们建议仅在您的后端API中使用它麻省理工学院©Travis Fischer
如果您发现这个项目很有趣,请考虑赞助我或在Twitter上关注我