You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.1 kB

10 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # dora-llama-cpp-python
  2. A Dora node that provides access to LLaMA-based models using either llama.cpp or Hugging Face backends for text generation.
  3. ## Features
  4. - Supports both llama.cpp (CPU) and Hugging Face (CPU/GPU) backends
  5. - Easy integration with speech-to-text and text-to-speech pipelines
  6. - Configurable system prompts and activation words
  7. - Chat history support with Hugging Face models
  8. - Lightweight CPU inference with GGUF models
  9. ## Getting started
  10. ### Installation
  11. ```bash
  12. uv venv -p 3.11 --seed
  13. uv pip install -e .
  14. ```
  15. ## Usage
  16. The node can be configured in your dataflow YAML file:
  17. ```yaml
  18. - id: dora-llama-cpp-python
  19. build: pip install -e path/to/dora-llama-cpp-python
  20. path: dora-llama-cpp-python
  21. inputs:
  22. text: source_node/text # Input text to generate response for
  23. outputs:
  24. - text # Generated response text
  25. env:
  26. MODEL_BACKEND: "llama-cpp" # or "huggingface"
  27. SYSTEM_PROMPT: "You're a very succinct AI assistant with short answers."
  28. ACTIVATION_WORDS: "what how who where you" # Space-separated activation words
  29. ```
  30. ### Configuration Options
  31. - `MODEL_BACKEND`: Choose between:
  32. - `llama-cpp`: Uses GGUF models via llama.cpp (CPU-optimized, default)
  33. - `huggingface`: Uses Hugging Face Transformers models
  34. - `SYSTEM_PROMPT`: Customize the AI assistant's personality/behavior
  35. - `ACTIVATION_WORDS`: Space-separated list of words that trigger model response
  36. ## Example yml
  37. ### Basic Speech-to-Text-to-Speech Pipeline
  38. This example shows how to create a conversational AI pipeline that:
  39. 1. Captures audio from microphone
  40. 2. Converts speech to text
  41. 3. Generates AI responses
  42. 4. Converts responses back to speech
  43. ```yaml
  44. nodes:
  45. - id: dora-microphone
  46. build: pip install dora-microphone
  47. path: dora-microphone
  48. inputs:
  49. tick: dora/timer/millis/2000
  50. outputs:
  51. - audio
  52. - id: dora-vad
  53. build: pip install dora-vad
  54. path: dora-vad
  55. inputs:
  56. audio: dora-microphone/audio
  57. outputs:
  58. - audio
  59. - timestamp_start
  60. - id: dora-whisper
  61. build: pip install dora-distil-whisper
  62. path: dora-distil-whisper
  63. inputs:
  64. input: dora-vad/audio
  65. outputs:
  66. - text
  67. - id: dora-llama-cpp-python
  68. build: pip install -e .
  69. path: dora-llama-cpp-python
  70. inputs:
  71. text: dora-whisper/text
  72. outputs:
  73. - text
  74. env:
  75. MODEL_BACKEND: llama-cpp
  76. SYSTEM_PROMPT: "You're a helpful assistant."
  77. ACTIVATION_WORDS: "hey help what how"
  78. - id: dora-tts
  79. build: pip install dora-kokoro-tts
  80. path: dora-kokoro-tts
  81. inputs:
  82. text: dora-llama-cpp-python/text
  83. outputs:
  84. - audio
  85. ```
  86. ### Running the Example
  87. ```bash
  88. dora build example.yml
  89. dora run example.yml
  90. ```
  91. ## Contribution Guide
  92. - Format with [ruff](https://docs.astral.sh/ruff/):
  93. ```bash
  94. uv pip install ruff
  95. uv run ruff check . --fix
  96. ```
  97. - Lint with ruff:
  98. ```bash
  99. uv run ruff check .
  100. ```
  101. - Test with [pytest](https://github.com/pytest-dev/pytest)
  102. ```bash
  103. uv pip install pytest
  104. uv run pytest . # Test
  105. ```
  106. ## License
  107. dora-llama-cpp-python's code is released under the MIT License