Python SDK reference

CyberProfilerClient, the tikos library's client for the Cyber Profiler API.

Install the library, then import the client:

pip install tikos
from tikos.profiler.cyberprofiler import CyberProfilerClient

See Quickstart for a worked example.

CyberProfilerClient(url: str = '', authToken: str = '')

Configure the client once, for every call it makes.

ArgumentDescription
urlThe service's base URL. Defaults to https://cyberprofiler.tikos.uk.
authTokenThe client's authentication token, used by every call unless overridden.

client.analyse(prompt: str = '', authToken: str = None, useBearerHeader: bool = False)

Analyse one prompt.

Calls POST /analyse once.

ArgumentDescription
promptThe text to be analysed (required, non-empty).
authTokenA token for this call only. Defaults to the client's token.
useBearerHeaderSend the token as an Authorization: Bearer <token> header rather than in the request body.

Returns: tuple: (status_code, reason, text) from the HTTP response, where text is the JSON response body.

Raises: requests.RequestException: The request couldn't be sent or answered.

client.analysePrompts(prompts: [str] = None, authToken: str = None, useBearerHeader: bool = False)

Analyse several prompts at once, on parallel threads.

Calls POST /analyse once per prompt.

ArgumentDescription
promptsThe texts to be analysed.
authTokenA token for these calls only. Defaults to the client's token.
useBearerHeaderSend the token as an Authorization: Bearer <token> header rather than in the request body.

Returns: list: concurrent.futures.Future objects, in the order they finished. Each future's result() is (prompt, (status_code, reason, text)), or (False, False) if that prompt's request raised an exception.