Jupyter magic to support sydney-py
MIT License
Sydney Magic is an IPython extension that provides line and cell magics for interacting with Sydney.py, an unofficial Python client for Copilot (formerly named Bing Chat), also known as Sydney. This extension allows users to easily use Copilot's capabilities directly within IPython notebooks or shells.
%sydney ask "<prompt>"
.%sydney compose "<prompt>"
.To install Sydney Magic from pip:
pip install sydney-magic
To install Sydney Magic from code, follow these steps:
setup.py
.pip install .
This command installs Sydney Magic and its dependencies.
Sydney Magic requires a cookie from the Copilot web page to authenticate requests to the Copilot API. To set up this cookie:
F12
or right-clicking on the chat dialog and selecting Inspect
).Network
tab to view all requests sent to Copilot.create?bundleVersion=XYZ
and click on it.Cookie:
field.Then, set it as an environment variable in your shell:
export BING_COOKIES="<your-cookies>"
Alternatively, you can set the cookie within your IPython notebook or script using the helper_set_cookie("<your-cookies>")
function provided by Sydney Magic.
After installation, load the extension in your IPython environment:
%load_ext sydney_magic
Use `%sydney [command]` for line magic or `%%sydney [command]` for cell magic.
Commands:
- ask [prompt]: Ask a question or make a request to Copilot.
Options:
--attachment=[image url or path]
--context=[web-page-source]
--citations=[True|False]
--suggestions: Include suggested responses.
--raw=[True|False]: Get raw JSON response.
- compose [prompt]: Compose content with a specific format and tone.
Options:
--tone=[professional|casual|enthusiastic|informational|funny]: Set the tone for composition.
--format=[paragraph|email|blogpost|ideas]: Set the format for composition.
--length=[short|medium|long]: Set the length for composition.
--suggestions: Include suggested responses.
--raw=[True|False]: Get raw JSON response.
- explain: Explain the current notebook code.
- error: Explain the last occurred error.
- readme: Generates README.md in the current directory.
Example:
`%sydney ask "What is Python?" --citations`
Ask Copilot a question:
%sydney ask "What is the weather like today?"
Compose content with specific formatting:
%sydney compose "Write a short story about a robot" --format=blogpost --tone=enthusiastic
For more information on commands and options, use:
%sydney help
This project is licensed under the MIT License - see the LICENSE file for details.