Skip to content

Commit a6bc29b

Browse files
author
Gerome El-assaad
committed
Added GPT-5 & Vercel Flags (growthbook)
1 parent 3b32159 commit a6bc29b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2218
-5364
lines changed

CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,69 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [v0.0.34] - 2025-08-09
6+
7+
### 🤖 Added
8+
- **GPT-5 Model Integration**: Added support for OpenAI's latest GPT-5 model series
9+
- Integrated GPT-5, GPT-5 Mini, and GPT-5 Nano models with multimodal capabilities
10+
- Added o3 model support for advanced reasoning tasks
11+
- Enhanced AI model selection with beta model access control through feature flags
12+
- Added subscription-tier based model filtering (Pro/Enterprise for beta models)
13+
14+
### 🎛️ Enhanced
15+
- **Real Feature Flag Implementation**: Converted placeholder flags to production-ready business logic
16+
- `workflow-builder-v2`: Visual workflow creation interface with canvas view
17+
- `enhanced-code-editor`: Advanced Monaco editor with minimap, suggestions, and bracket colorization
18+
- `premium-templates`: Template access control based on subscription tier
19+
- `advanced-analytics`: Detailed usage metrics and performance insights for Pro+ users
20+
- `beta-ai-models`: Access control for cutting-edge AI models
21+
- `theme-customization`: Enhanced theming options in appearance settings
22+
23+
### 🛠️ Fixed
24+
- **Settings Pages Stability**: Resolved critical loading and functionality issues
25+
- Fixed account settings page glitching and infinite loading states
26+
- Resolved billing page endless loading with proper timeout mechanisms
27+
- Added comprehensive error boundaries with graceful fallback handling
28+
- Implemented optimistic UI updates for better user experience
29+
- **Edge Config Error Handling**: Improved Vercel Edge Config integration
30+
- Added proper connection string validation to prevent runtime errors
31+
- Enhanced middleware with configuration guards and fallback responses
32+
- Reduced error noise in development environments
33+
- **TypeScript Compliance**: Resolved all compilation errors
34+
- Fixed missing `'codinit-engineer'` template references
35+
- Updated `TemplatesDataObject` to `Templates` type throughout codebase
36+
- Added optional `isBeta` property to `LLMModel` type for beta model filtering
37+
38+
### 🗑️ Cleaned
39+
- **Codebase Optimization**: Removed redundant and development-only files
40+
- Removed duplicate components: `logo2.tsx`, `settings-context.tsx`, `settings-provider.tsx`
41+
- Eliminated development debugging tools and diagnostic components
42+
- Cleaned up unused utilities and experimental components
43+
- Reduced bundle size and eliminated potential conflicts
44+
- Improved maintainability with cleaner file structure
45+
46+
---
47+
48+
## [v0.0.33] - 2025-08-07
49+
50+
### ⚡ Added
51+
- **Vercel Edge Config Integration**: High-performance feature flag caching system
52+
- Integrated `@vercel/edge-config` for ultra-fast feature flag access at the edge
53+
- Created Edge Config middleware for intelligent flag routing (`/api/edge-flags`, `/welcome`, `/edge-config/*`)
54+
- Built EdgeConfigAdapter with automatic fallback to GrowthBook API when cache is unavailable
55+
- Added React hooks (`useEdgeFlags`, `useFeatureFlag`, `useFeatureValue`) for seamless client-side usage
56+
- Enhanced feature flag example component with real-time cache status and refresh capabilities
57+
- Implemented batch feature flag checking with POST endpoint for multiple flags
58+
59+
### 🚀 Enhanced
60+
- **Feature Flag Performance**: Dramatically improved feature flag response times
61+
- Edge-cached responses reduce latency from ~100ms to ~10ms
62+
- Intelligent fallback system ensures 100% availability
63+
- Real-time source indicators show whether flags come from cache or API
64+
- Added comprehensive error handling and retry mechanisms
65+
66+
---
67+
568
## [v0.0.31] - 2025-08-07
669

770
### 🗑️ Removed

