Skip to main content

LLM Blocks

LLM Blocks is a Python module that helps users interact with Language Learning Model (LLM) chains. It provides a simple and flexible way to create and manage LLM chains, ensuring efficient interactions with models such as OpenAI's GPT-3.5 Turbo.

Installation

First, make sure to have Python installed. Then, to install the required dependencies for this module, run the following commands:

pip install -r requirements.txt
pip install -r requirements.dev.txt

Configuration

To run the LLM Blocks, you'll need an OpenAI API key. Store your API key in a .env file or export it as an environment variable:

For a .env file:

OPENAI_API_KEY=your_openai_api_key

For environment variables:

export OPENAI_API_KEY=your_openai_api_key

Usage

The llm_blocks folder contains the main ChatUtils class, which can be utilized to create and manage your LLM chains.

Here's a simple example of using the GenericChain class:

from llm_blocks.chat_utils import GenericChain

# Create a chain with a given template
template = "The meaning of {word} is:"
my_chain = GenericChain(template)

# Call the chain with any input you desire
response = my_chain("friendship")
print(response)

Module Structure

  • exclude.toml: Configuration file to specify files or directories to exclude.
  • requirements.dev.txt: Development dependencies for this module.
  • requirements.txt: Main dependencies for this module.
  • llm_blocks
    • chat_utils.py: Python file containing the definition of the GenericChain class and utility functions for working with LLM chains.

Logging Responses

The GenericChain class keeps a log of all interactions with the given LLM. The log is stored as a list of dictionaries and can be accessed with my_chain.logs.

Example:

for log in my_chain.logs:
    print(f'Inputs: {log["inputs"]}')
    print(f'Callback: {log["callback"]}')
    print(f'Response: {log["response"]}')
    print(f'Response Time: {log["response_time"]}')
    print('---')

Contributing

Feel free to submit pull requests, report bugs, or suggest new features through the GitHub repository. We appreciate your contributions and feedback!

License

This project is licensed under the MIT License.

Metadata

Release files for llm-blocks 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-blocks 0.2.1
File Size Uploaded
llm-blocks-0.2.1.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-blocks 0.2.1
File Interpreter ABI Platform
llm_blocks-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / llm-blocks-0.2.1.tar.gz

Download URL llm-blocks-0.2.1.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
52255a90f011be16f257f7b288c6caa580821489cb05b9edb1a9d658dff7364d
BLAKE2b-256 checksum
How to use checksums
752ff0046a9957e0a744e40b0387c923f51266575c090564c828c60c6448a249
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.1

Release files / llm_blocks-0.2.1-py3-none-any.whl

Download URL llm_blocks-0.2.1-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a69e929293f9d546171cacf4a64e5b24f8520ba1b347bf7f6bfd7fe71ae58880
BLAKE2b-256 checksum
How to use checksums
dd0e5513ee5dcc3be7cd1b20a699889e9d5c69a9556ef9824599ee9164528c80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.1

Release history Release notifications | RSS feed

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

This release

0.2.1 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page