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上關注我