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参数是可选的,它是您要从聊天机器人开始的对话的名称。如果未提供此参数,将使用默认对话。