Skip to content

LlamaBot: A Pythonic bot interface to LLMs

This is a developer README for LlamaBot.

LlamaBot implements a Pythonic interface to LLMs, making it much easier to experiment with LLMs in a Jupyter notebook and build Python apps that utilize LLMs. All models supported by LiteLLM are supported by LlamaBot.

Setting up your developer environment

Make sure that you have followed the README.md before jumping on the next steps.

Creating a Conda virtual environment

It is recommended to have Conda available on your system.

conda env create -f environment.yml

After the conda environment creation, you may need to run the following commands.

conda activate llamabot

The following command will install all your pip dependencies

pip install -e .

Installing pre-commit hook

It is recommended to install and use the pre-commit hook if you plan to commit this project. This will check for any issues before committing your code. It is also one of the recommended developers' best practices.

The following command will install pre-commit in your virtual environment.

pre-commit install

Now before you commit your changes, running the pre-commit command below will automatically run code checks for you. If there are any issues that pre-commit finds, such as missing line breaks, lint errors or others, then please make the appropriate changes, rerun pre-commit to ensure that the checks pass and then commit the files.

pre-commit run

Configuring your downloaded model

If you are using a local model, you may need to update the DEFAULT_LANGUAGE_MODEL to your local model path by running the following command:

Replace wth your locally downloaded model.

For example:

  • If you are using Mistral: replace <your_model_name> with mistral.
  • If you are using Llama3: replace <your_model_name> with llama3.
llamabot configure default-model --model-name "ollama/<your_model_name>"

OR

You could also pass the language model as an argument when extending/creating your own model from the SimpleBot api.

Example:

feynman = SimpleBot(
    "You are Richard Feynman. You will be given a difficult concept, and your task is to explain it back.",
    model_name="ollama/llama3"
)