Skip to content

viur-framework/viur-assistant

Repository files navigation

viur-assistant

Badge showing current PyPI version Documentation Status Badge displaying the license

AI-based ViUR assistant plugin.

Usage

Install with pip

pip install viur-assistant

Install with pipenv

pipenv install viur-assistant

Register module

Import the Assistant module in the module loader in your project.

# deploy/modules/__init__.py
from viur.assistant import Assistant as assistant  # noqa

Note: the # noqa prevents your IDE from removing the import for refactorings, as this is considered unnecessary (in this file).

Configuration

Import the assistant CONFIG in your project and set up the API keys.

# deploy/main.py
from viur.core import secret
from viur.assistant import CONFIG as ASSISTANT_CONFIG

ASSISTANT_CONFIG.api_openai_key = "..."
ASSISTANT_CONFIG.api_anthropic_key = secret.get("api-anthropic-key")

Note: Using the Google Secret Manager is the more secure way. But of course the value can also be loaded from the env — as long as the value is provided as a string.

Development / Contributing

Create a fork and clone it

Setup & Run tests

  1. Install viur-assistant as editable in your project.
    cd my-project
    pip install -e path/to/viur-assistant[testing]
    cd path/to/viur-assistant
  2. Launch the local development server
  3. Get a valid session cookie and store it in the environment
    export SESSION_COOKIE="viur_cookie_$project=abc***xyz"
    This is necessary because the Assistant API is only accessible to admins.
  4. Run the tests with pytest
    pytest tests -s

Branches

Depending on what kind of change your Pull Request contains, please submit your PR against the following branches:

  • main: fixes/patches that fix a problem with existing code go into this branch.
  • develop: new features, refactorings, or adjustments for new versions of dependencies are added to this branch.