graphdoc.data.dspy_data package

class graphdoc.data.dspy_data.DspyDataHelper[source]

Bases: ABC

Abstract class for creating data objects related to a given dspy.Signature.

prompt_signature() Signature | SignatureMeta[source]

Given a prompt, return a dspy.Signature object.

Parameters:

prompt (Any) – A prompt.

static _(prompt: Predict) Signature | SignatureMeta[source]

Given a dspy.Predict object, return a dspy.Signature object.

static formatted_signature(signature: Signature | SignatureMeta, example: Example) str[source]

Given a dspy.Signature and a dspy.Example, return a formatted signature as a string.

Parameters:
  • signature (dspy.Signature) – A dspy.Signature object.

  • example (dspy.Example) – A dspy.Example object.

Returns:

A formatted signature as a string.

Return type:

str

abstract static example(inputs: dict[str, Any]) Example[source]

Given a dictionary of inputs, return a dspy.Example object.

Parameters:

inputs (dict[str, Any]) – A dictionary of inputs.

Returns:

A dspy.Example object.

Return type:

dspy.Example

abstract static example_example() Example[source]

Return an example dspy.Example object with the inputs set to the example values.

Returns:

A dspy.Example object.

Return type:

dspy.Example

abstract static model_signature() ModelSignature[source]

Return a mlflow.models.ModelSignature object. Based on the example object, removes the output fields and utilizes the remaining fields to infer the model signature.

Returns:

A mlflow.models.ModelSignature object.

Return type:

mlflow.models.ModelSignature

abstract static prediction(inputs: dict[str, Any]) Prediction[source]

Given a dictionary of inputs, return a dspy.Prediction object.

Parameters:

inputs (dict[str, Any]) – A dictionary of inputs.

Returns:

A dspy.Prediction object.

Return type:

dspy.Prediction

abstract static prediction_example() Prediction[source]

Return an example dspy.Prediction object with the inputs set to the example values.

Returns:

A dspy.Prediction object.

Return type:

dspy.Prediction

abstract static trainset(inputs: dict[str, Any] | Dataset, filter_args: dict[str, Any] | None = None) list[Example][source]

Given a dictionary of inputs or a datasets.Dataset object, return a list of dspy.Example objects.

Parameters:
  • inputs (Union[dict[str, Any], datasets.Dataset]) – A dictionary of inputs or a datasets.Dataset object.

  • filter_args (Optional[dict[str, Any]]) – A dictionary of filter arguments. These are instructions for how we will filter and / or transform the inputs.

Returns:

A list of dspy.Example objects.

Return type:

list[dspy.Example]

class graphdoc.data.dspy_data.GenerationDataHelper[source]

Bases: DspyDataHelper

A helper class for creating data objects related to our Documentation Generation dspy.Signature.

The example signature is defined as: ` database_schema: str = dspy.InputField() documented_schema: str = dspy.OutputField() `

static example(inputs: dict[str, Any]) Example[source]

Given a dictionary of inputs, return a dspy.Example object.

Parameters:

inputs (dict[str, Any]) – A dictionary of inputs.

Returns:

A dspy.Example object.

Return type:

dspy.Example

static example_example() Example[source]

Return an example dspy.Example object with the inputs set to the example values.

Returns:

A dspy.Example object.

Return type:

dspy.Example

static model_signature() ModelSignature[source]

Return a mlflow.models.ModelSignature object. Based on the example object, removes the output fields and utilizes the remaining fields to infer the model signature.

Returns:

A mlflow.models.ModelSignature object.

Return type:

mlflow.models.ModelSignature

static prediction(inputs: dict[str, Any]) Prediction[source]

Given a dictionary of inputs, return a dspy.Prediction object.

Parameters:

inputs (dict[str, Any]) – A dictionary of inputs.

Returns:

A dspy.Prediction object.

Return type:

dspy.Prediction

static prediction_example() Prediction[source]

Return an example dspy.Prediction object with the inputs set to the example values.

Returns:

A dspy.Prediction object.

Return type:

dspy.Prediction

static trainset(inputs: dict[str, Any] | Dataset, filter_args: dict[str, Any] | None = None) list[Example][source]

Given a dictionary of inputs or a datasets.Dataset object, return a list of dspy.Example objects.

Parameters:
  • inputs (Union[dict[str, Any], datasets.Dataset]) – A dictionary of inputs or a datasets.Dataset object.

  • filter_args (Optional[dict[str, Any]]) – A dictionary of filter arguments. These are instructions for how we will filter and / or transform the inputs.

Returns:

A list of dspy.Example objects.

Return type:

list[dspy.Example]

class graphdoc.data.dspy_data.QualityDataHelper[source]

Bases: DspyDataHelper

A helper class for creating data objects related to our Documentation Quality dspy.Signature.

The example signature is defined as:

database_schema: str = dspy.InputField()
category: Literal["perfect", "almost perfect", "poor but correct", "incorrect"] = (
    dspy.OutputField()
)
rating: Literal[4, 3, 2, 1] = dspy.OutputField()
static example(inputs: dict[str, Any]) Example[source]

Given a dictionary of inputs, return a dspy.Example object.

Parameters:

inputs (dict[str, Any]) – A dictionary of inputs.

Returns:

A dspy.Example object.

Return type:

dspy.Example

static example_example() Example[source]

Return an example dspy.Example object with the inputs set to the example values.

Returns:

A dspy.Example object.

Return type:

dspy.Example

static model_signature() ModelSignature[source]

Return a mlflow.models.ModelSignature object. Based on the example object, removes the output fields and utilizes the remaining fields to infer the model signature.

Returns:

A mlflow.models.ModelSignature object.

Return type:

mlflow.models.ModelSignature

static prediction(inputs: dict[str, Any]) Prediction[source]

Given a dictionary of inputs, return a dspy.Prediction object.

Parameters:

inputs (dict[str, Any]) – A dictionary of inputs.

Returns:

A dspy.Prediction object.

Return type:

dspy.Prediction

static prediction_example() Prediction[source]

Return an example dspy.Prediction object with the inputs set to the example values.

Returns:

A dspy.Prediction object.

Return type:

dspy.Prediction

static trainset(inputs: dict[str, Any] | Dataset, filter_args: dict[str, Any] | None = None) list[Example][source]

Given a dictionary of inputs or a datasets.Dataset object, return a list of dspy.Example objects.

Parameters:
  • inputs (Union[dict[str, Any], datasets.Dataset]) – A dictionary of inputs or a datasets.Dataset object.

  • filter_args (Optional[dict[str, Any]]) – A dictionary of filter arguments. These are instructions for how we will filter and / or transform the inputs.

Returns:

A list of dspy.Example objects.

Return type:

list[dspy.Example]

Submodules