Skip to content

Commit 66603a0

Browse files
GeneralJerelclaude
andcommitted
feat: make LLM model and rate limits configurable via env vars
- LLM_MODEL env var in agent (defaults to gpt-5.4-2026-03-05) - RATE_LIMIT_WINDOW_MS and RATE_LIMIT_MAX env vars (defaults 60s/40 req) - README callout: strong models required for generative UI (GPT-5.4, Claude Opus 4.6, Gemini 3.1 Pro) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 59537d4 commit 66603a0

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

.env.example

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
OPENAI_API_KEY=
1+
OPENAI_API_KEY=
2+
3+
# LLM model — strong models are required for reliable UI generation
4+
# Recommended: gpt-5.4, gpt-5.4-pro, claude-opus-4-6, gemini-3.1-pro
5+
LLM_MODEL=gpt-5.4-2026-03-05
6+
7+
# Rate limiting (per IP)
8+
RATE_LIMIT_WINDOW_MS=60000
9+
RATE_LIMIT_MAX=40

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ make setup # Install deps + create .env template
2323
make dev # Start all services
2424
```
2525

26+
> **Strong models required.** Generative UI demands high-capability models that can produce complex, well-structured HTML/SVG in a single pass. Set `LLM_MODEL` in your `.env` to one of:
27+
>
28+
> | Model | Provider |
29+
> |-------|----------|
30+
> | `gpt-5.4` / `gpt-5.4-pro` | OpenAI |
31+
> | `claude-opus-4-6` | Anthropic |
32+
> | `gemini-3.1-pro` | Google |
33+
>
34+
> Smaller or weaker models will produce broken layouts, missing interactivity, or incomplete visualizations.
35+
2636
- **App**: http://localhost:3000
2737
- **Agent**: http://localhost:8123
2838

apps/agent/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
It defines the workflow graph, state, tools, nodes and edges.
44
"""
55

6+
import os
7+
68
from copilotkit import CopilotKitMiddleware
79
from langchain.agents import create_agent
810
from langchain_openai import ChatOpenAI
@@ -17,7 +19,7 @@
1719
_skills_text = load_all_skills()
1820

1921
agent = create_agent(
20-
model=ChatOpenAI(model="gpt-5.4-2026-03-05"),
22+
model=ChatOpenAI(model=os.environ.get("LLM_MODEL", "gpt-5.4-2026-03-05")),
2123
tools=[query_data, *todo_tools, generate_form, *template_tools],
2224
middleware=[CopilotKitMiddleware()],
2325
state_schema=AgentState,

apps/app/src/app/api/copilotkit/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { LangGraphAgent } from "@copilotkit/runtime/langgraph";
77
import { NextRequest } from "next/server";
88

99
// Simple sliding-window rate limiter (per IP)
10-
const RATE_LIMIT_WINDOW_MS = 60_000; // 1 minute
11-
const RATE_LIMIT_MAX = 20; // max requests per window
10+
const RATE_LIMIT_WINDOW_MS = Number(process.env.RATE_LIMIT_WINDOW_MS) || 60_000;
11+
const RATE_LIMIT_MAX = Number(process.env.RATE_LIMIT_MAX) || 40;
1212
const hits = new Map<string, number[]>();
1313

1414
function isRateLimited(ip: string): boolean {

0 commit comments

Comments
 (0)