Skip to main content

Python Client for Bing Chat, also known as Sydney.

Project description

Sydney.py

Latest Release Python MIT License

Python Client for Bing Chat, also known as Sydney.

Note This is an unofficial client.

Requirements

  • Python 3.10 or newer
  • Microsoft account with access to Bing Chat

Installation

To install Sydney.py, run the following command:

pip install sydney-py

or, if you use poetry:

poetry add sydney-py

Usage

To use Sydney.py you first need to extract the _U cookie from Bing.

Then, set it as an environment variable:

export BING_U_COOKIE=<your-cookie>

Then, you can use the provided Sydney Client:

import asyncio

from sydney import SydneyClient


async def main() -> None:
    sydney = SydneyClient()

    await sydney.start_conversation(style="balanced")

    response = await sydney.ask("Hello, how are you?")
    print(response)

    await sydney.reset_conversation()

    prompt = "What's today's weather forecast?"
    async for response in sydney.ask_stream(prompt, citations=True):
        print(response, end="", flush=True)

    await sydney.close_conversation()


if __name__ == "__main__":
    asyncio.run(main())

The Sydney Client also supports the Compose feature:

import asyncio

from sydney import SydneyClient


async def main() -> None:
    sydney = SydneyClient()

    await sydney.start_conversation()

    response = await sydney.compose("Why Python is a great language", format="ideas")
    print(response)

    await sydney.close_conversation()


if __name__ == "__main__":
    asyncio.run(main())

For more detailed documentation and options, please refer to the code docstrings.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sydney_py-0.8.0.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

sydney_py-0.8.0-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page