Add OpenAI-compatible API support with configuration management and response handling

This commit is contained in:
Илья Глазунов
2026-02-14 20:18:02 +03:00
parent bfd76dc0c1
commit bd62cf5524
4 changed files with 340 additions and 19 deletions
+24 -1
View File
@@ -13,7 +13,10 @@ const DEFAULT_CONFIG = {
const DEFAULT_CREDENTIALS = {
apiKey: '',
groqApiKey: ''
groqApiKey: '',
openaiCompatibleApiKey: '',
openaiCompatibleBaseUrl: '',
openaiCompatibleModel: ''
};
const DEFAULT_PREFERENCES = {
@@ -27,6 +30,7 @@ const DEFAULT_PREFERENCES = {
fontSize: 'medium',
backgroundTransparency: 0.8,
googleSearchEnabled: false,
responseProvider: 'gemini',
ollamaHost: 'http://127.0.0.1:11434',
ollamaModel: 'llama3.1',
whisperModel: 'Xenova/whisper-small',
@@ -204,6 +208,23 @@ function setGroqApiKey(groqApiKey) {
return setCredentials({ groqApiKey });
}
function getOpenAICompatibleConfig() {
const creds = getCredentials();
return {
apiKey: creds.openaiCompatibleApiKey || '',
baseUrl: creds.openaiCompatibleBaseUrl || '',
model: creds.openaiCompatibleModel || ''
};
}
function setOpenAICompatibleConfig(apiKey, baseUrl, model) {
return setCredentials({
openaiCompatibleApiKey: apiKey,
openaiCompatibleBaseUrl: baseUrl,
openaiCompatibleModel: model
});
}
// ============ PREFERENCES ============
function getPreferences() {
@@ -500,6 +521,8 @@ module.exports = {
setApiKey,
getGroqApiKey,
setGroqApiKey,
getOpenAICompatibleConfig,
setOpenAICompatibleConfig,
// Preferences
getPreferences,