Skip to content

Commit a2d29d4

Browse files
committed
fix: improve loading and reduce model options
1 parent 3bc36b3 commit a2d29d4

5 files changed

Lines changed: 46 additions & 60 deletions

File tree

packages/ai-powerups/src/admin/presentation/WbContentGeneration/GenerateContentDialog.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import { GenerateContentFeature } from "./feature.js";
1111
import { decompressGzipBase64 } from "./decompressGzipBase64.js";
1212
import type { CreateElementParams } from "./abstractions.js";
1313

14+
function formatElapsed(totalSeconds: number): string {
15+
const minutes = Math.floor(totalSeconds / 60);
16+
const seconds = totalSeconds % 60;
17+
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
18+
}
19+
1420
export const GENERATE_CONTENT_DIALOG = "generate-content";
1521

1622
export const WS_ACTION_CONTENT = "aiPowerUps.generatePageContent.content";
@@ -144,7 +150,20 @@ export const GenerateContentDialog = observer(() => {
144150
}
145151
>
146152
{vm.loading ? <OverlayLoader text={"Loading..."} /> : null}
147-
{vm.submitting ? <OverlayLoader text={"Generating content..."} /> : null}
153+
{vm.submitting ? (
154+
<OverlayLoader
155+
className={"bg-neutral-base/90"}
156+
text={
157+
<>
158+
<div>Generating content... {formatElapsed(vm.elapsedSeconds)}</div>
159+
<div className="text-sm text-neutral-muted pt-xs">
160+
Content generation can take a few minutes, depending on the model
161+
you&apos;re using.
162+
</div>
163+
</>
164+
}
165+
/>
166+
) : null}
148167
{vm.processing ? <OverlayLoader text={"Processing content..."} /> : null}
149168
{vm.form ? <FormView name="GenerateContent" form={vm.form} /> : null}
150169
</Dialog>

packages/ai-powerups/src/admin/presentation/WbContentGeneration/GenerateContentPresenter.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class GenerateContentPresenterImpl implements GenerateContentPresenter.Interface
1919
private _form: FormModel.Interface | null = null;
2020
private _settings: IAiPowerUpsSettings | null = null;
2121
private _timeoutId: ReturnType<typeof setTimeout> | null = null;
22+
private _intervalId: ReturnType<typeof setInterval> | null = null;
23+
private _elapsedSeconds = 0;
2224

2325
constructor(
2426
private toolRegistry: ToolRegistry.Interface,
@@ -36,7 +38,8 @@ class GenerateContentPresenterImpl implements GenerateContentPresenter.Interface
3638
loading: this._loading,
3739
submitting: this._submitting,
3840
processing: this._processing,
39-
timedOut: this._timedOut
41+
timedOut: this._timedOut,
42+
elapsedSeconds: this._elapsedSeconds
4043
};
4144
}
4245

@@ -145,11 +148,18 @@ class GenerateContentPresenterImpl implements GenerateContentPresenter.Interface
145148

146149
private startTimeout(): void {
147150
this.clearTimeout();
151+
this._elapsedSeconds = 0;
152+
this._intervalId = setInterval(() => {
153+
runInAction(() => {
154+
this._elapsedSeconds++;
155+
});
156+
}, 1000);
148157
this._timeoutId = setTimeout(() => {
149158
runInAction(() => {
150159
this._submitting = false;
151160
this._timedOut = true;
152161
});
162+
this.clearInterval();
153163
}, SUBMIT_TIMEOUT_MS);
154164
}
155165

@@ -158,6 +168,14 @@ class GenerateContentPresenterImpl implements GenerateContentPresenter.Interface
158168
clearTimeout(this._timeoutId);
159169
this._timeoutId = null;
160170
}
171+
this.clearInterval();
172+
}
173+
174+
private clearInterval(): void {
175+
if (this._intervalId !== null) {
176+
clearInterval(this._intervalId);
177+
this._intervalId = null;
178+
}
161179
}
162180

