Skip to content

Add PipelineTemplateResource #24

@mathislucka

Description

@mathislucka

Overview

We want to add a PipelineTemplateResource to our AsyncDeepsetClient that allows us to interact with pipeline templates on the deepset platform. Specifically, we will allow to get a specific template by name as well as allowing to list all templates.

Roughly:

class PipelineTemplateResource:
  def __init__(self, client, workspace):
    ...
  async def get_template(template_name):
    ...
  async def list_templates(limit = 100):
    ...

API Spec
This is how to list templates:

curl --request GET \
     --url 'https://api.cloud.deepset.ai/api/v1/workspaces/workspace_name/pipeline_templates?limit=100&page_number=1&field=created_at&order=DESC' \
     --header 'accept: application/json'

This is a response example:

{
  "data": [
    {
      "author": "string",
      "available_to_all_organization_types": false,
      "best_for": [
        "string"
      ],
      "deepset_cloud_version": "v2",
      "description": "string",
      "expected_output": [
        "string"
      ],
      "indexing_yaml": "string",
      "name": "string",
      "pipeline_name": "string",
      "pipeline_template_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "pipeline_type": "indexing",
      "potential_applications": [
        "string"
      ],
      "query_yaml": "string",
      "recommended_dataset": [
        "string"
      ],
      "tags": [
        {
          "name": "string",
          "tag_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        }
      ]
    },
    {
      "additionalProp": {}
    }
  ],
  "has_more": true,
  "total": 0
}

This is how to get a single template:

curl --request GET \
     --url https://api.cloud.deepset.ai/api/v1/workspaces/some_workspace/pipeline_templates/template_name \
     --header 'accept: application/json'

This is an example response:

{
  "author": "string",
  "available_to_all_organization_types": false,
  "best_for": [
    "string"
  ],
  "deepset_cloud_version": "v2",
  "description": "string",
  "expected_output": [
    "string"
  ],
  "indexing_yaml": "string",
  "name": "string",
  "pipeline_name": "string",
  "pipeline_template_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "pipeline_type": "indexing",
  "potential_applications": [
    "string"
  ],
  "query_yaml": "string",
  "recommended_dataset": [
    "string"
  ],
  "tags": [
    {
      "name": "string",
      "tag_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    }
  ]
}

Note: We dropped the indexing_yaml. When creating a model for the PipelineTemplate you should only consider the query_yaml (same as for DeepsetPipeline).

Note: map pipeline_name to template_name in the response model

Steps

  • reference src/deepset_mcp/api/pipeline as a point of comparison to check out how to configure the PipelineTemplateResource and the corresponding models
  • add a protocol for the resource in src/deepset_mcp/api/protocols.py
  • add the resource as a method both to the AsyncClientProtocol as well as on the actual client: src/deepset_mcp/api/client.py
  • refer to test/unit/api/pipeline/test_pipeline_resource.py to see how to test a resource, test the PipelineTemplateResource using the same approach. Use the same BaseFakeClient and add the template resource
  • don't forget to add the resource to the BaseFakeClient in test/unit/conftest.py

Use the same coding style and conventions as throughout the project. Make sure to use proper type annotations. The PR should pass our CI!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions