-
Notifications
You must be signed in to change notification settings - Fork 25.4k
[ES|QL] Add doc for the COMPLETION command #131010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b04a881
Update COMPLETION command documentation with examples
afoucret 2fe94e4
Update COMPLETION docs to use new applies_to system
afoucret 9c9b0a9
Added missing include.
afoucret 5f7c6ba
Fix typo
afoucret 409be85
Addressing PR reviews.
afoucret 700b147
Rewording.
afoucret 126e5dd
Update docs/reference/query-languages/esql/_snippets/commands/layout/…
afoucret 93e5cdd
Update docs/reference/query-languages/esql/_snippets/commands/layout/…
afoucret ac57221
Apply suggestions from code review
afoucret 3db3597
Fix requirements section.
afoucret e01f6c4
Apply suggestions from code review
afoucret File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
docs/reference/query-languages/esql/_snippets/commands/layout/completion.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
## `COMPLETION` [esql-completion] | ||
|
||
```yaml {applies_to} | ||
serverless: preview | ||
stack: preview 9.1.0 | ||
``` | ||
|
||
The `COMPLETION` processing command generates text completions using a specified LLM (Large Language Model). | ||
|
||
**Syntax** | ||
|
||
```esql | ||
COMPLETION [column =] prompt WITH inference_id | ||
``` | ||
|
||
**Parameters** | ||
|
||
`column` | ||
: (Optional) The name of the output column that will contain the completion results. | ||
If not specified, the results will be stored in a column named `completion`. | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
If the specified column already exists, it will be overwritten with the new completion results. | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`prompt` | ||
: The input text or expression that will be used as the prompt for the completion. | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This can be a string literal or a reference to a column containing text. | ||
|
||
`inference_id` | ||
: The ID of the inference endpoint to use for text completion. | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The inference endpoint must be configured with the `completion` task type. | ||
|
||
**Description** | ||
|
||
The `COMPLETION` command uses a machine learning model to generate text completions based on the provided prompt. | ||
|
||
The command works with any LLM deployed to | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
the [Elasticsearch inference API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put) | ||
and can be chained with other ES|QL commands for further processing. | ||
|
||
**Examples** | ||
|
||
Basic completion with an inline prompt: | ||
|
||
```esql | ||
ROW question = "What is Elasticsearch?" | ||
| COMPLETION answer = question WITH test_completion_model | ||
| KEEP question, answer | ||
``` | ||
|
||
| question:keyword | answer:keyword | | ||
| --- | --- | | ||
| What is Elasticsearch? | A distributed search and analytics engine | | ||
|
||
|
||
Summarizing the top 10 highest-rated movies using a prompt: | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```esql | ||
FROM movies | ||
| SORT rating DESC | ||
| LIMIT 10 | ||
| EVAL prompt = CONCAT( | ||
"Summarize this movie using the following information: \n", | ||
"Title: ", title, "\n", | ||
"Synopsis: ", synopsis, "\n", | ||
"Actors: ", MV_CONCAT(actors, ", "), "\n", | ||
) | ||
| COMPLETION summary = prompt WITH test_completion_model | ||
| KEEP title, summary, rating | ||
``` | ||
|
||
|
||
| title:keyword | summary:keyword | rating:double | | ||
| --- | --- | --- | | ||
| The Shawshank Redemption | A tale of hope and redemption in prison. | 9.3 | | ||
| The Godfather | A mafia family's rise and fall. | 9.2 | | ||
| The Dark Knight | Batman battles the Joker in Gotham. | 9.0 | | ||
| Pulp Fiction | Interconnected crime stories with dark humor. | 8.9 | | ||
| Fight Club | A man starts an underground fight club. | 8.8 | | ||
| Inception | A thief steals secrets through dreams. | 8.8 | | ||
| The Matrix | A hacker discovers reality is a simulation. | 8.7 | | ||
| Parasite | Class conflict between two families. | 8.6 | | ||
| Interstellar | A team explores space to save humanity. | 8.6 | | ||
| The Prestige | Rival magicians engage in dangerous competition. | 8.5 | | ||
|
1 change: 1 addition & 0 deletions
1
docs/reference/query-languages/esql/_snippets/lists/processing-commands.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.