mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-16 11:15:34 +00:00
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:
parent
4354000ddb
commit
f4be25bdac
62 changed files with 1125 additions and 148 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue