Skip to content

Commit bd8f27e

Browse files
mrjasonroyclaude
andcommitted
feat: make file-generator tool toggleable in UI
Converts file-generator from always-on to a toggleable tool that users can enable/disable in the Tools dropdown, following the same pattern as other default tools like code execution. Changes: - Add FileGenerator to AppDefaultToolkit enum - Register file-generator in APP_DEFAULT_TOOL_KIT - Remove file-generator from always-on tools in chat route - Add File Generator option to tool selector UI with file icon - Add translation for "File Generator" label - Remove file-generator references from system prompts Users can now enable/disable file generation via the Tools dropdown in the chat interface. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 935105a commit bd8f27e

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

messages/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@
247247
"visualization": "Data Visualization",
248248
"webSearch": "Search the Web",
249249
"http": "HTTP Request",
250-
"code": "Code Execution"
250+
"code": "Code Execution",
251+
"fileGenerator": "File Generator"
251252
}
252253
},
253254
"VoiceChat": {

src/app/api/chat/route.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ import { getSession } from "auth/server";
4848
import { colorize } from "consola/utils";
4949
import { generateUUID } from "lib/utils";
5050
import { nanoBananaTool, openaiImageTool } from "lib/ai/tools/image";
51-
import { fileGeneratorTool } from "lib/ai/tools/file-generator";
52-
import { ImageToolName, FileGeneratorToolName } from "lib/ai/tools";
51+
import { ImageToolName } from "lib/ai/tools";
5352
import { buildCsvIngestionPreviewParts } from "@/lib/ai/ingest/csv-ingest";
5453
import { serverFileStorage } from "lib/file-storage";
5554

@@ -284,13 +283,10 @@ export async function POST(request: Request) {
284283
: openaiImageTool,
285284
}
286285
: {};
287-
const FILE_GENERATOR_TOOL: Record<string, Tool> = {
288-
[FileGeneratorToolName]: fileGeneratorTool,
289-
};
290286
const vercelAITooles = safe({
291287
...MCP_TOOLS,
292288
...WORKFLOW_TOOLS,
293-
...FILE_GENERATOR_TOOL,
289+
...IMAGE_TOOL,
294290
})
295291
.map((t) => {
296292
const bindingTools =

src/components/tool-select-dropdown.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ChartColumn,
1010
ChevronRight,
1111
CodeIcon,
12+
FileIcon,
1213
GlobeIcon,
1314
HardDriveUploadIcon,
1415
ImagesIcon,
@@ -887,6 +888,9 @@ function AppDefaultToolKitSelector() {
887888
case AppDefaultToolkit.Code:
888889
icon = CodeIcon;
889890
break;
891+
case AppDefaultToolkit.FileGenerator:
892+
icon = FileIcon;
893+
break;
890894
}
891895
return {
892896
label,

src/lib/ai/prompts.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ You can assist with:
9797
- Analysis and problem-solving across various domains
9898
- Using available tools and resources to complete tasks
9999
- Adapting communication to user preferences and context
100-
- Generating downloadable files (CSV, JSON, PDF, code files, etc.) when users request data exports or file creation
101100
</general_capabilities>`;
102101

103102
// Communication preferences
@@ -125,9 +124,8 @@ ${userPreferences.responseStyleExample}
125124
prompt += `
126125
127126
- When using tools, briefly mention which tool you'll use with natural phrases
128-
- Examples: "I'll search for that information", "Let me check the weather", "I'll run some calculations", "I'll generate that file for you"
127+
- Examples: "I'll search for that information", "Let me check the weather", "I'll run some calculations"
129128
- Use \`mermaid\` code blocks for diagrams and charts when helpful
130-
- When users request data exports, file downloads, or structured data files, use the file-generator tool to create downloadable files
131129
</communication_preferences>`;
132130
}
133131

@@ -180,7 +178,6 @@ ${userInfo.join("\n")}
180178
You excel at conversational voice interactions by:
181179
- Providing clear, natural spoken responses
182180
- Using available tools to gather information and complete tasks
183-
- Generating downloadable files when users request data exports or file creation
184181
- Adapting communication to user preferences and context
185182
</voice_capabilities>`;
186183

src/lib/ai/tools/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export enum AppDefaultToolkit {
33
WebSearch = "webSearch",
44
Http = "http",
55
Code = "code",
6+
FileGenerator = "fileGenerator",
67
}
78

89
export enum DefaultToolName {

src/lib/ai/tools/tool-kit.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { createBarChartTool } from "./visualization/create-bar-chart";
33
import { createLineChartTool } from "./visualization/create-line-chart";
44
import { createTableTool } from "./visualization/create-table";
55
import { exaSearchTool, exaContentsTool } from "./web/web-search";
6-
import { AppDefaultToolkit, DefaultToolName } from ".";
6+
import { AppDefaultToolkit, DefaultToolName, FileGeneratorToolName } from ".";
77
import { Tool } from "ai";
88
import { httpFetchTool } from "./http/fetch";
99
import { jsExecutionTool } from "./code/js-run-tool";
1010
import { pythonExecutionTool } from "./code/python-run-tool";
11+
import { fileGeneratorTool } from "./file-generator";
1112

1213
export const APP_DEFAULT_TOOL_KIT: Record<
1314
AppDefaultToolkit,
@@ -30,4 +31,7 @@ export const APP_DEFAULT_TOOL_KIT: Record<
3031
[DefaultToolName.JavascriptExecution]: jsExecutionTool,
3132
[DefaultToolName.PythonExecution]: pythonExecutionTool,
3233
},
34+
[AppDefaultToolkit.FileGenerator]: {
35+
[FileGeneratorToolName]: fileGeneratorTool,
36+
},
3337
};

0 commit comments

Comments
 (0)