163181
private buildForm() {

packages/ai-powerups/src/admin/presentation/WbContentGeneration/abstractions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface IGenerateContentVm {
1717
submitting: boolean;
1818
processing: boolean;
1919
timedOut: boolean;
20+
elapsedSeconds: number;
2021
}
2122

2223
export interface IGenerateContentPresenter {

packages/api-core/src/features/ai/AnthropicSdkFactory.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,12 @@ import { AiSdkFactory as AiSdkFactoryAbstraction } from "./abstractions.js";
33
import type { IAiSdk, IAiSdkModel } from "./abstractions.js";
44

55
const ANTHROPIC_MODELS: IAiSdkModel[] = [
6-
{ id: "claude-3-haiku-20240307", name: "Claude 3 Haiku" },
7-
{ id: "claude-haiku-4-5-20251001", name: "Claude Haiku 4.5" },
8-
{ id: "claude-haiku-4-5", name: "Claude Haiku 4.5" },
9-
{ id: "claude-opus-4-0", name: "Claude Opus 4" },
10-
{ id: "claude-opus-4-20250514", name: "Claude Opus 4" },
11-
{ id: "claude-opus-4-1-20250805", name: "Claude Opus 4.1" },
12-
{ id: "claude-opus-4-1", name: "Claude Opus 4.1" },
6+
{ id: "claude-opus-4-7", name: "Claude Opus 4.7" },
7+
{ id: "claude-opus-4-6", name: "Claude Opus 4.6" },
138
{ id: "claude-opus-4-5", name: "Claude Opus 4.5" },
14-
{ id: "claude-opus-4-5-20251101", name: "Claude Opus 4.5" },
15-
{ id: "claude-sonnet-4-0", name: "Claude Sonnet 4" },
16-
{ id: "claude-sonnet-4-20250514", name: "Claude Sonnet 4" },
17-
{ id: "claude-sonnet-4-5-20250929", name: "Claude Sonnet 4.5" },
18-
{ id: "claude-sonnet-4-5", name: "Claude Sonnet 4.5" },
199
{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
20-
{ id: "claude-opus-4-6", name: "Claude Opus 4.6" }
10+
{ id: "claude-sonnet-4-5", name: "Claude Sonnet 4.5" },
11+
{ id: "claude-haiku-4-5", name: "Claude Haiku 4.5" }
2112
];
2213

2314
class AnthropicSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {

packages/api-core/src/features/ai/OpenAiSdkFactory.ts

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,19 @@ import { createImplementation } from "@webiny/feature/api";
22
import { AiSdkFactory as AiSdkFactoryAbstraction } from "./abstractions.js";
33
import type { IAiSdk, IAiSdkModel } from "./abstractions.js";
44

5-
// 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05'
6-
75
const OPENAI_MODELS: IAiSdkModel[] = [
8-
{ id: "gpt-5", name: "GPT-5" },
9-
{ id: "gpt-5-2025-08-07", name: "GPT-5" },
10-
{ id: "gpt-5-chat-latest", name: "GPT-5" },
11-
{ id: "gpt-5-mini", name: "GPT-5 Mini" },
12-
{ id: "gpt-5-mini-2025-08-07", name: "GPT-5 Mini" },
13-
{ id: "gpt-5-nano", name: "GPT-5 Nano" },
14-
{ id: "gpt-5-nano-2025-08-07", name: "GPT-5 Nano" },
15-
{ id: "gpt-5.1", name: "GPT-5.1" },
16-
{ id: "gpt-5.1-2025-11-13", name: "GPT-5.1" },
17-
{ id: "gpt-5.1-chat-latest", name: "GPT-5.1" },
18-
{ id: "gpt-5.2", name: "GPT-5.2" },
19-
{ id: "gpt-5.2-2025-12-11", name: "GPT-5.2" },
20-
{ id: "gpt-5.2-chat-latest", name: "GPT-5.2" },
21-
{ id: "gpt-5.2-pro", name: "GPT-5.2 Pro" },
22-
{ id: "gpt-5.2-pro-2025-12-11", name: "GPT-5.2 Pro" },
23-
{ id: "gpt-5.3-chat-latest", name: "GPT-5.3" },
246
{ id: "gpt-5.4", name: "GPT-5.4" },
25-
{ id: "gpt-5.4-2026-03-05", name: "GPT-5.4" },
267
{ id: "gpt-5.4-mini", name: "GPT-5.4 Mini" },
27-
{ id: "gpt-5.4-mini-2026-03-17", name: "GPT-5.4 Mini" },
288
{ id: "gpt-5.4-nano", name: "GPT-5.4 Nano" },
29-
{ id: "gpt-5.4-nano-2026-03-17", name: "GPT-5.4 Nano" },
309
{ id: "gpt-5.4-pro", name: "GPT-5.4 Pro" },
31-
{ id: "gpt-5.4-pro-2026-03-05", name: "GPT-5.4 Pro" },
10+
{ id: "gpt-5.3-chat-latest", name: "GPT-5.3 Chat" },
3211
{ id: "gpt-4.1", name: "GPT-4.1" },
33-
{ id: "gpt-4.1-2025-04-14", name: "GPT-4.1" },
3412
{ id: "gpt-4.1-mini", name: "GPT-4.1 Mini" },
35-
{ id: "gpt-4.1-mini-2025-04-14", name: "GPT-4.1 Mini" },
3613
{ id: "gpt-4.1-nano", name: "GPT-4.1 Nano" },
37-
{ id: "gpt-4.1-nano-2025-04-14", name: "GPT-4.1 Nano" },
3814
{ id: "gpt-4o", name: "GPT-4o" },
39-
{ id: "gpt-4o-2024-05-13", name: "GPT-4o" },
40-
{ id: "gpt-4o-2024-08-06", name: "GPT-4o" },
41-
{ id: "gpt-4o-2024-11-20", name: "GPT-4o" },
42-
{ id: "gpt-4o-audio-preview", name: "GPT-4o Audio Preview" },
43-
{ id: "gpt-4o-audio-preview-2024-12-17", name: "GPT-4o Audio Preview" },
44-
{ id: "gpt-4o-search-preview", name: "GPT-4o Search Preview" },
45-
{ id: "gpt-4o-search-preview-2025-03-11", name: "GPT-4o Search Preview" },
46-
{ id: "gpt-4o-mini-search-preview", name: "GPT-4o Mini Search Preview" },
47-
{ id: "gpt-4o-mini-search-preview-2025-03-11", name: "GPT-4o Mini Search Preview" },
4815
{ id: "gpt-4o-mini", name: "GPT-4o Mini" },
49-
{ id: "gpt-4o-mini-2024-07-18", name: "GPT-4o Mini" },
50-
{ id: "gpt-3.5-turbo-0125", name: "GPT-3.5 Turbo" },
51-
{ id: "gpt-3.5-turbo", name: "GPT-3.5 Turbo" },
52-
{ id: "gpt-3.5-turbo-1106", name: "GPT-3.5 Turbo" },
53-
{ id: "o1", name: "o1" },
54-
{ id: "o1-2024-12-17", name: "o1" },
55-
{ id: "o3", name: "o3" },
56-
{ id: "o3-2025-04-16", name: "o3" },
57-
{ id: "o3-mini", name: "o3 Mini" },
58-
{ id: "o3-mini-2025-01-31", name: "o3 Mini" },
5916
{ id: "o4-mini", name: "o4 Mini" },
60-
{ id: "o4-mini-2025-04-16", name: "o4 Mini" }
17+
{ id: "o3", name: "o3" }
6118
];
6219

6320
class OpenAiSdkFactoryImpl implements AiSdkFactoryAbstraction.Interface {

0 commit comments

Comments
 (0)