Skip to content

Commit

Permalink
Set StudioBot order to first to facilitate default model
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 577009694
  • Loading branch information
Googler authored and copybara-github committed Oct 26, 2023
1 parent f56f33c commit 578a723
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class IntelliJExtManager {
*/
private static final String EXPERIMENT_SERVICE_PROPERTY = "use.intellij.ext.experiments";

private static final BoolExperiment CHATBOT =
new BoolExperiment("use.intellij.ext.chatbot", false);

public static IntelliJExtManager getInstance() {
return ApplicationManager.getApplication().getService(IntelliJExtManager.class);
}
Expand Down Expand Up @@ -132,4 +135,8 @@ public boolean isKytheEnabled() {
public static boolean isExperimentsServiceEnabled() {
return Objects.equals(System.getProperty(EXPERIMENT_SERVICE_PROPERTY), "1");
}

public boolean isChatBotEnabled() {
return isEnabled() && CHATBOT.getValue();
}
}
1 change: 1 addition & 0 deletions ext/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ proto_library(
name = "intellijext_proto",
srcs = [
"build_service.proto",
"chatbotmodel.proto",
"experiments.proto",
"intellijext.proto",
"issuetracker.proto",
Expand Down
85 changes: 85 additions & 0 deletions ext/proto/chatbotmodel.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed 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.
*/
syntax = "proto3";

package com.google.idea.blaze.ext;

option java_package = "com.google.idea.blaze.ext";
option java_multiple_files = true;
option java_outer_classname = "ChatBotModelProto";


// Request message for [GenerateAnswers].
message GenerateAnswersRequest {
// Specified when a message is continuing an existing session.
optional string session_id = 1;

// Identifies which chatbot or model to query.
optional string model_id = 2;

// Unformatted user prompt.
optional string text = 3;
}

message GenerateAnswersResponse {
optional Message response = 1;
}

message Timestamp {
// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive.
optional int64 seconds = 1;

// Non-negative fractions of a second at nanosecond resolution. Negative
// second values with fractions must still have non-negative nanos values
// that count forward in time. Must be from 0 to 999,999,999
// inclusive.
optional int32 nanos = 2;
}

// A chat message.
message Message {
// The ID of the message.
optional string message_id = 1;

// The ID of the session.
optional string session_id = 2;

// The unformatted contents of the message.
optional string text = 3;

// Identifies which model the message is associated with.
optional string model_id = 4;

optional Timestamp creation_timestamp = 5;

repeated RelatedResources related_resources = 6;
}

message RelatedResources {
// Identifies the origin url of the resource.
optional string url = 1;

// Identifies the title associated with the resource.
optional string title = 2;
}

service ChatBotModel {
// Returns GenerateAnswersResponse given GenerateAnswersRequest
rpc GenerateAnswers(GenerateAnswersRequest)
returns (GenerateAnswersResponse) {}
}
5 changes: 5 additions & 0 deletions ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.idea.blaze.ext;

import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceFutureStub;
import com.google.idea.blaze.ext.ChatBotModelGrpc.ChatBotModelBlockingStub;
import com.google.idea.blaze.ext.ExperimentsServiceGrpc.ExperimentsServiceBlockingStub;
import com.google.idea.blaze.ext.IntelliJExtGrpc.IntelliJExtBlockingStub;
import com.google.idea.blaze.ext.IssueTrackerGrpc.IssueTrackerBlockingStub;
Expand Down Expand Up @@ -78,6 +79,10 @@ public ExperimentsServiceBlockingStub getExperimentsService() {
return ExperimentsServiceGrpc.newBlockingStub(channel);
}

public ChatBotModelBlockingStub getChatBotModelService() {
return ChatBotModelGrpc.newBlockingStub(channel);
}

public LinterFutureStub getLinterService() {
return LinterGrpc.newFutureStub(channel);
}
Expand Down
6 changes: 6 additions & 0 deletions ext/src/com/google/idea/blaze/ext/IntelliJExtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceFutureStub;
import com.google.idea.blaze.ext.ChatBotModelGrpc.ChatBotModelBlockingStub;
import com.google.idea.blaze.ext.ExperimentsServiceGrpc.ExperimentsServiceBlockingStub;
import com.google.idea.blaze.ext.IntelliJExtGrpc.IntelliJExtBlockingStub;
import com.google.idea.blaze.ext.IssueTrackerGrpc.IssueTrackerBlockingStub;
Expand Down Expand Up @@ -159,6 +160,11 @@ public ExperimentsServiceBlockingStub getExperimentsService() throws IOException
return client.getExperimentsService();
}

public ChatBotModelBlockingStub getChatBotModelService() throws IOException {
IntelliJExtBlockingStub unused = connect();
return client.getChatBotModelService();
}

public LinterFutureStub getLinterService() throws IOException {
IntelliJExtBlockingStub unused = connect();
return client.getLinterService();
Expand Down

0 comments on commit 578a723

Please sign in to comment.