Skip to content

Controller

meganno_client.controller.Controller

The Controller class manages annotation agents and runs agent jobs.

__init__(service, auth)

Init function

Parameters:

Name Type Description Default
service Service

MEGAnno service object for the connected project.

required
auth Authentication

MEGAnno authentication object.

required

list_agents(created_by_filter=None, provider_filter=None, api_filter=None, show_job_list=False)

Get the list of registered agents by their issuer IDs.

Parameters:

Name Type Description Default
created_by_filter list

List of user IDs to filter agents, by default None (if None, list all)

None
provider_filter

Returns agents with the specified provider eg. openai

None
api_filter

Returns agents with the specified api eg. completion

None
show_job_list

if True, also return the list uuids of jobs of the agent.

False

Returns:

Type Description
list

A list of agents that are created by specified issuers.

list_jobs(filter_by, filter_values, show_agent_details=False)

Get the list of jobs with querying filters.

Parameters:

Name Type Description Default
filter_by str

Filter options. Must be ["agent_uuid" | "issued_by" | "uuid"] | None

required
filter_values list

List of uuids of entity specified in 'filter_by'

required
show_agent_details bool

If True, return agent configuration, by default False

False

Returns:

Type Description
list

A list of jobs that match given filtering criteria.

list_jobs_of_agent(agent_uuid, show_agent_details=False)

Get the list of jobs of a given agent.

Parameters:

Name Type Description Default
agent_uuid str

Agent uuid

required
show_agent_details bool

If True, return agent configuration, by default False

False

Returns:

Type Description
list

A list of jobs of a given agent

register_agent(model_config, prompt_template_str, provider_api)

Register an agent with backend service.

Parameters:

Name Type Description Default
model_config dict

Model configuration object

required
prompt_template_str str

Serialized prompt template

required
provider_api str

Name of provider and corresponding api eg. 'openai:chat'

required

Returns:

Type Description
dict

object with unique agent id.

persist_job(agent_uuid, job_uuid, label_name, annotation_uuid_list)

Given annoations for a subset, persist them as a job for the project.

Parameters:

Name Type Description Default
agent_uuid str

Agent uuid

required
job_uuid str

Job uuid

required
label_name str

Label name used for annotation

required
annotation_uuid_list list

List of uuids of records that have valid annotations from the job

required

Returns:

Type Description
dict

Object with job uuid and annotation count

create_agent(model_config, prompt_template, provider_api='openai:chat')

Validate model configs and register a new agent. Return new agent's uuid.

Parameters:

Name Type Description Default
model_config dict

Model configuration object

required
prompt_template str

PromptTemplate object

required
provider_api str

Name of provider and corresponding api eg. 'openai:chat'

'openai:chat'

Returns:

Name Type Description
agent_uuid str

Agent uuid

get_agent_by_uuid(agent_uuid)

Return agent model configuration, prompt template, and creator id of specified agent.

Parameters:

Name Type Description Default
agent_uuid str

Agent uuid

required

Returns:

Type Description
dict

A dict containing agent details.

list_my_agents()

Get the list of registered agents by me.

Returns:

Name Type Description
agents list

A list of agents that are created by me.

list_my_jobs(show_agent_details=False)

Get the list of jobs of issued by me.

Parameters:

Name Type Description Default
show_agent_details bool

If True, return agent configuration, by default False

False

Returns:

Name Type Description
jobs list

A list of jobs of issued by me.

run_job(agent_uuid, subset, label_name, batch_size=1, num_retrials=2, label_meta_names=[], fuzzy_extraction=False)

Create, run, and persist an LLM annotation job with given agent and subset.

Parameters:

Name Type Description Default
agent_uuid str

Uuid of an agent to be used for the job

required
subset Subset

[Megagon-only] MEGAnno Subset object to be annotated in the job

required
label_name str

Label name used for annotation

required
batch_size int

Size of batch to each Open AI prompt

1
num_retrials int

Number of retrials to OpenAI in case of failure in response

2
label_meta_names

list of label metadata names to be set

[]
fuzzy_extraction

Set to True if fuzzy extraction desired in post processing

False

Returns:

Name Type Description
job_uuid str

Job uuid