Skip to content

Commit 19ddc76

Browse files
Ajoute dans IA studio, un truc ou tu peut donnée du texte (et préparer p
1 parent 67dd76f commit 19ddc76

File tree

4 files changed

+61
-14
lines changed

4 files changed

+61
-14
lines changed

src/ai/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ config();
44

55
import '@/ai/flows/generate-project-ideas.ts';
66
import '@/ai/flows/summarize-project-documentation.ts';
7-
// import '@/ai/flows/flag-api-key-risks.ts'; // Removed
7+
import '@/ai/flows/flag-api-key-risks.ts'; // Removed
88
import '@/ai/flows/generate-document-content.ts';
99
import '@/ai/flows/generate-project-scaffold.ts';
1010
import '@/ai/flows/edit-file-content-ai.ts';

src/ai/flows/summarize-project-documentation.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
'use server';
33
/**
4-
* @fileOverview An AI agent for summarizing document content.
4+
* @fileOverview An AI agent for summarizing document content, meeting notes, or any long text.
55
*
66
* - summarizeDocumentation - A function that takes text content and returns a concise summary.
77
* - SummarizeDocumentationInput - The input type for the function.
@@ -12,15 +12,15 @@ import {ai} from '@/ai/genkit';
1212
import {z} from 'genkit';
1313

1414
const SummarizeDocumentationInputSchema = z.object({
15-
content: z.string().describe('The document content to be summarized.'),
16-
title: z.string().optional().describe('The title of the document, for context.'),
15+
content: z.string().describe('The document content, meeting notes, or text to be summarized.'),
16+
title: z.string().optional().describe('The title of the document or meeting, for context.'),
1717
});
1818
export type SummarizeDocumentationInput = z.infer<typeof SummarizeDocumentationInputSchema>;
1919

2020
const SummarizeDocumentationOutputSchema = z.object({
2121
summary: z
2222
.string()
23-
.describe('A concise, well-structured summary of the document content in Markdown format.'),
23+
.describe('A concise, well-structured summary of the text content in Markdown format. Should include key points, decisions, and action items if applicable.'),
2424
});
2525
export type SummarizeDocumentationOutput = z.infer<typeof SummarizeDocumentationOutputSchema>;
2626

@@ -36,14 +36,14 @@ const prompt = ai.definePrompt({
3636
name: 'summarizeDocumentationPrompt',
3737
input: {schema: SummarizeDocumentationInputSchema},
3838
output: {schema: SummarizeDocumentationOutputSchema},
39-
prompt: `You are an expert at technical writing and summarization.
40-
Your task is to create a concise, easy-to-read summary of the provided document content.
39+
prompt: `You are an expert at summarizing technical documents, meeting notes, and long texts.
40+
Your task is to create a concise, easy-to-read summary of the provided content.
4141
The summary should be in Markdown format.
42-
Focus on the key points, purpose, and main takeaways of the document.
42+
Focus on the key points, purpose, main takeaways, decisions made, and any action items mentioned.
4343
44-
Document Title (for context): {{{title}}}
44+
Document/Meeting Title (for context): {{{title}}}
4545
46-
Document Content to Summarize:
46+
Content to Summarize:
4747
---
4848
{{{content}}}
4949
---

src/app/(app)/studio/actions.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { generateProjectIdeas, type GenerateProjectIdeasOutput } from '@/ai/flow
55
import { generateProjectScaffold, type GenerateProjectScaffoldOutput } from '@/ai/flows/generate-project-scaffold';
66
import { generateDocumentContent, type GenerateDocumentContentOutput } from '@/ai/flows/generate-document-content';
77
import { generateProjectKickstart, type GenerateProjectKickstartOutput } from '@/ai/flows/generate-project-kickstart';
8+
import { summarizeDocumentation, type SummarizeDocumentationOutput } from '@/ai/flows/summarize-project-documentation';
89
import { createProjectFromAIPlan } from '@/app/(app)/projects/new/actions';
910
import { z } from 'zod';
1011
import { createGithubFileAction } from '@/app/(app)/projects/[id]/actions';
@@ -60,6 +61,22 @@ export async function generateDocumentContentAction(
6061
}
6162
}
6263

64+
export async function summarizeTextAction(
65+
text: string
66+
): Promise<{ data?: SummarizeDocumentationOutput; error?: string }> {
67+
const validatedFields = z.string().min(20, 'Text must be at least 20 characters long.').safeParse(text);
68+
if (!validatedFields.success) {
69+
return { error: validatedFields.error.flatten().formErrors.join(', ') };
70+
}
71+
try {
72+
const output = await summarizeDocumentation({ content: validatedFields.data });
73+
return { data: output };
74+
} catch (e: any) {
75+
return { error: e.message || 'Failed to generate summary.' };
76+
}
77+
}
78+
79+
6380
export async function addScaffoldToProjectAction(
6481
projectUuid: string,
6582
files: { filePath: string; content: string }[]

src/app/(app)/studio/page.tsx

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import {
1515
generateDocumentContentAction,
1616
addScaffoldToProjectAction,
1717
createProjectFromAIAction,
18+
summarizeTextAction,
1819
} from './actions';
1920
import { fetchProjectsAction } from '../projects/actions';
2021
import type { Project } from '@/types';
2122
import type { GenerateProjectIdeasOutput } from '@/ai/flows/generate-project-ideas';
2223
import type { GenerateProjectScaffoldOutput } from '@/ai/flows/generate-project-scaffold';
2324
import type { GenerateDocumentContentOutput } from '@/ai/flows/generate-document-content';
24-
import { BrainCircuit, Bot, FileCode, FileText, Lightbulb, Loader2, Sparkles, FolderGit2, Rocket } from 'lucide-react';
25+
import type { SummarizeDocumentationOutput } from '@/ai/flows/summarize-project-documentation';
26+
import { BrainCircuit, Bot, FileCode, FileText, Lightbulb, Loader2, Sparkles, FolderGit2, Rocket, FileSignature } from 'lucide-react';
2527
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
2628
import ReactMarkdown from 'react-markdown';
2729
import remarkGfm from 'remark-gfm';
@@ -30,7 +32,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
3032
import { useAuth } from '@/hooks/useAuth';
3133
import { useRouter } from 'next/navigation';
3234

33-
type AIGeneratorTool = 'ideas' | 'scaffold' | 'docs' | 'kickstart';
35+
type AIGeneratorTool = 'ideas' | 'scaffold' | 'docs' | 'kickstart' | 'summarize';
3436

3537
export default function StudioPage() {
3638
const { toast } = useToast();
@@ -44,6 +46,8 @@ export default function StudioPage() {
4446
const [ideaResult, setIdeaResult] = useState<GenerateProjectIdeasOutput | null>(null);
4547
const [scaffoldResult, setScaffoldResult] = useState<GenerateProjectScaffoldOutput | null>(null);
4648
const [docResult, setDocResult] = useState<GenerateDocumentContentOutput | null>(null);
49+
const [summaryResult, setSummaryResult] = useState<SummarizeDocumentationOutput | null>(null);
50+
4751

4852
// State for adding scaffold to project
4953
const [isAddToProjectDialogOpen, setIsAddToProjectDialogOpen] = useState(false);
@@ -80,7 +84,11 @@ export default function StudioPage() {
8084
} else if (tool === 'docs') {
8185
result = await generateDocumentContentAction(prompt);
8286
if (result.data) setDocResult(result.data);
83-
} else if (tool === 'kickstart') {
87+
} else if (tool === 'summarize') {
88+
result = await summarizeTextAction(prompt);
89+
if (result.data) setSummaryResult(result.data);
90+
}
91+
else if (tool === 'kickstart') {
8492
result = await createProjectFromAIAction(prompt);
8593
if (result.data) {
8694
toast({ title: 'Project Created!', description: `Successfully created "${result.data.name}". Redirecting...` });
@@ -135,6 +143,7 @@ export default function StudioPage() {
135143
setIdeaResult(null);
136144
setScaffoldResult(null);
137145
setDocResult(null);
146+
setSummaryResult(null);
138147
setActiveDialog(tool);
139148
};
140149

@@ -194,6 +203,16 @@ export default function StudioPage() {
194203
</div>
195204
);
196205
}
206+
if (activeDialog === 'summarize' && summaryResult) {
207+
return (
208+
<div className="mt-4 space-y-4">
209+
<h4 className="font-semibold">Generated Summary</h4>
210+
<div className="prose dark:prose-invert max-w-none p-4 border rounded-md bg-muted/50">
211+
<ReactMarkdown remarkPlugins={[remarkGfm]}>{summaryResult.summary}</ReactMarkdown>
212+
</div>
213+
</div>
214+
);
215+
}
197216
return null;
198217
};
199218

@@ -203,24 +222,35 @@ export default function StudioPage() {
203222
icon: Rocket,
204223
title: 'Project Kick-starter',
205224
description: "Describe your project idea, and the AI will generate a name, description, README, and create the project for you instantly.",
225+
promptPlaceholder: "e.g., 'A web app to track personal book reading habits, built with React and a simple Node.js backend.'"
206226
},
207227
{
208228
tool: 'ideas' as AIGeneratorTool,
209229
icon: Lightbulb,
210230
title: 'Project Idea Generator',
211231
description: "Stuck in a rut? Describe a concept or technology and get a list of project ideas and initial task lists to get you started.",
232+
promptPlaceholder: "e.g., 'Generate project ideas for a weekend hackathon using Genkit and a vector database.'"
212233
},
213234
{
214235
tool: 'scaffold' as AIGeneratorTool,
215236
icon: FolderGit2,
216237
title: 'Project Scaffolder',
217238
description: "Describe a simple application, and the AI will generate a complete file structure with starter code for HTML, CSS, JS, Python, and more.",
239+
promptPlaceholder: "e.g., 'A simple portfolio website with a homepage, about page, and contact form.'"
218240
},
219241
{
220242
tool: 'docs' as AIGeneratorTool,
221243
icon: FileText,
222244
title: 'Document Generator',
223245
description: "Automate your documentation. Provide a prompt about a feature or process, and the AI will generate comprehensive Markdown documentation.",
246+
promptPlaceholder: "e.g., 'An installation guide for a Node.js CLI tool published on npm.'"
247+
},
248+
{
249+
tool: 'summarize' as AIGeneratorTool,
250+
icon: FileSignature,
251+
title: 'Meeting Summarizer',
252+
description: "Paste in your meeting notes or any long text, and the AI will generate a concise summary with key points and action items.",
253+
promptPlaceholder: "Paste your raw meeting notes or text here..."
224254
},
225255
{
226256
tool: 'fileEditor' as const, // Not a generator tool
@@ -278,7 +308,7 @@ export default function StudioPage() {
278308
<Label htmlFor="ai-prompt">Your Prompt</Label>
279309
<Textarea
280310
id="ai-prompt"
281-
placeholder="e.g., 'A simple to-do list app using React and Tailwind CSS' or 'Generate project ideas for a weekend hackathon using Genkit'"
311+
placeholder={studioTools.find(t => t.tool === activeDialog)?.promptPlaceholder || "Enter your prompt here..."}
282312
value={prompt}
283313
onChange={(e) => setPrompt(e.target.value)}
284314
rows={4}

0 commit comments

Comments
 (0)