Skip to content

ES|QL - Completion command #124405

@afoucret

Description

@afoucret

Tracked in #123043

The completion command will be used to execute a completion through an LLM using ES}QL.

Command grammar

| COMPLETION (<targetField>=)<prompt> WITH <inferenceId>

where

param required description
prompt required Provides the prompt to be executed for the row.The prompt can be built from a mix a constant and field values.
inferenceId required Endpoint used to do the completion(can be optional when we will have a default LLM in EIS).
targetField optionaldefault: completion Name of the result column.

Usage example:

Row by row

FROM search-movies
| WHERE match(plot, "Gandalf the grey")
| EVAL prompt= CONCAT(
      "Extract movie genre:\n",
       "<title>", title, "</title>",
       "<actors>", MV_CONCAT(actors, ","), "</actors">,
       "<plot>", plot, "</plot"
    )
| COMPLETION completion=prompt WITH "openai-completion" AS genre
| DROP prompt

Aggregated rows:

FROM business-news
| WHERE industry:technology AND date:today
| EVAL company_data = CONCAT(
        "<title>", title, "</title>",
        "<summary>", summary, "</summary">
        "<article>", title, "</article"
    )
| STATS company_data = VALUES(company_data) BY company
| EVAL prompt=CONCAT(
        Summarize important news for the copmany\n",
        "<company>", company, "</company>\n",
        MV_CONCAT(company_data, "\n")
    )
| COMPLETION completion=prompt WITH "openai-completion" AS company_news

Development

Tech preview scope

GA scope

  • Cross cluster support

Metadata

Metadata

Assignees

Labels

:SearchOrg/RelevanceLabel for the Search (solution/org) Relevance team>featureES|QL-uiImpacts ES|QL UIMetaTeam:Search - RelevanceThe Search organization Search Relevance teamTeam:SearchOrgMeta label for the Search Org (Enterprise Search)priority:normalA label for assessing bug priority to be used by ES engineersv9.0.0

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