npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@timefox/bic-sydney

v1.1.7

Published

This is a module which allows sydney to use the Bing Image Creator to generate images for you.

Downloads

11,943

Readme

A demonstration using this module with ChatGPT API and PandoraAI together.

node-bic-sydney

A Node.js module that provides some 'Bing Image Creator' functions.

Prerequisites

  • Node.js >= 16.0.0
  • Sydney's optionsSets must contain 'gencontentv3' if you want bing to provide prompts for you.

Usage

Module

npm i @timefox/bic-sydney

Usage

Create images by Bing Image Creator, and get an iframe pointing to the page contains the images created. This method is most likely what the original bing browser client does. The format of {BingImageCreator} options is almost same as the bingAiClient options of '@waylaidwanderer/chatgpt-api'.

import { BingImageCreator } from '@timefox/bic-sydney';
import crypto from 'crypto';

// Setup the required options.
const options = {
    // Necessary for some people in different countries, e.g. China (https://cn.bing.com)
    host: '',
    // The "_U" cookie value from bing.com
    userToken: '',
    // If the above doesn't work, provide all your cookies as a string instead
    cookies: '',
    // A proxy string like "http://<ip>:<port>"
    proxy: '',
    // (Optional) Set to true to enable `console.debug()` logging
    debug: false,
    // (Optional) The user agent for the network request.
    userAgent: '',
};

const prompt = 'a fox plays xbox';
const messageId = crypto.randomUUID();

// Make a creation request with given prompt. With 'gencontentv3' option on, bing will give you the prompt
// in a message which's contentType is 'IMAGE'.
const imageIframe = new BingImageCreator(options).genImageIframeCsr(prompt, messageId);
imageIframe.then((result) => {
    console.debug(result);
}).catch((error) => {
    console.debug(error);
});

Note: If this iframe is returned to client browser, the user must be logged in to bing.com in order to generate the image successfully. The user's cookie is required for the polling requests of the generation process.

Create images by Bing Image Creator, and get an iframe which uses the 'srcdoc' attribute to hold the rendered result page. This method does not require the user to have logged in to bing.com on the client side. The entire request process is completed by the server proxy. It's very useful for the clients can not visit the new bing's service directly.

import { BingImageCreator } from '@timefox/bic-sydney';
import crypto from 'crypto';

// Setup the required options.
const options = {
    // Necessary for some people in different countries, e.g. China (https://cn.bing.com)
    host: '',
    // The "_U" cookie value from bing.com
    userToken: '',
    // If the above doesn't work, provide all your cookies as a string instead
    cookies: '',
    // A proxy string like "http://<ip>:<port>"
    proxy: '',
    // (Optional) Set to true to enable `console.debug()` logging
    debug: false,
    // (Optional) The user agent for the network request.
    userAgent: '',
};

const prompt = 'a fox plays xbox';
const messageId = crypto.randomUUID();

// Make a creation request with given prompt. With 'gencontentv3' option on, bing will give you the prompt
// in a message which's contentType is 'IMAGE'.
// The onProgress is a callback function. If onProgress is provided and returns true, the request will be cancelled.
imageIframe = new BingImageCreator(options).genImageIframeSsr(
    prompt,
    messageId,
    (progress) => {
        if (progress?.contentIframe) {
            console.debug('contentIframe:');
            console.debug(progress.contentIframe);
        }
        if (progress?.pollingStartTime) {
            console.debug(`pollingStartTime: ${progress.pollingStartTime}`);
        }
    },
);
imageIframe.then((result) => {
    console.debug(result);
}).catch((error) => {
    console.debug(error);
});

For more usage, please refer to the module's documentation.

Documents

npm run doc

It will generate the module's docs for you under ./docs.

License

This project is licensed under the MIT License.