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 = '')
CyberProfilerClient(url: str = '', authToken: str = '')Configure the client once, for every call it makes.
| Argument | Description |
|---|---|
url | The service's base URL. Defaults to https://cyberprofiler.tikos.uk. |
authToken | The client's authentication token, used by every call unless overridden. |
client.analyse(prompt: str = '', authToken: str = None, useBearerHeader: bool = False)
client.analyse(prompt: str = '', authToken: str = None, useBearerHeader: bool = False)Analyse one prompt.
Calls POST /analyse once.
| Argument | Description |
|---|---|
prompt | The text to be analysed (required, non-empty). |
authToken | A token for this call only. Defaults to the client's token. |
useBearerHeader | Send 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)
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.
| Argument | Description |
|---|---|
prompts | The texts to be analysed. |
authToken | A token for these calls only. Defaults to the client's token. |
useBearerHeader | Send 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.
