Skip to main content

dora-llama-cpp-python

A Dora node that provides access to LLaMA models using llama-cpp-python for efficient CPU/GPU inference.

Features

  • GPU acceleration support (CUDA on Linux, Metal on macOS)
  • Easy integration with speech-to-text and text-to-speech pipelines
  • Configurable system prompts and activation words
  • Lightweight CPU inference with GGUF models
  • Thread-level CPU optimization
  • Adjustable context window size

Getting started

Installation

uv venv -p 3.11 --seed
uv pip install -e .

Usage

The node can be configured in your dataflow YAML file:

# Using a HuggingFace model
- id: dora-llama-cpp-python
  build: pip install -e path/to/dora-llama-cpp-python
  path: dora-llama-cpp-python
  inputs:
    text: source_node/text  # Input text to generate response for
  outputs:
    - text  # Generated response text
  env:
    MODEL_NAME_OR_PATH: "TheBloke/Llama-2-7B-Chat-GGUF"
    MODEL_FILE_PATTERN: "*Q4_K_M.gguf"
    SYSTEM_PROMPT: "You're a very succinct AI assistant with short answers."
    ACTIVATION_WORDS: "what how who where you"
    MAX_TOKENS: "512"
    N_GPU_LAYERS: "35"     # Enable GPU acceleration
    N_THREADS: "4"         # CPU threads
    CONTEXT_SIZE: "4096"   # Maximum context window

Configuration Options

  • MODEL_NAME_OR_PATH: Path to local model file or HuggingFace repo id (default: "TheBloke/Llama-2-7B-Chat-GGUF")
  • MODEL_FILE_PATTERN: Pattern to match model file when downloading from HF (default: "*Q4_K_M.gguf")
  • SYSTEM_PROMPT: Customize the AI assistant's personality/behavior
  • ACTIVATION_WORDS: Space-separated list of words that trigger model response
  • MAX_TOKENS: Maximum number of tokens to generate (default: 512)
  • N_GPU_LAYERS: Number of layers to offload to GPU (default: 0, set to 35 for GPU acceleration)
  • N_THREADS: Number of CPU threads to use (default: 4)
  • CONTEXT_SIZE: Maximum context window size (default: 4096)

Example: Speech Assistant Pipeline

This example shows how to create a conversational AI pipeline that:

  1. Captures audio from microphone
  2. Converts speech to text
  3. Generates AI responses
  4. Converts responses back to speech
nodes:
  - id: dora-microphone
    build: pip install dora-microphone
    path: dora-microphone
    inputs:
      tick: dora/timer/millis/2000
    outputs:
      - audio

  - id: dora-vad
    build: pip install dora-vad
    path: dora-vad
    inputs:
      audio: dora-microphone/audio
    outputs:
      - audio
      - timestamp_start

  - id: dora-whisper
    build: pip install dora-distil-whisper
    path: dora-distil-whisper
    inputs:
      input: dora-vad/audio
    outputs:
      - text

  - id: dora-llama-cpp-python
    build: pip install -e .
    path: dora-llama-cpp-python
    inputs:
      text: dora-whisper/text
    outputs:
      - text
    env:
      MODEL_NAME: "TheBloke/Llama-2-7B-Chat-GGUF"
      MODEL_FILE_PATTERN: "*Q4_K_M.gguf"
      SYSTEM_PROMPT: "You're a helpful assistant."
      ACTIVATION_WORDS: "hey help what how"
      MAX_TOKENS: "512"
      N_GPU_LAYERS: "35"
      N_THREADS: "4"
      CONTEXT_SIZE: "4096"

  - id: dora-tts
    build: pip install dora-kokoro-tts
    path: dora-kokoro-tts
    inputs:
      text: dora-llama-cpp-python/text
    outputs:
      - audio

Running the Example

dora build example.yml
dora run example.yml

Contribution Guide

uv pip install ruff
uv run ruff check . --fix
  • Lint with ruff:
uv run ruff check .
uv pip install pytest
uv run pytest . # Test

License

dora-llama-cpp-python is released under the MIT License

Metadata

Release files for dora-llama-cpp-python 1.0.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 dora-llama-cpp-python 1.0.1
File Size Uploaded Provenance Actions
dora_llama_cpp_python-1.0.1.tar.gz 4.6 kB Without provenance Details for dora_llama_cpp_python-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dora-llama-cpp-python 1.0.1
File Interpreter ABI Platform Actions
dora_llama_cpp_python-1.0.1-py3-none-any.whl Python 3 none any Details for dora_llama_cpp_python-1.0.1-py3-none-any.whl

Total release size: 9.7 kB

Release files / dora_llama_cpp_python-1.0.1.tar.gz

Download URL dora_llama_cpp_python-1.0.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f876b2efeb8ea108a18e6fae600adc81083014eb8bcb98e562221ae2c31236c9
BLAKE2b-256 checksum
How to use checksums
1de80adf73ce0e31a20f41aa701af4ff39b18c78ad50f20a23797c5d713a3263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.12

Release files / dora_llama_cpp_python-1.0.1-py3-none-any.whl

Download URL dora_llama_cpp_python-1.0.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
406cf0f68bd07df08e96020b6676dc75c3dc9b57b77e7f47a58957ab20c609f6
BLAKE2b-256 checksum
How to use checksums
93eeeb276ef7458e7a68a7870de274d86ed908824d5a036fe6f61b3791989edb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.12

Security for dora-llama-cpp-python 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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