Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 50 additions & 13 deletions backend/app/controller/electron_browser.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const startUrl = args[2] || 'https://www.google.com';

// This must be called before app.ready
app.commandLine.appendSwitch('remote-debugging-port', cdpPort);
app.commandLine.appendSwitch('password-store', 'basic');
app.commandLine.appendSwitch('use-mock-keychain');

console.log('[ELECTRON BROWSER] Starting with:');
console.log(' Chrome version:', process.versions.chrome);
Expand Down Expand Up @@ -36,8 +38,14 @@ app.whenReady().then(async () => {

// Check command line switches
console.log('[ELECTRON BROWSER] Command line switches:');
console.log(' user-data-dir:', app.commandLine.getSwitchValue('user-data-dir'));
console.log(' remote-debugging-port:', app.commandLine.getSwitchValue('remote-debugging-port'));
console.log(
' user-data-dir:',
app.commandLine.getSwitchValue('user-data-dir')
);
console.log(
' remote-debugging-port:',
app.commandLine.getSwitchValue('remote-debugging-port')
);

// Log partition session info
const userLoginSession = session.fromPartition('persist:user_login');
Expand All @@ -46,7 +54,12 @@ app.whenReady().then(async () => {
console.log(' Session storage path:', userLoginSession.getStoragePath());

// Check if Cookies file exists
const cookiesPath = path.join(app.getPath('userData'), 'Partitions', 'user_login', 'Cookies');
const cookiesPath = path.join(
app.getPath('userData'),
'Partitions',
'user_login',
'Cookies'
);
console.log('[ELECTRON BROWSER] Cookies path:', cookiesPath);
console.log('[ELECTRON BROWSER] Cookies exists:', fs.existsSync(cookiesPath));
if (fs.existsSync(cookiesPath)) {
Expand All @@ -60,8 +73,8 @@ app.whenReady().then(async () => {
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
webviewTag: true
}
webviewTag: true,
},
});

// Create navigation bar and webview HTML
Expand Down Expand Up @@ -305,9 +318,14 @@ app.whenReady().then(async () => {
setInterval(async () => {
try {
const cookies = await userLoginSession.cookies.get({});
console.log('[ELECTRON BROWSER] Current cookies count:', cookies.length);
console.log(
'[ELECTRON BROWSER] Current cookies count:',
cookies.length
);
if (cookies.length > 0) {
console.log('[ELECTRON BROWSER] Cookie domains:', [...new Set(cookies.map(c => c.domain))]);
console.log('[ELECTRON BROWSER] Cookie domains:', [
...new Set(cookies.map((c) => c.domain)),
]);
}
} catch (error) {
console.error('[ELECTRON BROWSER] Failed to get cookies:', error);
Expand All @@ -327,20 +345,34 @@ app.whenReady().then(async () => {

// Log cookies before flush
const cookiesBeforeFlush = await userLoginSession.cookies.get({});
console.log('[ELECTRON BROWSER] Cookies count before flush:', cookiesBeforeFlush.length);
console.log(
'[ELECTRON BROWSER] Cookies count before flush:',
cookiesBeforeFlush.length
);

// Flush storage
console.log('[ELECTRON BROWSER] Flushing storage data...');
await userLoginSession.flushStorageData();
console.log('[ELECTRON BROWSER] Storage data flushed successfully');

// Check cookies file after flush
const cookiesPath = path.join(app.getPath('userData'), 'Partitions', 'user_login', 'Cookies');
const cookiesPath = path.join(
app.getPath('userData'),
'Partitions',
'user_login',
'Cookies'
);
if (fs.existsSync(cookiesPath)) {
const stats = fs.statSync(cookiesPath);
console.log('[ELECTRON BROWSER] Cookies file size after flush:', stats.size, 'bytes');
console.log(
'[ELECTRON BROWSER] Cookies file size after flush:',
stats.size,
'bytes'
);
} else {
console.log('[ELECTRON BROWSER] WARNING: Cookies file does not exist after flush!');
console.log(
'[ELECTRON BROWSER] WARNING: Cookies file does not exist after flush!'
);
}
} catch (error) {
console.error('[ELECTRON BROWSER] Failed to flush storage data:', error);
Expand Down Expand Up @@ -368,9 +400,14 @@ app.on('before-quit', async (event) => {

// Log cookies before flush
const cookiesBeforeQuit = await userLoginSession.cookies.get({});
console.log('[ELECTRON BROWSER] Cookies count before quit:', cookiesBeforeQuit.length);
console.log(
'[ELECTRON BROWSER] Cookies count before quit:',
cookiesBeforeQuit.length
);
if (cookiesBeforeQuit.length > 0) {
console.log('[ELECTRON BROWSER] Cookie domains before quit:', [...new Set(cookiesBeforeQuit.map(c => c.domain))]);
console.log('[ELECTRON BROWSER] Cookie domains before quit:', [
...new Set(cookiesBeforeQuit.map((c) => c.domain)),
]);
}

// Flush storage
Expand Down
1 change: 1 addition & 0 deletions backend/app/model/model_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"z.ai": "openai-compatible-model",
"ModelArk": "openai-compatible-model",
"grok": "openai-compatible-model",
"ernie": "openai-compatible-model",
"llama.cpp": "openai-compatible-model",
}

Expand Down
3 changes: 2 additions & 1 deletion backend/tests/app/model/test_model_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_normalize_model_platform_maps_known_aliases():
assert normalize_model_platform("grok") == "openai-compatible-model"
assert normalize_model_platform("z.ai") == "openai-compatible-model"
assert normalize_model_platform("ModelArk") == "openai-compatible-model"
assert normalize_model_platform("ernie") == "openai-compatible-model"
assert normalize_model_platform("llama.cpp") == "openai-compatible-model"


Expand All @@ -44,7 +45,7 @@ class _Model(BaseModel):
optional_model_platform: NormalizedOptionalModelPlatform = None

item = _Model(
model_platform="llama.cpp",
model_platform="ernie",
optional_model_platform="ModelArk",
)

Expand Down
Binary file added src/assets/model/ernie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/lib/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ export const INIT_PROVODERS: Provider[] = [
is_valid: false,
model_type: '',
},
{
id: 'ernie',
name: 'Ernie',
apiKey: '',
apiHost: 'https://qianfan.baidubce.com/v2',
description: 'Baidu Ernie model configuration.',
is_valid: false,
model_type: '',
},
{
id: 'openai-compatible-model',
name: 'OpenAI Compatible',
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Agents/Models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import azureImage from '@/assets/model/azure.svg';
import bedrockImage from '@/assets/model/bedrock.svg';
import deepseekImage from '@/assets/model/deepseek.svg';
import eigentImage from '@/assets/model/eigent.svg';
import ernieImage from '@/assets/model/ernie.png';
import geminiImage from '@/assets/model/gemini.svg';
import llamaCppImage from '@/assets/model/llamacpp.svg';
import lmstudioImage from '@/assets/model/lmstudio.svg';
Expand Down Expand Up @@ -1057,6 +1058,7 @@ export default function SettingModels() {
openrouter: openrouterImage,
'tongyi-qianwen': qwenImage,
deepseek: deepseekImage,
ernie: ernieImage,
minimax: minimaxImage,
'z.ai': zaiImage,
moonshot: moonshotImage,
Expand Down
Loading