Skip to main content

LlamaForge

Ultimate Language Model Command Interface

License: MIT Version

LlamaForge is a powerful command-line tool and Python library designed to streamline working with large language models. It provides a unified interface for managing, running, and optimizing various language models from different providers.

Features

  • Multiple Backends: Support for llama.cpp, Hugging Face, and OpenAI models
  • Plugin System: Extend functionality with preprocessing, postprocessing, tools, and commands
  • API Server: OpenAI-compatible API for easy integration with existing tools
  • Command Line Interface: Simple and intuitive CLI for working with models
  • Configuration Management: Flexible configuration system for models and backends
  • Streaming Support: Stream generated text for real-time applications

Installation

Basic Installation

pip install llamaforge

With Backend Support

# For llama.cpp models
pip install "llamaforge[llama.cpp]"

# For Hugging Face models
pip install "llamaforge[huggingface]"

# For OpenAI API
pip install "llamaforge[openai]"

# For API server
pip install "llamaforge[server]"

# For all features
pip install "llamaforge[all]"

Quick Start

Python API

from llamaforge import LlamaForge

# Initialize LlamaForge
forge = LlamaForge()

# Load a model
forge.load_model("llama-2-7b-chat")

# Generate text
response = forge.generate("Explain quantum computing in simple terms")
print(response)

Command Line

# Initialize configuration
llamaforge config init

# List available models
llamaforge list models

# Chat with a model
llamaforge chat --model llama-2-7b-chat

# Generate text from a prompt
llamaforge run "Explain quantum computing in simple terms" --model llama-2-7b-chat

# Start API server
llamaforge serve --model llama-2-7b-chat

Configuration

LlamaForge uses a configuration file located at ~/.llamaforge/config.json. You can initialize it with the following command:

llamaforge config init

To set configuration values:

llamaforge config set default_model llama-2-7b-chat

To get configuration values:

llamaforge config get default_model

Plugin System

LlamaForge includes a powerful plugin system for extending functionality:

  • Preprocessing: Modify input text before sending to the model
  • Postprocessing: Clean and format model outputs
  • Tools: Add capabilities like web search, code execution, etc.
  • Commands: Extend the CLI with custom commands

Example configuration for plugins:

{
  "plugins": [
    {
      "type": "preprocessing",
      "name": "text_formatter",
      "config": {
        "trim_whitespace": true,
        "format_as_chat": true,
        "chat_format": "llama2"
      }
    },
    {
      "type": "postprocessing",
      "name": "text_cleaner",
      "config": {
        "remove_special_tokens": true,
        "trim_whitespace": true
      }
    }
  ]
}

API Server

LlamaForge includes an OpenAI-compatible API server:

llamaforge serve --host 127.0.0.1 --port 8000 --model llama-2-7b-chat

Then you can use it with OpenAI-compatible clients:

from openai import OpenAI

client = OpenAI(
    api_key="dummy",  # Not used but required
    base_url="http://127.0.0.1:8000/v1"
)

response = client.chat.completions.create(
    model="llama-2-7b-chat",
    messages=[
        {"role": "user", "content": "Hello, how are you?"}
    ]
)
print(response.choices[0].message.content)

License

LlamaForge is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llamaforge_llamasearch-0.2.0.tar.gz (86.5 kB view details)

Uploaded Source

Built Distribution

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

llamaforge_llamasearch-0.2.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file llamaforge_llamasearch-0.2.0.tar.gz.

File metadata

  • Download URL: llamaforge_llamasearch-0.2.0.tar.gz
  • Upload date:
  • Size: 86.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for llamaforge_llamasearch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f9b8254e5e10b10a7388b2265c1c1401262a94cea53c5ec6e978b4f30ee96bd8
MD5 299eb2c4cba2460ebb41c44084f26496
BLAKE2b-256 7a3228c23f3e26344e0e04560bc144ec4ebc7f23c64a8f34f3dcfe954a29bbf1

See more details on using hashes here.

File details

Details for the file llamaforge_llamasearch-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llamaforge_llamasearch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9d513346d6552acd2e2bcfe033493e9b878fb04d95fbbcc5f853e50f41f551e
MD5 30213b190d49c38b1d70a564df44ae28
BLAKE2b-256 178c21710d5d3e5750360b9b2ed8d13afb520d8c51abed5e9b51bd31bc6e9281

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

Supported by

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