Add OpenAI-compatible API support with configuration management and response handling
This commit is contained in:
+24
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user