You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/CompletionFunction.java
+19-1Lines changed: 19 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,25 @@
27
27
28
28
/**
29
29
* COMPLETION function generates text completions from a prompt using an inference endpoint.
30
-
* This function is not registered in the function registry.
30
+
* <p>
31
+
* This function is an internal optimization primitive used exclusively for constant folding of
32
+
* {@code COMPLETION} commands during the analysis phase. It should never be registered in the
33
+
* function registry or exposed to users, as ESQL does not currently support async functions
34
+
* in the function registry.
35
+
* <p>
36
+
* When a {@code COMPLETION} command has a foldable prompt (e.g., a literal or foldable expression),
37
+
* the analyzer transforms it into an {@code EVAL} node with a {@code CompletionFunction} expression:
38
+
* <pre>{@code
39
+
* FROM books
40
+
* | COMPLETION "Translate this text" WITH { "inference_id": "my-model" }
41
+
* }</pre>
42
+
* is internally rewritten into:
43
+
* <pre>{@code
44
+
* FROM books
45
+
* | EVAL completion = COMPLETION("Translate this text", "my-model")
46
+
* }</pre>
47
+
* The pre-optimizer then evaluates this function using {@code InferenceFunctionEvaluator} and
0 commit comments