Skip to content

Commit 84ea9f0

Browse files
committed
update model providers
1 parent 1f61a27 commit 84ea9f0

11 files changed

Lines changed: 272 additions & 113 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Some components are built with [ShipAny.ai](https://shipany.ai) - AI-powered ful
121121
- [Join Discord](https://discord.gg/rDSmZ8HS39)
122122
- [Follow on X](https://x.com/workanyai)
123123

124-
# ❤️ Contributors
124+
## ❤️ Contributors
125125

126126
<a href="https://github.com/workany-ai/workany/graphs/contributors">
127127
<img src="https://contrib.rocks/image?repo=workany-ai/workany" />

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "workany",
33
"private": true,
4-
"version": "0.1.9",
4+
"version": "0.1.10",
55
"type": "module",
66
"scripts": {
77
"ver": "./scripts/version.sh",

src-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "workany-api",
3-
"version": "0.1.9",
3+
"version": "0.1.10",
44
"type": "module",
55
"scripts": {
66
"dev": "node --import tsx --watch src/index.ts",

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "workany"
3-
version = "0.1.9"
3+
version = "0.1.10"
44
description = "A Tauri App"
55
authors = ["you"]
66
edition = "2021"

src-tauri/tauri.conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "WorkAny",
4-
"version": "0.1.9",
4+
"version": "0.1.10",
55
"identifier": "ai.thinkany.workany",
66
"build": {
77
"beforeDevCommand": "pnpm dev",
@@ -39,4 +39,4 @@
3939
},
4040
"resources": []
4141
}
42-
}
42+
}
Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import type { ComponentType } from 'react';
2+
import {
3+
customProviderModels,
4+
defaultProviderIds,
5+
defaultProviders,
6+
providerDefaultModels,
7+
} from '@/shared/db/settings';
28
import {
39
Cpu,
410
Database,
@@ -29,49 +35,18 @@ export const categoryIcons: Record<
2935
about: Info,
3036
};
3137

32-
// Provider icons mapping
33-
export const providerIcons: Record<string, string> = {
34-
openrouter: '<',
35-
};
36-
37-
// Provider API Key settings URLs
38-
export const providerApiKeyUrls: Record<string, string> = {
39-
openrouter: 'https://openrouter.ai/keys',
40-
volcengine: 'https://volcengine.com/L/Sq5rSgyFu_E',
41-
};
38+
// Provider icons mapping (derived from defaultProviders)
39+
export const providerIcons: Record<string, string> = Object.fromEntries(
40+
defaultProviders.filter((p) => p.icon).map((p) => [p.id, p.icon!])
41+
);
4242

43-
// Default provider IDs that cannot be deleted
44-
export const defaultProviderIds = ['openrouter', 'volcengine'];
43+
// Provider API Key settings URLs (derived from defaultProviders)
44+
export const providerApiKeyUrls: Record<string, string> = Object.fromEntries(
45+
defaultProviders.filter((p) => p.apiKeyUrl).map((p) => [p.id, p.apiKeyUrl!])
46+
);
4547

46-
// Popular models for each provider (for suggestions)
47-
export const providerDefaultModels: Record<string, string[]> = {
48-
openrouter: [
49-
'anthropic/claude-sonnet-4-5-20250514',
50-
'anthropic/claude-opus-4-5-20250514',
51-
],
52-
anthropic: ['claude-sonnet-4-5-20250514', 'claude-opus-4-5-20250514'],
53-
openai: ['gpt-4o', 'gpt-4o-mini', 'o1-preview'],
54-
// Custom providers - provide common model name patterns
55-
default: ['claude-sonnet-4-5-20250514', 'claude-sonnet-4-20250514'],
56-
};
57-
58-
// Model suggestions for custom providers (matched by name pattern)
59-
export const customProviderModels: Record<string, string[]> = {
60-
火山: [
61-
'doubao-1-5-pro-256k-250115',
62-
'doubao-1-5-lite-32k-250115',
63-
'deepseek-v3-250324',
64-
],
65-
volcengine: [
66-
'doubao-1-5-pro-256k-250115',
67-
'doubao-1-5-lite-32k-250115',
68-
'deepseek-v3-250324',
69-
],
70-
deepseek: ['deepseek-chat', 'deepseek-coder', 'deepseek-reasoner'],
71-
moonshot: ['moonshot-v1-8k', 'moonshot-v1-32k', 'moonshot-v1-128k'],
72-
zhipu: ['glm-4-plus', 'glm-4-flash', 'glm-4-long'],
73-
qwen: ['qwen-max', 'qwen-plus', 'qwen-turbo'],
74-
};
48+
// Re-export from settings.ts for backward compatibility
49+
export { customProviderModels, defaultProviderIds, providerDefaultModels };
7550

7651
// Re-export API config
7752
export { API_PORT, API_BASE_URL } from '@/config';

src/components/settings/tabs/DataSettings.tsx

Lines changed: 111 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ interface ExportData {
4646
}
4747

4848
type OperationStatus = 'idle' | 'loading' | 'success' | 'error';
49+
type ClearType = 'tasks' | 'settings' | 'all' | null;
4950

5051
export function DataSettings() {
5152
const { t } = useLanguage();
5253
const [exportStatus, setExportStatus] = useState<OperationStatus>('idle');
5354
const [importStatus, setImportStatus] = useState<OperationStatus>('idle');
5455
const [clearStatus, setClearStatus] = useState<OperationStatus>('idle');
5556
const [showClearDialog, setShowClearDialog] = useState(false);
57+
const [confirmClearType, setConfirmClearType] = useState<ClearType>(null);
5658
const [errorMessage, setErrorMessage] = useState<string>('');
5759

5860
// Export all data
@@ -186,24 +188,40 @@ export function DataSettings() {
186188
};
187189

188190
// Clear data
189-
const handleClear = async (clearSettings: boolean) => {
191+
const handleClear = async (type: ClearType) => {
192+
if (!type) return;
193+
190194
setClearStatus('loading');
191195
setErrorMessage('');
192196
setShowClearDialog(false);
197+
setConfirmClearType(null);
193198

194199
try {
195-
// Clear workspace files first
196-
await clearWorkspaceFiles();
197-
198-
// Get all tasks and delete them with their messages
199-
const tasks = await getAllTasks();
200-
for (const task of tasks) {
201-
await deleteMessagesByTaskId(task.id);
202-
await deleteTask(task.id);
203-
}
204-
205-
// Clear settings if requested
206-
if (clearSettings) {
200+
if (type === 'settings') {
201+
// Clear settings only
202+
await clearAllSettings();
203+
} else if (type === 'tasks') {
204+
// Clear workspace files first
205+
await clearWorkspaceFiles();
206+
207+
// Get all tasks and delete them with their messages
208+
const tasks = await getAllTasks();
209+
for (const task of tasks) {
210+
await deleteMessagesByTaskId(task.id);
211+
await deleteTask(task.id);
212+
}
213+
} else if (type === 'all') {
214+
// Clear workspace files first
215+
await clearWorkspaceFiles();
216+
217+
// Get all tasks and delete them with their messages
218+
const tasks = await getAllTasks();
219+
for (const task of tasks) {
220+
await deleteMessagesByTaskId(task.id);
221+
await deleteTask(task.id);
222+
}
223+
224+
// Clear settings
207225
await clearAllSettings();
208226
}
209227

@@ -221,6 +239,25 @@ export function DataSettings() {
221239
}
222240
};
223241

242+
// Handle clear option click - show confirmation
243+
const handleClearOptionClick = (type: ClearType) => {
244+
setConfirmClearType(type);
245+
};
246+
247+
// Get confirmation message based on clear type
248+
const getConfirmMessage = (type: ClearType): string => {
249+
switch (type) {
250+
case 'tasks':
251+
return t.settings.dataClearTasksConfirm || 'Are you sure you want to delete all tasks and messages? This action cannot be undone.';
252+
case 'settings':
253+
return t.settings.dataClearSettingsConfirm || 'Are you sure you want to reset all settings to defaults? This action cannot be undone.';
254+
case 'all':
255+
return t.settings.dataClearAllConfirm || 'Are you sure you want to delete ALL data including tasks, messages, and settings? This action cannot be undone.';
256+
default:
257+
return '';
258+
}
259+
};
260+
224261
const getButtonContent = (
225262
status: OperationStatus,
226263
icon: React.ReactNode,
@@ -380,7 +417,7 @@ export function DataSettings() {
380417

381418
<div className="space-y-3">
382419
<button
383-
onClick={() => handleClear(false)}
420+
onClick={() => handleClearOptionClick('tasks')}
384421
className={cn(
385422
'flex w-full items-center justify-between rounded-lg px-4 py-3 text-left transition-colors',
386423
'border-border hover:bg-accent border'
@@ -398,7 +435,25 @@ export function DataSettings() {
398435
</button>
399436

400437
<button
401-
onClick={() => handleClear(true)}
438+
onClick={() => handleClearOptionClick('settings')}
439+
className={cn(
440+
'flex w-full items-center justify-between rounded-lg px-4 py-3 text-left transition-colors',
441+
'border-border hover:bg-accent border'
442+
)}
443+
>
444+
<div>
445+
<div className="text-foreground font-medium">
446+
{t.settings.dataClearSettingsOnly || 'Clear Settings Only'}
447+
</div>
448+
<div className="text-muted-foreground text-sm">
449+
{t.settings.dataClearSettingsOnlyDescription ||
450+
'Reset all settings to defaults, keep tasks'}
451+
</div>
452+
</div>
453+
</button>
454+
455+
<button
456+
onClick={() => handleClearOptionClick('all')}
402457
className={cn(
403458
'flex w-full items-center justify-between rounded-lg px-4 py-3 text-left transition-colors',
404459
'border border-red-500/30 bg-red-500/5 hover:bg-red-500/10'
@@ -425,6 +480,47 @@ export function DataSettings() {
425480
</div>
426481
</div>
427482
)}
483+
484+
{/* Confirmation Dialog */}
485+
{confirmClearType && (
486+
<div className="bg-background/80 fixed inset-0 z-[60] flex items-center justify-center backdrop-blur-sm">
487+
<div className="border-border bg-background mx-4 w-full max-w-md rounded-xl border p-6 shadow-lg">
488+
<div className="mb-4 flex items-center gap-3">
489+
<div className="flex size-10 items-center justify-center rounded-full bg-red-500/10 text-red-500">
490+
<AlertTriangle className="size-5" />
491+
</div>
492+
<h3 className="text-foreground text-lg font-semibold">
493+
{t.settings.dataConfirmTitle || 'Confirm'}
494+
</h3>
495+
</div>
496+
497+
<p className="text-muted-foreground mb-6 text-sm">
498+
{getConfirmMessage(confirmClearType)}
499+
</p>
500+
501+
<div className="flex gap-3">
502+
<button
503+
onClick={() => setConfirmClearType(null)}
504+
className={cn(
505+
'flex-1 rounded-lg px-4 py-2 text-sm font-medium transition-colors',
506+
'border-border text-foreground hover:bg-accent border'
507+
)}
508+
>
509+
{t.settings.dataCancel || 'Cancel'}
510+
</button>
511+
<button
512+
onClick={() => handleClear(confirmClearType)}
513+
className={cn(
514+
'flex-1 rounded-lg px-4 py-2 text-sm font-medium transition-colors',
515+
'bg-red-500 text-white hover:bg-red-600'
516+
)}
517+
>
518+
{t.settings.dataConfirmClear || 'Yes, Clear'}
519+
</button>
520+
</div>
521+
</div>
522+
</div>
523+
)}
428524
</div>
429525
);
430526
}

0 commit comments

Comments
 (0)