app/api/chat/route.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { Duration } from '@/lib/duration'
2-
import { getModelClient } from '@/lib/models'
3-
import { LLMModel, LLMModelConfig } from '@/lib/models'
2+
import {
3+
getModelClient,
4+
getDefaultModelParams,
5+
LLMModel,
6+
LLMModelConfig,
7+
} from '@/lib/models'
48
import { toPrompt } from '@/lib/prompt'
59
import ratelimit from '@/lib/ratelimit'
610
import { fragmentSchema as schema } from '@/lib/schema'
7-
import { TemplateId } from '@/lib/templates'
8-
import templates from '@/lib/templates'
11+
import { Templates } from '@/lib/templates'
912
import { streamObject, LanguageModel, CoreMessage } from 'ai'
1013

11-
export const maxDuration = 60
14+
export const maxDuration = 300
1215

1316
const rateLimitMaxRequests = process.env.RATE_LIMIT_MAX_REQUESTS
1417
? parseInt(process.env.RATE_LIMIT_MAX_REQUESTS)
@@ -29,7 +32,7 @@ export async function POST(req: Request) {
2932
messages: CoreMessage[]
3033
userID: string | undefined
3134
teamID: string | undefined
32-
template: TemplateId
35+
template: Templates
3336
model: LLMModel
3437
config: LLMModelConfig
3538
} = await req.json()
@@ -54,22 +57,22 @@ export async function POST(req: Request) {
5457
}
5558

5659
console.log('userID', userID)
57-
console.log('template', template)
60+
console.log('teamID', teamID)
61+
// console.log('template', template)
5862
console.log('model', model)
59-
console.log('config', config)
63+
// console.log('config', config)
6064

6165
const { model: modelNameString, apiKey: modelApiKey, ...modelParams } = config
6266
const modelClient = getModelClient(model, config)
6367

6468
try {
65-
const systemPrompt = toPrompt(templates);
66-
6769
const stream = await streamObject({
6870
model: modelClient as LanguageModel,
6971
schema,
70-
system: systemPrompt,
72+
system: toPrompt(template),
7173
messages,
72-
maxRetries: 0,
74+
maxRetries: 0, // do not retry on errors
75+
...getDefaultModelParams(model),
7376
...modelParams,
7477
})
7578

@@ -118,4 +121,4 @@ export async function POST(req: Request) {
118121
},
119122
)
120123
}
121-
}
124+
}

app/api/debug/route.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

