BARD의 리버스 엔지니어링 API를 사용하여 GoogleBard Chatbot을 생성하기위한 NPM 모듈. 리버스 엔지니어링 API 기능을 통해 개발자가 BARD의 잠재력을 최대한 활용할 수있게합니다.
__Secure-{account_number}PSID 로 시작하는 쿠키를 복사하십시오.__Secure-1PSIDbard.google.com/u/{account_number} 로 찾을 수있는 계정 번호에 해당하는 올바른 쿠키를 복사하고 있는지 확인하십시오./u/2 인 경우 __Secure-2PSID 라는 쿠키를 검색하십시오./u/3 인 경우 __Secure-3PSID 라는 쿠키를 검색하십시오.패키지를 설치하려면 다음 명령을 실행하십시오.
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 챗봇을 만드는 방법을 보여줍니다. 더 많은 예제는 아직 추가되지 않았으므로 계속 지켜봐 주시기 바랍니다!