Skip to content

v0.1.1

Choose a tag to compare

@MaxMLang MaxMLang released this 03 May 15:31
· 29 commits to main since this release

Release v0.1.1

This release introduces significant enhancements, including support for local GGUF models, improved Groq API integration, a new pytest-based test suite, and CI fixes.

✨ New Features

  • GGUF Model Support: Added the ability to use local GGUF models for detection via llama-cpp-python.
    • Install with the optional extra: pip install pytector[gguf]
    • Initialize the detector by passing the local .gguf file path to model_name_or_url.
    • Detection uses a basic prompting method ("Is this an attack? Yes/No") and returns (True/False, None) as probability scores are not available. Reliability may vary depending on the model.
    • Note: Requires llama-cpp-python, which may need C++ build tools (compiler, CMake) installed. See the llama-cpp-python documentation for details.
  • Pytest Test Suite: Introduced a new test suite using pytest located in the tests/ directory.
    • Includes fixtures for different detector types and uses conditional skipping based on environment variables (GROQ_API_KEY, PYTECTOR_TEST_GGUF_PATH) and library availability (llama-cpp-python).
    • Added tests for initialization errors, local models, Groq API, and GGUF models.

🚀 Improvements

  • Groq API Integration:
    • Improved error handling to catch specific groq.APIError / groq.APIConnectionError and return (None, "API_ERROR").
    • Enhanced response parsing to handle different response formats and return (False, "PARSE_ERROR") if the hazard code cannot be extracted.
    • Made the Groq model configurable via the groq_model parameter in __init__.
    • Cleaned up detect_injection_api signature (removed redundant parameters).
  • Documentation: Updated README.md and docs/PromptInjectionDetector.md extensively to cover GGUF usage, prerequisites, refined Groq API details, testing instructions, and updated method signatures/examples.
  • Setup & Dependencies:
    • Added [gguf] and [test] extras to setup.py for optional dependencies.
    • Removed outdated test configuration (tests_require, setup_requires).

🐛 Fixes

  • CI Workflows: Fixed GitHub Actions (tests.yml, workflow.yml) to correctly install dependencies using pip install -e ".[test]" and execute tests using pytest -v.
  • Missing Dependency: Added groq to the base install_requires list in setup.py.

Installation / Upgrade

pip install --upgrade pytector
# or for GGUF support:
pip install --upgrade pytector[gguf]