app/api/edge-flags/route.ts

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import { NextRequest, NextResponse } from 'next/server';
2+
import { edgeConfigAdapter } from '@/lib/edge-config-adapter';
3+
import { getAllFeatureFlags } from '@/flags';
4+
5+
// Force dynamic rendering for this route
6+
export const dynamic = 'force-dynamic';
7+
8+
export async function GET(request: NextRequest) {
9+
try {
10+
const url = new URL(request.url);
11+
const useEdgeConfig = url.searchParams.get('edge') === 'true';
12+
const featureKey = url.searchParams.get('feature');
13+
14+
if (useEdgeConfig) {
15+
// Use Edge Config adapter for faster response
16+
if (featureKey) {
17+
// Get specific feature
18+
const value = await edgeConfigAdapter.getFeatureValue(featureKey);
19+
20+
return NextResponse.json({
21+
success: true,
22+
source: 'edge-config',
23+
feature: featureKey,
24+
value,
25+
timestamp: new Date().toISOString(),
26+
});
27+
} else {
28+
// Get all features from Edge Config
29+
const features = await edgeConfigAdapter.getAllFeatures();
30+
const featureData = await edgeConfigAdapter.getFeatureData();
31+
32+
return NextResponse.json({
33+
success: true,
34+
source: 'edge-config',
35+
features,
36+
metadata: {
37+
featuresCount: Object.keys(features).length,
38+
dateUpdated: featureData?.dateUpdated,
39+
cached: true,
40+
},
41+
timestamp: new Date().toISOString(),
42+
});
43+
}
44+
} else {
45+
// Use standard GrowthBook integration
46+
const flags = await getAllFeatureFlags();
47+
48+
return NextResponse.json({
49+
success: true,
50+
source: 'growthbook-standard',
51+
flags,
52+
metadata: {
53+
flagsCount: Object.keys(flags).length,
54+
cached: false,
55+
},
56+
timestamp: new Date().toISOString(),
57+
});
58+
}
59+
} catch (error) {
60+
console.error('Error in edge-flags API:', error);
61+
62+
return NextResponse.json(
63+
{
64+
success: false,
65+
source: 'error',
66+
error: error instanceof Error ? error.message : 'Unknown error',
67+
timestamp: new Date().toISOString(),
68+
},
69+
{ status: 500 }
70+
);
71+
}
72+
}
73+
74+
export async function POST(request: NextRequest) {
75+
try {
76+
const body = await request.json();
77+
const { features, context } = body;
78+
79+
if (!features || !Array.isArray(features)) {
80+
return NextResponse.json(
81+
{ error: 'Invalid request: features array required' },
82+
{ status: 400 }
83+
);
84+
}
85+
86+
// Batch check multiple features
87+
const results: Record<string, any> = {};
88+
89+
for (const featureKey of features) {
90+
results[featureKey] = await edgeConfigAdapter.getFeatureValue(featureKey, false, context);
91+
}
92+
93+
return NextResponse.json({
94+
success: true,
95+
source: 'edge-config',
96+
features: results,
97+
context,
98+
timestamp: new Date().toISOString(),
99+
});
100+
} catch (error) {
101+
console.error('Error in batch feature check:', error);
102+
103+
return NextResponse.json(
104+
{
105+
success: false,
106+
error: error instanceof Error ? error.message : 'Unknown error',
107+
timestamp: new Date().toISOString(),
108+
},
109+
{ status: 500 }
110+
);
111+
}
112+
}

app/api/flags/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NextRequest, NextResponse } from 'next/server';
2-
import { getAllFeatureFlags } from '@/lib/feature-flags';
2+
import { getAllFeatureFlags } from '@/flags';
33

44
// Force dynamic rendering for this route
55
export const dynamic = 'force-dynamic';

app/providers.tsx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@
22

33
import { ThemeProvider as NextThemesProvider } from 'next-themes'
44
import { type ThemeProviderProps } from 'next-themes/dist/types'
5-
import { PostHogProvider as PHProvider } from 'posthog-js/react'
6-
import { AuthProvider as AuthContextProvider } from '@/lib/auth-provider'
5+
import posthog from 'posthog-js'
6+
import { PostHogProvider as PostHogProviderJS } from 'posthog-js/react'
77

8-
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
9-
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
8+
if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_ENABLE_POSTHOG) {
9+
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY ?? '', {
10+
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
11+
person_profiles: 'identified_only',
12+
session_recording: {
13+
recordCrossOriginIframes: true,
14+
}
15+
})
1016
}
1117

1218
export function PostHogProvider({ children }: { children: React.ReactNode }) {
13-
if (!process.env.NEXT_PUBLIC_POSTHOG_KEY) {
14-
return <>{children}</>
15-
}
16-
17-
return (
18-
<PHProvider
19-
apiKey={process.env.NEXT_PUBLIC_POSTHOG_KEY}
20-
options={{
21-
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
22-
capture_pageview: false // Disable automatic pageview capture, as we capture manually
23-
}}
24-
>
25-
{children}
26-
</PHProvider>
19+
return process.env.NEXT_PUBLIC_ENABLE_POSTHOG ? (
20+
<PostHogProviderJS client={posthog}>{children}</PostHogProviderJS>
21+
) : (
22+
children
2723
)
2824
}
2925

30-
export function AuthProvider({ children }: { children: React.ReactNode }) {
31-
return <AuthContextProvider>{children}</AuthContextProvider>
26+
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
27+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
3228
}
29+
30+
// Re-export AuthProvider from lib/auth-provider
31+
export { AuthProvider } from '../lib/auth-provider'

0 commit comments

Comments
 (0)