Skip to content

Serialisation of the PromptModel is broken if the invocation_layer_class param is set, both from and to yaml #6495

@CoLdIcE42

Description

@CoLdIcE42

Describe the bug
A clear and concise description of what the bug is.

I am using a pipeline that uses a PromptModel with an invocation_layer_class specified, to deploy Haystack API via docker.
On executing docker-compose up this will result in the error described below.

yml file:

name: PromptModel
params:
api_key: EMPTY
invocation_layer_class: !!python/name:haystack.nodes.prompt.invocation_layer.open_ai.OpenAIInvocationLayer ''
max_length: 1024
model_kwargs:
api_base: http://localhost:8100/v1
maximum_context_length: 2048
type: PromptModel

Error message
Error that was thrown (if available)

yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/name:haystack.nodes.prompt.invocation_layer.open_ai.OpenAIInvocationLayer'

Expected behavior
A clear and concise description of what you expected to happen.

I expected the pipleline to load correctly.

Additional context
Add any other context about the problem here, like document types / preprocessing steps / settings of reader etc.

The issue has been replicated by @anakin87

To Reproduce
Steps to reproduce the behavior

  1. Serialize a pipeline with a PromptModel with invocation_layer_class param, to yaml
  2. Load the pipeline in the haystack api docker container

FAQ Check

System:

  • OS: Windows11 + WSL2
  • GPU/CPU: GPU
  • Haystack version (commit or version number): 1.22.1
  • DocumentStore: WeaviateDocumentStore
  • Reader: -
  • Retriever: EmbeddingRetriever

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions