opto.optimizers#

Package Contents#

Classes#

OPRO

OptoPrime

API#

class OPRO(*args, **kwargs)[source]#

Bases: opto.optimizers.optoprime.OptoPrime

user_prompt_template = 'dedent(...)'#
output_format_prompt = 'dedent(...)'#
default_objective = 'Come up with a new variable in accordance to feedback.'#
construct_prompt(summary, mask=None, *args, **kwargs)[source]#

Construct the system and user prompt.

class OptoPrime(parameters: List[opto.trace.nodes.ParameterNode], config_list: List = None, *args, propagator: opto.trace.propagators.propagators.Propagator = None, objective: Union[None, str] = None, ignore_extraction_error: bool = True, include_example=False, memory_size=0, max_tokens=4096, log=True, **kwargs)[source]#

Bases: opto.optimizers.optimizer.Optimizer

representation_prompt = 'dedent(...)'#
default_objective = 'You need to change the <value> of the variables in #Variables to improve the output in accordance to...'#
output_format_prompt = 'dedent(...)'#
example_problem_template = 'dedent(...)'#
user_prompt_template = 'dedent(...)'#
example_prompt = 'dedent(...)'#
final_prompt = 'dedent(...)'#
default_propagator()[source]#

Return the default Propagator object of the optimizer.

summarize()[source]#
static repr_node_value(node_dict)[source]#
static repr_node_constraint(node_dict)[source]#
probelm_instance(summary, mask=None)[source]#
construct_prompt(summary, mask=None, *args, **kwargs)[source]#

Construct the system and user prompt.

construct_update_dict(suggestion: Dict[str, Any]) Dict[opto.trace.nodes.ParameterNode, Any][source]#

Convert the suggestion in text into the right data type.

extract_llm_suggestion(response: str)[source]#

Extract the suggestion from the response.

call_llm(system_prompt: str, user_prompt: str, verbose: Union[bool, str] = False, max_tokens: int = 4096)[source]#

Call the LLM with a prompt and return the response.