Skip to content
nucliaPublic

About

Nuclia Python SDK

Resources

Stars

7 stars

Watchers

7 watching

Forks

Repository files navigation

Nuclia Python Client

In order to install

pip install nuclia

Authentication

Nuclia

You can login with your Nuclia user How to sign-up via

nuclia auth login

Nuclia Knowledgebox

You can login to a specific knowledgebox if you have a Service Token (How to get a Service Token) or your NucliaDB is deployed on-premise

nuclia auth kb --url KB_URL --token SERVICE_TOKEN

KB_URL its the url of the Knowledge Box. On the cloud service you can retrieve it on the dashboard. On the on-premise/community deployment its the url mapped to it.

Nuclia Understanding API

You can login with a Nuclia Understanding API key to process files, predict and train using our system

nuclia auth nua --key ZZZZ

Guardrails

Account guardrail policies can be managed with the synchronous or asynchronous SDK:

from nuclia_models.accounts.guardrails import CreateGuardrailPolicy
from nuclia.sdk import NucliaGuardrails

guardrails = NucliaGuardrails()
policy = guardrails.create(
    CreateGuardrailPolicy(
        name="Safety policy",
        instruction="Flag requests that ask for dangerous instructions.",
        query="Does the request violate the safety policy?",
        enabled=True,
        blocking=True,
    ),
    zone="europe-1",
)

Enabled account policies are evaluated automatically for Predict chat requests. Content can also be evaluated directly against a configured or inline policy:

from nuclia_models.predict.guardrails import GuardrailRequest
from nuclia.sdk import NucliaPredict

result = NucliaPredict().guardrail(
    GuardrailRequest(
        content="Content to evaluate",
        policy_id=str(policy.id),
    )
)

Policy violations always block chat generation. The blocking setting controls failure handling: evaluation failures fail closed when enabled and fail open when disabled.

Documentation

You can find the documentation here

For internal use

Find more information on the internal CI setup here

About

Nuclia Python SDK

Resources

Stars

7 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages