Skip to content

Examples

MC+A edited this page Jan 5, 2025 · 3 revisions

Setup a pipeline

The following is an example of how to setup a field with the payload and then to make the http call to the external service.

PUT _ingest/pipeline/search-knowledge@custom
{
    "description": "Adds call to NER for Inference",
    "processors": [
      {
        "set": {
          "field": "bookend_input",
          "value": """{   "text": "{{body_content}}",   "question": "", "context": "","instruction": "Extract entities from the model's output"}"""
        }
      },
      {
        "ingest_rest": {
          "field": "ner_input",
          "target_field": "ner",
          "endpoint": "https://api.plaiground.ai/mcplusa/models/predict?model_id=c9318fab-1526-1974-86c7-cat627cdd7d3&task=named_entity_recognition",
          "content_type": "application/json",
          "method": "POST",
          }
      }
    ]
  }

This will result in the output of the call from to be added to a field called ner looking something like this:

{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_version": "-3",
        "_id": "http://www.mcplusa.com/example/ner",
        "_source": {
          "ner_input": """{"text": "Japanese pitcher and freshly minted Dodgers team member Shohei Ohtani’s decade-long $700 million contract with the team — .", "question": "", "context": "","instruction": "Extract entities from the model's output"}""",
          "ner": """["Named entities in the text:\n\n1. Shohei Ohtani (Japanese pitcher and freshly minted Dodgers team member)\n2. Dodgers\n3. Contract\n4. $700 million"]"""
        },
        "_ingest": {
          "timestamp": "2024-03-07T17:27:03.636898717Z"
        }
      }
    }
  ]
}

Clone this wiki locally