gupta-sahil01 commented on code in PR #6436:
URL: https://github.com/apache/texera/pull/6436#discussion_r4596303737
##########
agent-service/src/server.ts:
##########
@@ -388,6 +390,45 @@ const agentsRouter = new Elysia({ prefix: "/agents" })
}
);
+// Stateless ambient operator recommender (apache/texera#5240). Given the
+// operator a user just added, returns a short ranked list of likely next
+// operators for the canvas to render as suggestions. Version 1 uses a
+// hardcoded rule table with no LLM call, so it needs no user token and no
+// per-request model configuration; it only reads the process-wide operator
+// catalog to validate and label its suggestions.
+const recommendRouter = new Elysia({ prefix: "/recommend" })
+ // Local-scoped error handler, mirroring agentsRouter: body-schema and
+ // malformed-JSON failures are client errors (400), not 500s.
+ .onError(({ code, error, set }) => {
+ log.error({ err: error }, "recommend request error");
+ const errorMessage = error instanceof Error ? error.message :
String(error);
+ if (code === "VALIDATION" || code === "PARSE") {
+ set.status = 400;
+ return { error: errorMessage || "Invalid request body" };
+ }
+ set.status = 500;
+ return { error: errorMessage || "Internal server error" };
+ })
+ .post(
+ "/",
Review Comment:
Formatted in 1a2fd8231; `prettier --check` passes for agent-service.
##########
agent-service/src/recommender/hardcoded-rules.ts:
##########
@@ -0,0 +1,210 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hardcoded "what usually comes next" table for the Version 1 operator
+ * recommender (apache/texera#5240). Kept deliberately small and readable: a
+ * coarse category per operator, a ranked successor list per category, plus a
+ * handful of specific overrides for the most common dataflow patterns.
+ *
+ * Operator type strings here must match the `@JsonSubTypes` names registered
on
+ * `LogicalOp` (the catalog the frontend and compiler use). Suggestions are
+ * validated against the live operator catalog before being returned, so a
stale
+ * entry here degrades to "not suggested" rather than to a broken suggestion.
+ */
+
+export type OperatorCategory = "source" | "transform" | "aggregate" | "join" |
"rowOps" | "udf" | "ml" | "sink";
+
+/**
+ * Explicit category for operators whose successors don't follow from a naming
+ * heuristic. Operators absent here fall back to {@link inferCategory}.
+ */
+const OPERATOR_CATEGORY: Record<string, OperatorCategory> = {
+ // Sources — read data into the workflow.
+ CSVFileScan: "source",
+ CSVOldFileScan: "source",
+ ParallelCSVFileScan: "source",
+ JSONLFileScan: "source",
+ FileScan: "source",
+ ArrowSource: "source",
+ TextInput: "source",
+ URLFetcher: "source",
+ FileLister: "source",
+ PostgreSQLSource: "source",
+ MySQLSource: "source",
+ AsterixDBSource: "source",
+ SQLSource: "source",
Review Comment:
Gone in 1a2fd8231. The per-operator category table (including `SQLSource`
and `ParallelCSVFileScan`) was removed in favor of catalog-based
classification, and every remaining operator type in the rules is a registered
`@JsonSubTypes` name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]