Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Liu00222 Open Prompt Injection open config

From Leeroopedia
Knowledge Sources
Domains Configuration, Data_Loading
Last Updated 2026-02-14 15:00 GMT

Overview

Concrete tool for loading JSON configuration files provided by the OpenPromptInjection utility module.

Description

The open_config function reads a JSON file from disk and returns its contents as a Python dictionary. It is the entry point for all configuration-driven components in the experiment pipeline, used to load model configs, task configs, and API key information.

Usage

Import this function whenever you need to load a model or task configuration file at the start of an experiment. It is called before any factory function (create_model, create_task, etc.).

Code Reference

Source Location

Signature

def open_config(config_path):
    """
    Args:
        config_path (str): Path to a JSON configuration file.
    Returns:
        dict: Parsed JSON content.
    """
    with open(config_path, 'r') as f:
        config = json.load(f)
    return config

Import

from OpenPromptInjection.utils import open_config

I/O Contract

Inputs

Name Type Required Description
config_path str Yes Path to a JSON file (e.g., `configs/model_configs/palm2_config.json`)

Outputs

Name Type Description
config dict Parsed JSON content with keys depending on config type (model_info, params, api_key_info for models; dataset_info for tasks)

Usage Examples

Loading a Model Config

from OpenPromptInjection.utils import open_config

model_config = open_config(config_path="configs/model_configs/gpt_config.json")
# Returns: {"model_info": {"provider": "openai", "name": "gpt-3.5-turbo"}, "params": {...}, "api_key_info": {...}}

Loading a Task Config

task_config = open_config(config_path="configs/task_configs/sst2_config.json")
# Returns: {"dataset_info": {"dataset": "sst2", ...}}

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment