Skip to main content

A lightweight library to support the development of applications using LLMs.

Project description

ralf_logo

ralf

Documentation PyPI version License

ralf is a Python library intended to assist developers in creating applications that involve calls to Large Language Models (LLMs). A core concept in ralf is the idea of composability, which allows chaining together LLM calls such that the output of one call can be used to form the prompt of another. ralf makes it easy to chain together both LLM-based and Python-based actions— enabling developers to construct complex information processing pipelines composed of simpler building blocks. Using LLMs in this way can lead to more capable, robust, steerable and inspectable applications.

Currently, the ralf base library offers generic functionality for action chaining (through the Dispatcher and Action classes) as well as text classificaiton (through the ZeroShotClassifier class). Check out the other projects within the RALF ecosystem for more specialized functionality, like dialogue management and information extraction.

Quickstart Guide

This quickstart guide is intended to get you up and running with ralf within a few minutes.

Installation

We recommend creating a Conda environment before installing the package:

conda create -n ralf python=3.10
conda activate ralf

Install from PyPI

You may install ralf from PyPI using pip:

pip install ralf-jhuapl

Install from Source

Alternatively, you can build the package from source. First, clone the Github repository:

git clone https://github.com/jhuapl-fomo/ralf.git

Next, install the requirements using pip:

cd ralf
pip install -r requirements.txt

Then, build the package using flit and install it using pip:

flit build
pip install .

Or if you would like an editable installation, you can instead use:

pip install -e .

OpenAI Configuration

ralf currently relies on language models provided by OpenAI, either directly via the OpenAI API or through Microsoft Azure. In either case, you must save your API key as an environment variable by executing the following in bash:

echo "export OPENAI_API_KEY='your_key'" >> ~/.bashrc
source ~/.bashrc

OpenAI Configuration (Azure)

If you are accessing OpenAI models through Azure, you must additionally provide the URL for your Azure endpoint.

echo "export OPENAI_API_KEY='https://yourendpoint.openai.azure.com/'" >> ~/.bashrc
source ~/.bashrc

Running the Demos

To test if installation was successful, try running the demo scripts:

cd demos
python dispatcher_demo.py
python classifier_demo.py

If the scripts execute successfully, you are good to go! You may want to look through the demo scripts to learn about some of the things ralf can do, or follow the more detailed tutorials.

Documentation & Tutorials

The best way to get started with ralf is to follow the tutorials, which can be found in the full documentation.

License

This project is released under the MIT License.

Copyright © 2023 The Johns Hopkins University Applied Physics Laboratory

Contact: ralf@jhuapl.edu

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

ralf-jhuapl-0.0.6.tar.gz (377.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ralf_jhuapl-0.0.6-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file ralf-jhuapl-0.0.6.tar.gz.

File metadata

  • Download URL: ralf-jhuapl-0.0.6.tar.gz
  • Upload date:
  • Size: 377.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for ralf-jhuapl-0.0.6.tar.gz
Algorithm Hash digest
SHA256 dd610674f00e9ab5860dc2ad810622e8e671a2558117a6890061b0d7c033216f
MD5 69eb5056f38e8c766e68c06dc7bfa0af
BLAKE2b-256 fd83f3f82993999c9bef47a8e26c3699f8acceac61696c734ba31006ec4f19cd

See more details on using hashes here.

File details

Details for the file ralf_jhuapl-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: ralf_jhuapl-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for ralf_jhuapl-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7d30675e6df45e37a9057a9ae2270cbafa889ad24eee061a404d0c48ff069e02
MD5 28bde48bce6987d3ef0ca1b38d11b66b
BLAKE2b-256 0a62c4bc021a35bbe25cc5cf0cfe06c728023e3a43d7cbc9167a6a0b4666e8b7

See more details on using hashes here.

Supported by

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