Welcome to lpmn_client_biz’s documentation!

class lpmn_client_biz.Connection(username='', password='', baseurl='', config_file='', api_token='', x_token='', x_token_header=False)

Implementation of Connection class.

headers()

Sets request header.

class lpmn_client_biz.IOType(value)

Enum type for input types.

static argparse(s)

Argument parsing for argparser type.

class lpmn_client_biz.Task(lpmn: list, connection: Connection)

Implements Task class.

cancel()

Cancel running task.

get_output() str | None

Returns task output id, raises exception if task is not completed.

Returns:

output file_id if task is completed

Return type:

str, optional

get_progress() float

Returns progress of the running task.

Returns:

task progress value [0, 1]

Return type:

float

run(input: str, input_type: IOType, blocking: bool = True, timeout: float = 0, verbose: bool = False) str | None

Start task execution.

Parameters:
  • input (str) – input data file_id or text

  • input_type (InputType) – type of input text or file

  • blocking (bool) – if it is blocking method will wait for task to finish and return output file_id

  • timeout (float) – timeout for blocking task

  • verbose (bool) – if blocking task progress should be returned

Returns:

output file_id or None if not blocking task

Return type:

str, optional

run_llm_completions(**kwargs) list | None

Start llm completion task execution.

Parameters:
  • kwargs (dict) – input kwargs

  • messages (list) – list of input messages dicts with role and content

Returns:

output list of completions

Return type:

list

run_llm_edits(**kwargs) list | None

Start llm edits task execution.

Parameters:

kwargs (dict) – input kwargs

Returns:

output list of edits

Return type:

list

run_sent(texts: list) list | None

Start sentence task execution.

Parameters:

texts (list) – list of input sentences

Returns:

output list of vectors

Return type:

list, optional

run_task(input: str, media_type='text')

Start task and waits for result.

Parameters:
  • media_type (str) – type of output

  • input (str) – text input

Returns:

byte output of task

Return type:

bytes

lpmn_client_biz.archive_to_jsonl(archive_path, output_file, json_file, columns_to_take=[])

Appended archive desired columns to json file.

Parameters:
  • json_file (str) – path to the jsonl file

  • columns_to_take (list) – list of columns to take from the archive files

  • archive_path (str) – path to the zip archive

  • output_file (str) – path to the output jsonl file

lpmn_client_biz.delete(connection: Connection, file_id) str

Deleting file from server.

Parameters:
  • connection (Connection) – instance of Connection class

  • file_id (FileID) – id of file located on server

Returns:

deleted file id

Return type:

str

lpmn_client_biz.download(connection: Connection, file_id: str, output_type: IOType, output_path: str | None = None, filename: str | None = None) str

Downloading file from server.

Parameters:
  • connection (Connection) – instance of Connection class

  • output_type (IOType) – preferred type of output

  • file_id (FileID) – id of file located on server

  • output_path (str) – path to local dir where file should be downloaded if not provided value is current working directory

  • filename – target filename of downloaded file if not provided value is file_id

Returns:

downloaded file path

Return type:

str

lpmn_client_biz.jsonl_to_directory(input_path, column_name)

Converts a jsonl file to a directory with files.

Parameters:
  • input_path (str) – path to the input jsonl file

  • column_name (str) – name of the column to extract from the jsonl file

Returns:

path to the output directory

Return type:

str

lpmn_client_biz.run_json_lines(connection: Connection, lpmn, json_file_path, output_path, column_from_jsonl, columns_from_task, verbose=False)

Run a task on a jsonl file.

Parameters:
  • connection (Connection) – Task connection

  • lpmn (list) – Task lpmn

  • json_file_path (str) – path to jsonl file

  • output_path (str) – path to output file

  • column_from_jsonl (str) – column to use as input

  • columns_from_task (list) – columns form task to add to output

  • verbose (bool, optional) – verbose output, defaults to False

lpmn_client_biz.run_with_header(config_path, x_token, lpmn, action, *action_args, **action_kwargs)

Runs given action with arguments, with x-token header.

Parameters:
  • config_path (str) – path to config.ini file

  • x_token (str) – api authorization token

  • lpmn (list(str)) – json style list with lpmn commands

  • action (str) – Task class method name

  • action_args (list) – arguments for Task method

  • action_kwargs (dict) – keyword arguments for Task method

Returns:

action result

lpmn_client_biz.upload(connection: Connection, file_path: str) str

Uploading file to server.

Parameters:
  • connection (Connection) – instance of connection class

  • file_path (str) – path to local file that should be sent to server

Returns:

id of file located on server

Return type:

FileID

Indices and tables