GoogleBard
1.0.0
BardのリバースエンジニアリングAPIを使用してGoogleBardチャットボットを作成するためのNPMモジュール。リバースエンジニアリングAPI機能により、開発者はバードの可能性を最大限に活用できるようになります。
__Secure-{account_number}PSIDで始まるCookieをコピーします。__Secure-1PSIDbard.google.com/u/{account_number}としてURLにあるアカウント番号に対応する正しいCookieをコピーしていることを確認してください。/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.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.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 GoogleBardを使用してCLIチャットボットを作成する方法を示す簡単な例がexamplesディレクトリに追加されました。このような例はまだ追加されていないので、お楽しみに!