Skip to content

ES|QL - Completion command #124405

Open
Open
@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 <prompt> WITH <inferenceId> (AS <targetField>)

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 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 prompt WITH "openai-completion" AS company_news

Development

Metadata

Metadata

Assignees

Labels

:SearchOrg/RelevanceLabel for the Search (solution/org) Relevance team>featureES|QL-uiImpacts ES|QL UIMetaTeam:Search RelevanceMeta label for the Search Relevance team in Elasticsearchpriority:normalA label for assessing bug priority to be used by ES engineersv9.0.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions