mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-20 09:24:08 +00:00
feat: keep previous files in context while chatting
This commit is contained in:
parent
3c91893982
commit
88bbd96900
2 changed files with 26 additions and 4 deletions
|
|
@ -6,7 +6,6 @@ import static ee.carlrobert.codegpt.settings.IncludedFilesSettingsState.DEFAULT_
|
|||
import static ee.carlrobert.codegpt.settings.IncludedFilesSettingsState.DEFAULT_REPEATABLE_CONTEXT;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
|
|
@ -149,7 +148,9 @@ public class IncludeFilesInContextAction extends AnAction {
|
|||
|
||||
private String getVirtualFileContent(VirtualFile virtualFile) {
|
||||
try {
|
||||
return new String(Files.readAllBytes(Paths.get(virtualFile.getPath())));
|
||||
if (!virtualFile.isDirectory()) {
|
||||
return new String(Files.readAllBytes(Paths.get(virtualFile.getPath())));
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ee.carlrobert.codegpt.toolwindow.chat;
|
|||
|
||||
import static ee.carlrobert.codegpt.ui.UIUtil.createScrollPaneWithSmartScroller;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
|
|
@ -38,11 +39,15 @@ import ee.carlrobert.codegpt.ui.textarea.UserInputPanel;
|
|||
import ee.carlrobert.codegpt.util.EditorUtil;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtil;
|
||||
import java.awt.BorderLayout;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import kotlin.Unit;
|
||||
|
|
@ -139,11 +144,27 @@ public class ChatToolWindowTabPanel implements Disposable {
|
|||
message.setReferencedFilePaths(referencedFilePaths);
|
||||
message.setUserMessage(message.getPrompt());
|
||||
|
||||
totalTokensPanel.updateReferencedFilesTokens(referencedFiles);
|
||||
|
||||
chatToolWindowPanel.ifPresent(panel -> panel.clearNotifications(project));
|
||||
} else {
|
||||
referencedFiles = conversation.getMessages().stream()
|
||||
.flatMap(prevMessage -> {
|
||||
if (prevMessage.getReferencedFilePaths() != null) {
|
||||
return prevMessage.getReferencedFilePaths().stream();
|
||||
}
|
||||
return Stream.empty();
|
||||
})
|
||||
.map(filePath -> {
|
||||
try {
|
||||
return new ReferencedFile(new File(filePath));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
}
|
||||
totalTokensPanel.updateConversationTokens(conversation);
|
||||
totalTokensPanel.updateReferencedFilesTokens(referencedFiles);
|
||||
|
||||
var userMessagePanel = new UserMessagePanel(project, message, this);
|
||||
var attachedFilePath = CodeGPTKeys.IMAGE_ATTACHMENT_FILE_PATH.get(project);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue