Configuration

PlotFilterConfig

PlotFilterConfig controls which plots are considered relevant for performance linking. Use the factory class methods to get pre-configured instances for your domain.

PlotFilterConfig

class PlotFilterConfig(BaseModel)

Bases: BaseModel

Configuration for filtering plots based on axis characteristics.

This allows domain-specific customization of what constitutes a “relevant” plot for performance data extraction.

Attributes:

NameTypeDescription
x_axis_labelslist[str]Labels that indicate a relevant x-axis (case-insensitive)
x_axis_unitslist[str]Units that indicate a relevant x-axis (case-insensitive)
y_axis_keywordslist[str]Keywords in y-axis label indicating performance metrics
y_axis_unitslist[str]Units that suggest performance data (e.g., “%”)
require_y_keyword_with_percentageboolIf True, % unit alone is not enough; the label must also contain a y_axis_keyword
filter_x_axisboolWhether to apply x-axis filtering
filter_y_axisboolWhether to apply y-axis filtering

Methods

is_relevant_x_axis(label, unit)
def is_relevant_x_axis(label, unit)

Check if x-axis indicates a relevant plot.

Parameters:

NameTypeDescriptionDefault
labelstr | NoneX-axis label (e.g., “Temperature”)required
unitstr | NoneX-axis unit (e.g., “°C”)required

Returns:

TypeDescription
boolTrue if x-axis matches configured criteria
is_relevant_y_axis(label, unit)
def is_relevant_y_axis(label, unit)

Check if y-axis indicates a performance metric.

Parameters:

NameTypeDescriptionDefault
labelstr | NoneY-axis label (e.g., “Conversion”)required
unitstr | NoneY-axis unit (e.g., “%”)required

Returns:

TypeDescription
boolTrue if y-axis matches configured criteria
for_catalysis()
def for_catalysis()

Factory method for catalysis domain (default configuration).

for_electrochemistry()
def for_electrochemistry()

Factory method for electrochemistry domain.

for_superconductivity()
def for_superconductivity()

Factory method for superconductivity domain (R(T) plots).

for_coverage()
def for_coverage()

Factory method for porous materials (adsorption isotherm plots).

no_filter()
def no_filter()

Factory method that disables all filtering (link all plots).

LLM registry

LLMConfig

class LLMConfig(model, api_key=None, api_base=None, extra_kwargs=None)

A configuration for an LLM to instantiate with dspy. Includes the model name, and optional API key name in the environment (e.g. “OPENAI_API_KEY”) and base URL. The latter is needed to call external providers with the OpenAI API. In DSPy, you can use dozens of LLM providers supported by LiteLLM. Simply follow their instructions for which {PROVIDER}_API_KEY to set and how to write pass the {provider_name}/{model_name} to the constructor.

Parameters:

NameTypeDescriptionDefault
modelstrThe name of the model to instantiate.required
api_keystr | NoneThe name of the environment variable containing the API key.None
api_basestr | NoneThe base URL of the API.None
extra_kwargsdict | Noneaddtl model-specific parameters (e.g., thinking mode).None

LLMRegistry

class LLMRegistry(configs)

A registry of LLMs to instantiate with dspy.

Parameters:

NameTypeDescriptionDefault
configsMapping[str, LLMConfig]A mapping of model names to LLM configurations.required

DSPy utilities

get_llm_from_name

def get_llm_from_name(llm_name, model_kwargs=None, system_prompt=None)

Get a dspy.LM from a given LLM name with cost tracking capabilities.

Parameters:

NameTypeDescriptionDefault
llm_namestrThe name of the LLM to get. cf. LLM_REGISTRYrequired
model_kwargsdict | NoneA dictionary of model kwargs to pass to the LLM.None
system_promptstr | NoneA system prompt to inject at the start of every call.None

Returns:

TypeDescription
LMA dspy.LM object with cost tracking capabilities.

configure_dspy

def configure_dspy(lm, model_kwargs=None, system_prompt=None)

Configure dspy with a selected LLM with cost tracking.

Parameters:

NameTypeDescriptionDefault
lmstrLLM key to configure (cf. LLM_REGISTRY).required
model_kwargsdict | NoneAdditional model kwargs (e.g., {“temperature”: 0.7}).None
system_promptstr | NoneA system prompt to inject at the start of every call.None