mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-22 03:30:04 +00:00
Add tests and build workflow, bump sinceVersion
This commit is contained in:
parent
a7927eea56
commit
4ceca4e45e
16 changed files with 416 additions and 50 deletions
|
|
@ -14,7 +14,7 @@ public class PluginStartupActivity implements StartupActivity {
|
|||
public void runActivity(@NotNull Project project) {
|
||||
ActionsUtil.refreshActions(ConfigurationState.getInstance().tableData);
|
||||
var settings = SettingsState.getInstance();
|
||||
if (settings.apiKey != null && settings.useOpenAIAccountName) {
|
||||
if (!settings.apiKey.isEmpty() && settings.useOpenAIAccountName) {
|
||||
ClientProvider.getDashboardClient()
|
||||
.getSubscriptionAsync(subscription ->
|
||||
settings.displayName = subscription.getAccountName());
|
||||
|
|
|
|||
|
|
@ -53,12 +53,18 @@ public class ClientProvider {
|
|||
var proxyHost = advancedSettings.proxyHost;
|
||||
var proxyPort = advancedSettings.proxyPort;
|
||||
if (!proxyHost.isEmpty() && proxyPort != 0) {
|
||||
builder.setProxy(new Proxy(advancedSettings.proxyType, new InetSocketAddress(proxyHost, proxyPort)));
|
||||
builder.setProxy(
|
||||
new Proxy(advancedSettings.proxyType, new InetSocketAddress(proxyHost, proxyPort)));
|
||||
if (advancedSettings.isProxyAuthSelected) {
|
||||
builder.setProxyAuthenticator(new ProxyAuthenticator(advancedSettings.proxyUsername, advancedSettings.proxyPassword));
|
||||
builder.setProxyAuthenticator(
|
||||
new ProxyAuthenticator(advancedSettings.proxyUsername, advancedSettings.proxyPassword));
|
||||
}
|
||||
}
|
||||
|
||||
if (!advancedSettings.host.isEmpty()) {
|
||||
builder.setHost(advancedSettings.host);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,14 +40,13 @@ class EventListener implements CompletionEventListener {
|
|||
}
|
||||
|
||||
private void saveConversation(String response) {
|
||||
var conversationsState = ConversationsState.getInstance();
|
||||
var conversationMessages = conversation.getMessages();
|
||||
|
||||
if (isRetry && !conversationMessages.isEmpty()) {
|
||||
conversationMessages.remove(conversationMessages.size() - 1);
|
||||
}
|
||||
|
||||
message.setResponse(response);
|
||||
conversationsState.saveConversation(conversation);
|
||||
conversation.addMessage(message);
|
||||
ConversationsState.getInstance().saveConversation(conversation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ public class RequestHandler implements ActionListener {
|
|||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
|
|
@ -63,10 +62,11 @@ public class RequestHandler implements ActionListener {
|
|||
|
||||
if (settings.isChatCompletionOptionSelected) {
|
||||
return ClientProvider.getChatCompletionClient(settings).stream(
|
||||
requestProvider.buildChatCompletionRequest(settings.chatCompletionBaseModel),
|
||||
eventListener);
|
||||
requestProvider.buildChatCompletionRequest(settings.chatCompletionBaseModel),
|
||||
eventListener);
|
||||
}
|
||||
return ClientProvider.getTextCompletionClient(settings).stream(
|
||||
requestProvider.buildTextCompletionRequest(settings.textCompletionBaseModel),
|
||||
eventListener); }
|
||||
requestProvider.buildTextCompletionRequest(settings.textCompletionBaseModel),
|
||||
eventListener);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,23 +122,24 @@ public class ConversationsState implements PersistentStateComponent<Conversation
|
|||
currentConversation = null;
|
||||
}
|
||||
|
||||
public Optional<Conversation> getNextConversation() {
|
||||
public Optional<Conversation> getPreviousConversation() {
|
||||
return tryGetNextOrPreviousConversation(true);
|
||||
}
|
||||
|
||||
public Optional<Conversation> getPreviousConversation() {
|
||||
public Optional<Conversation> getNextConversation() {
|
||||
return tryGetNextOrPreviousConversation(false);
|
||||
}
|
||||
|
||||
private Optional<Conversation> tryGetNextOrPreviousConversation(boolean isNext) {
|
||||
private Optional<Conversation> tryGetNextOrPreviousConversation(boolean isPrevious) {
|
||||
if (currentConversation != null) {
|
||||
var sortedConversations = getSortedConversations();
|
||||
for (int i = 0; i < sortedConversations.size(); i++) {
|
||||
var conversation = sortedConversations.get(i);
|
||||
if (conversation != null && conversation.getId().equals(currentConversation.getId())) {
|
||||
var nextIndex = isNext ? i + 1 : i - 1;
|
||||
if (isNext ? nextIndex < sortedConversations.size() : nextIndex != -1) {
|
||||
return Optional.of(sortedConversations.get(nextIndex));
|
||||
// higher index indicates older conversation
|
||||
var previousIndex = isPrevious ? i + 1 : i - 1;
|
||||
if (isPrevious ? previousIndex < sortedConversations.size() : previousIndex != -1) {
|
||||
return Optional.of(sortedConversations.get(previousIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -147,9 +148,9 @@ public class ConversationsState implements PersistentStateComponent<Conversation
|
|||
}
|
||||
|
||||
public void deleteSelectedConversation() {
|
||||
var nextConversation = getNextConversation();
|
||||
var nextConversation = getPreviousConversation();
|
||||
if (nextConversation.isEmpty()) {
|
||||
nextConversation = getPreviousConversation();
|
||||
nextConversation = getNextConversation();
|
||||
}
|
||||
|
||||
var iterator = conversationsContainer.getConversationsMapping()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ public class Message {
|
|||
private final String prompt;
|
||||
private String response;
|
||||
|
||||
public Message(String prompt, String response) {
|
||||
this(prompt);
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
|
||||
public Message(@JsonProperty("prompt") String prompt) {
|
||||
this.id = UUID.randomUUID();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
)
|
||||
public class AdvancedSettingsState implements PersistentStateComponent<AdvancedSettingsState> {
|
||||
|
||||
public String host = "";
|
||||
public String proxyHost = "";
|
||||
public int proxyPort;
|
||||
public Proxy.Type proxyType = Proxy.Type.SOCKS;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ public class ChatToolWindowTabHtmlPanel implements ToolWindowTabPanel {
|
|||
|
||||
public void handleComplete() {
|
||||
stop();
|
||||
conversation.addMessage(message);
|
||||
}
|
||||
|
||||
public void handleTokensExceeded() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ public class MoveDownAction extends MoveAction {
|
|||
|
||||
@Override
|
||||
protected Optional<Conversation> getConversation() {
|
||||
return ConversationsState.getInstance().getNextConversation();
|
||||
return ConversationsState.getInstance().getPreviousConversation();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ public class MoveUpAction extends MoveAction {
|
|||
|
||||
@Override
|
||||
protected Optional<Conversation> getConversation() {
|
||||
return ConversationsState.getInstance().getPreviousConversation();
|
||||
return ConversationsState.getInstance().getNextConversation();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ public class ThemeUtils {
|
|||
}
|
||||
|
||||
public static String getFontColorRGB() {
|
||||
return getRGB(EditorColorsManager.getInstance().getSchemeForCurrentUITheme().getDefaultForeground());
|
||||
return getRGB(
|
||||
EditorColorsManager.getInstance().getSchemeForCurrentUITheme().getDefaultForeground());
|
||||
}
|
||||
|
||||
public static String getSeparatorColorRGB() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue