You can access the CLI directly from within Notebooks
using IPython magic commands. First, configure
the qBraid magic command extension using:
The above command can also be executed from within a Jupyter notebook using the ! operator. Then, from within a
notebook cell, load the qBraid magic IPython extension using:
In [1]: %load_ext qbraid_magic
Now you can continue to use the qBraid-CLI as normal from within your Jupyter notebook using the magic % operator, e.g.
In [2]: %qbraid
In [3]: %qbraid --version
Quantum Jobs
Check whether quantum jobs are enabled in your current notebook, and enable Amazon Braket quantum jobs:
In [4]: %qbraid jobs state
In [5]: %qbraid jobs enable braket -y
After enabling quantum jobs within a notebook, you must restart your kernel in
order for the changes to take effect.
To use qbraid jobs commands within a notebook, you must prefix them with the
% magic operator. Using the ! operator instead will likely result in
errors, as it executes the commands as regular bash commands without
leveraging the notebook context.
qBraid Chat
Leverage qbraid chat as an in-line coding assistant with magic commands. Ask questions using the --prompt or -p flag to receive plain-text responses:
In [5]: %qbraid chat --prompt "What is a qubit?"
For raw code responses, use the --format or -f option with the code format:
In [6]: %qbraid chat -f code -p "Write a Cirq bell circuit"
The generated code will be automatically inserted into the notebook cell below.