Skip to main content

A Jupyter-based assistant for data analysis tasks

Project description

bia-bob

BIA bob is a Jupyter-based assistant for interacting with data using large language models which generate python code. It can make use of OpenAI's chatGPT API or Google's Vertex AI API and Gemini. You need an OpenAI API account or a Google Cloud account to use it.

img.png

Usage

You can initialize bob like this:

from bia_bob import bob

Code generation

You can ask Bob to generate code like this:

%bob Load blobs.tif and show it

It will then respond with a python code snippet that you can execute (see full example):

img.png

Bug fixing

Bob can fix simple bugs in code you executed. Just add %%fix on top of the cell right after the error happened.

img.png

Code documentation

Using the %%doc magic, you can generate documentation for a given code cell.

img.png

Example notebooks

Known issues

If you want to ask bob a question, you need to put a space before the ?.

%bob What do you know about blobs.tif ?

Installation

You can install bia-bob using pip. it is recommended to install it into via conda/mamba environment. If you have never used conda before, please read this guide first.

It is recommended to install bia-bob in a conda-environment together with useful tools for bio-image analysis.

mamba env create -f https://github.com/haesleinhuepf/bia-bob/raw/main/environment.yml

You can then activate this environment...

mamba activate bob_env

... and install bia-bob.

Using OpenAI as backend

pip install bia-bob openai

(Recommended openai version >= 1.2.0)

Create an OpenAI API Key and add it to your environment variables as explained on this page.

Using Google's Cloud AI API as backend

pip install bia-bob google-cloud-aiplatform

(Recommended google-cloud-aiplatform version >= 1.38.1)

To make use of the Google Cloud API, you need to create a Google Cloud account here and a project within the Google cloud (for billing) here. You need to store authentication details locally as explained here. This requires installing Google Cloud CLI. In very short: run the installer and when asked, activate the "Run gcloud init' checkbox. Or run 'gcloud init' from the terminal yourself. Restart the terminal window. After installing Google Cloud CLI, start a terminal and authenticate using:

gcloud auth application-default login

Follow the instructions in the browser. Enter your Project ID (not the name). If it worked the terminal should approximately look like this:

img.png

Development

If you want to contribute to bia-bob, you can install it in development mode like this:

git clone https://github.com/haesleinhuepf/bia-bob.git
cd bia-bob
pip install -e .

Extensibility

If you are maintainer of a Python library and want to make BiA-bob aware of functions in your library, you can extend Bob's knowledge using entry-points. Add this to your library setup.cfg:


[options.entry_points]
bia_bob_plugins =
    plugin1 = your_library._bia_bob_plugins:list_bia_bob_plugins

In the above mentioned _bia_bob_plugins.py define this function (and feel to rename the function and the Python file):

def list_bia_bob_plugins():
    """List of function hints for bia_bob"""
    return """
    * Computes the sum of a and b
    your_library.compute_sum(a:int,b:int) -> int
    
    * Determines the difference between a and b
    your_library.compute_difference(a:int, b:int) -> int
    
    """

Note that the syntax should be pretty much as shown above: A bullet point with a short description and a code-snippet just below. You can also generate the list_bia_bob_plugins function as demonstrated in this notebook. Please only list the most important functions. If the list of all plugins extending BiA-Bob becomes too long, the prompt will exceed the maximum prompt length.

List of known Python libraries that provide extensions to Bob:

(Feel free to extend this list by sending a pull-request)

Similar projects

There are similar projects:

Issues

If you encounter any problems or want to provide feedback or suggestions, please create a thread on image.sc along with a detailed description and tag @haesleinhuepf .

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

bia-bob-0.8.1.tar.gz (14.8 kB view hashes)

Uploaded Source

Built Distribution

bia_bob-0.8.1-py3-none-any.whl (12.6 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