pabloem commented on code in PR #27876:
URL: https://github.com/apache/beam/pull/27876#discussion_r1287291907
##########
plugins/beam-code-completion-plugin/src/main/java/BeamCompletionContributor.java:
##########
@@ -89,8 +98,36 @@ public boolean accepts(@NotNull PsiMethodCallExpression
psiMethodCallExpression,
@Override
public void fillCompletionVariants(@NotNull final CompletionParameters
parameters, @NotNull CompletionResultSet result) {
if (AFTER_METHOD_CALL_PATTERN.accepts(parameters.getPosition())){
- for (String transform: beamJavaSDKTransforms) {
-
result.addElement(LookupElementBuilder.create(transform).appendTailText("
org.apache.beam.sdk.transforms", true));
+ try {
+ int offset = parameters.getOffset();
+ String full_code = parameters.getOriginalFile().getText();
+ String code_to_complete = full_code.substring(0, offset);
+
+ Parameters model_parameters = new Parameters(0.1F, false);
+ RequestBody req_body_obj = new RequestBody(code_to_complete,
model_parameters);
+
+ String request_body_json = new Gson().toJson(req_body_obj);
+ String model_url =
"https://api-inference.huggingface.co/models/bigcode/starcoder";
Review Comment:
lets make this configurable with a default value of
`https://api-inference.huggingface.co/models/bigcode/starcoder-base`
##########
plugins/beam-code-completion-plugin/src/main/java/Parameters.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+
+public class Parameters {
+ private float temperature;
+ private boolean return_full_text;
Review Comment:
I recommend you create this as an AutoValue class. WDYT?
If you would prefer to avoid AutoValue, then at least make these two
variables `final`.
##########
plugins/beam-code-completion-plugin/src/main/java/RequestBody.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+
+public class RequestBody {
+ private String inputs;
+ private Parameters parameters;
Review Comment:
I recommend you create this as an AutoValue class. WDYT?
If you would prefer to avoid AutoValue, then at least make these two
variables `final`.
--
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]