Feature: Support chatting with multiple files (#306)

* Initial implementation

* Refactor UI related classes and organize imports

* Display selected files notification, include the files in the prompt

* feat: store referenced file paths in the messate state

* feat: add selected files accordion

* feat: update UI

* feat: improve file selection

* feat: support prompt template configuration

* fix: token calculation for virtualfile checkbox tree

* refactor: clean up

* refactor: move labels/descriptions to bundle
This commit is contained in:
Carl-Robert 2023-12-12 22:30:39 +02:00 committed by GitHub
parent 4354000ddb
commit f4be25bdac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 1125 additions and 148 deletions

View file

@ -2,6 +2,7 @@ package ee.carlrobert.codegpt;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.diagnostic.Logger;
import com.knuddels.jtokkit.Encodings;
import com.knuddels.jtokkit.api.Encoding;
import com.knuddels.jtokkit.api.EncodingRegistry;
@ -12,6 +13,8 @@ import ee.carlrobert.llm.client.openai.completion.request.OpenAIChatCompletionMe
@Service
public final class EncodingManager {
private static final Logger LOG = Logger.getInstance(EncodingManager.class);
private final EncodingRegistry registry = Encodings.newDefaultEncodingRegistry();
private final Encoding encoding = registry.getEncoding(EncodingType.CL100K_BASE);
@ -42,6 +45,11 @@ public final class EncodingManager {
}
public int countTokens(String text) {
return encoding.countTokens(text);
try {
return encoding.countTokens(text);
} catch (Exception ex) {
LOG.error(ex);
return 0;
}
}
}