GoogleBard
1.0.0
NPM模塊,用於使用Bard的反向工程API創建GoogleBard Chatbot。憑藉反向設計的API功能,它使開發人員能夠利用吟遊詩人的全部潛力。
__Secure-{account_number}PSID複製cookie。__Secure-1PSIDbard.google.com/u/{account_number}找到。/u/2 ,請搜索名為__Secure-2PSID的cookie。/u/3 ,請搜索名為__Secure-3PSID的cookie。要安裝軟件包,請運行以下命令:
npm install googlebard import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies ) ;
// other code - scroll below to view different functionalities availableinMemory :可選 - 如果true不會將對話保存到磁盤savePath :可選 - 保存對話的路徑(例如'./conversations.json')proxy :可選 - 處理代理配置 import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
inMemory : false ,
savePath : "./conversations.json" ,
proxy : {
host : process . env . PROXY_HOST ,
port : process . env . PROXY_PORT ,
auth : {
username : process . env . PROXY_USERNAME ,
password : process . env . PROXY_PASSWORD ,
} ,
protocol : "http" ,
} ,
} ) ;
// other code要詢問bot問題,您可以使用bot.ask(<prompt>, <conversation_id>:optional)功能。下面給出了它的用法:
import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies ) ;
let conversationId = "some_random_id" ; // optional: to make it remember the conversation
let response = await bot . ask ( "What is my name?" , conversationId ) ; // conversationId is optional
console . log ( response ) ; >> I don't know your name. I am a large language model, also known as a conversational AI or cha...
conversation_id將允許機器人記住您之前在對話中所說的 import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
inMemory : false ,
savePath : "./conversations.json" , // this is being done to save crucial information about the conversation so the bot remembers it
} ) ;
let conversationId = "test_id" ;
let response = await bot . ask ( "My name is Mehul" , conversationId ) ;
console . log ( response ) ; >> Hi Mehul, it's nice to meet you! I'm Bard...
import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
inMemory : false ,
savePath : "./conversations.json" ,
} ) ;
let conversationId = "test_id" ;
let response = await bot . ask ( "What is my name?" , conversationId )
console . log ( response ) ; >> I know your name is Mehul. You told me earlier.
要問bot問題並模擬響應流,您可以通過自定義邏輯實現它,也可以使用內置的bot.askStream(<callback>, <content>, <conversation_id>:optional) 。下面給出了它的用法:
import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
inMemory : false ,
savePath : "./conversations.json" ,
} ) ;
let conversationId = "test_id" ;
await bot . askStream (
( res ) => {
console . log ( res ) ;
} , // returns the response
"Hello?" ,
conversationId ,
) ; >> Your
name
is
Mehul.
I
will
remember
that
for
the
next
time
we
speak.
要重置對話,您可以使用bot.resetConversation(<conversation_id>)功能。此功能允許用戶使機器人忘記以前的對話,只要它們都在同一conversation_id中。下面給出了它的用法:
import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
inMemory : false ,
savePath : "./conversations.json" ,
} ) ;
let conversationId = "test_id" ; // notice id is the same as that used in the above example
let response = await bot . ask ( "what is my name?" , conversationId ) ;
console . log ( response ) ; >> You told me your name is Mehul.
import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
inMemory : false ,
savePath : "./conversations.json" ,
} ) ;
let conversationId = "test_id" ;
bot . resetConversation ( conversationId ) // resetting conversation
let response = await bot . ask ( "what is my name?" , conversationId ) ;
console . log ( response ) ; >> I understand that you are trying to get me to say your name, but...
為了檢索所有對話,您可以通過自定義邏輯實現功能,或者簡單地使用內置bot.getAllConversations() 。 。
import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
savePath : "./conversations.json" ,
} ) ;
let response = bot . getAllConversations ( )
console . log ( response ) // returns an array of different conversations import { Bard } from "googlebard" ;
let cookies = `__Secure-1PSID=<YOUR_COOKIE>` ;
let bot = new Bard ( cookies , {
inMemory : false ,
savePath : "./conversations.json" ,
} ) ;
let conversationId = "test_id" ;
await bot . waitForLoad ( ) ;
let response = bot . getConversationById ( conversationId ) ;
console . log ( response ) ; // returns an object 一個簡單的示例已添加到examples目錄中,該目錄顯示瞭如何使用GoogleBard來創建CLI ChatBot。尚未添加更多此類示例,因此請繼續關注!