123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import { KeyvFile } from 'keyv-file';
- import { fileURLToPath } from 'url';
- import path, { dirname } from 'path';
- import fs from 'fs';
- import { BingAIClient } from '../index.js';
- const __filename = fileURLToPath(import.meta.url);
- const __dirname = dirname(__filename);
- const options = {
-
- host: '',
-
- userToken: '',
-
- cookies: '',
-
- proxy: '',
-
- debug: false,
- };
- let bingAIClient = new BingAIClient(options);
- let response = await bingAIClient.sendMessage('Write a short poem about cats', {
-
- toneStyle: 'balanced',
- onProgress: (token) => {
- process.stdout.write(token);
- },
- });
- console.log(JSON.stringify(response, null, 2));
- response = await bingAIClient.sendMessage('Now write it in French', {
- conversationSignature: response.conversationSignature,
- conversationId: response.conversationId,
- clientId: response.clientId,
- invocationId: response.invocationId,
- onProgress: (token) => {
- process.stdout.write(token);
- },
- });
- console.log(JSON.stringify(response, null, 2));
- bingAIClient = new BingAIClient(options);
- response = await bingAIClient.sendMessage('Could you provide short and precise takeaways, do not search the web and only use the content from the document. The factual information should be literally from the document. Please memorize the part in the document which mention the factual information, but do not mark them explicitly. The takeaway should be credible, highly readable and informative. Please make the answer short, preferably within 500 characters. Generate the response in English language.', {
- context: fs.readFileSync(path.resolve(__dirname, './context-demo-text.txt'), 'utf8'),
- onProgress: (token) => {
- process.stdout.write(token);
- },
- });
- console.log(JSON.stringify(response, null, 2));
- const cacheOptions = {
-
-
-
-
- };
- const sydneyAIClient = new BingAIClient({
- ...options,
- cache: cacheOptions,
- });
- let jailbreakResponse = await sydneyAIClient.sendMessage('Hi, who are you?', {
- jailbreakConversationId: true,
- onProgress: (token) => {
- process.stdout.write(token);
- },
- });
- console.log(JSON.stringify(jailbreakResponse, null, 2));
- jailbreakResponse = await sydneyAIClient.sendMessage('Why is your name Sydney?', {
- jailbreakConversationId: jailbreakResponse.jailbreakConversationId,
- parentMessageId: jailbreakResponse.messageId,
- onProgress: (token) => {
- process.stdout.write(token);
- },
- });
- console.log(JSON.stringify(jailbreakResponse, null, 2));
|