sydney ai
1.0.0
npm install sydney-ai import ChatBot from "sydney-ai" ;
const bot = new ChatBot ( process . env . TOKEN ) ;
let response = await bot . ask ( "Hello" ) ;
console . log ( response ) ; 要安裝軟件包,請在您的終端中運行以下命令:
npm install sydney-ai首先,您需要導入該軟件包:
import ChatBot from "sydney-ai" ;這是如何在node.js代碼中使用軟件包的示例:
import ChatBot from "sydney-ai" ;
// creating the bot with default options
const bot = new ChatBot ( process . env . TOKEN ) ;
// asking a question with default conversation
let response = await bot . ask ( "Hello" ) ;
console . log ( response ) ;
// asking a question with a specific conversation
let response2 = await bot . ask ( "Hello" , "conversation name" ) ;
console . log ( response2 ) ;
//asking a question with a stream default conversation (streamResponse contains the final response)
let streamResponse = await bot . askStream ( res => {
console . log ( res ) ;
} , "Hello" ) ;
// asking a question with a stream specific conversation (streamResponse2 contains the final response)
let streamResponse2 = await bot . askStream ( res => {
console . log ( res ) ;
} , "Hello" , "conversation name" ) ; 這是用於創建新聊天機器人實例的構造函數。需要token參數,它是用於創建對話並與Bing通信的Bing _U cookie。 options參數是可選的,可用於為聊天機器人指定其他選項。
此方法用於向聊天機器人提出問題。需要message參數,這是您要詢問聊天機器人的問題。 conversation參數是可選的,它是您要從聊天機器人開始的對話的名稱。如果未提供此參數,將使用默認對話。