You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/server.js
+14-6Lines changed: 14 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -187,12 +187,20 @@ Give me ONLY a raw JSON string like {"exclusions": ["folder1"], "reasoning": "wh
187
187
// Step 5: AI Renaming reasoning
188
188
app.post("/api/ai/rename",async(req,res)=>{
189
189
try{
190
-
const{ fileInfo }=req.body;
191
-
constprompt=`I have a file with info ${JSON.stringify(fileInfo)}. Propose a rename and give reasoning.
192
-
Ensure names are deterministic (e.g., lowercase, underscores).
193
-
If it's a Finance/Form_16, ensure the year is prominent.
194
-
Return ONLY a raw JSON string like {"proposedName": "file.pdf", "reasoning": "why"}. No markdown.`;
195
-
constaiResponse=awaitaskAI(prompt,"You are a highly deterministic file renaming assistant. You must follow standard naming conventions and prioritize semantic clarity based on file content and metadata.");
190
+
const{ fileInfo, subjectPath }=req.body;
191
+
constfile=catalog.getFileByPath(subjectPath);
192
+
consttextSample=file?.extractedText ? file.extractedText.slice(0,800) : "No text available.";
193
+
194
+
constprompt=`I have a file named "${fileInfo.currentName}" with category "${fileInfo.category}" and purpose "${fileInfo.purpose}".
195
+
Here is a sample of its extracted text content:
196
+
---
197
+
${textSample}
198
+
---
199
+
Analyze the text to determine exactly what this file is (e.g. Bank Statement, Aadhaar Card, Offer Letter, etc.) and who it belongs to if applicable.
200
+
Propose a highly descriptive and structured file name. Use Spaces, Title Case, and clear descriptors (e.g., "Pratik Vaibhav - Aadhaar Card.pdf" or "HDFC Bank Statement - Jan 2024.pdf").
201
+
Do not just return the original name or "document_123.pdf".
202
+
Return ONLY a raw JSON string like {"proposedName": "New Name.pdf", "reasoning": "why"}. No markdown.`;
203
+
constaiResponse=awaitaskAI(prompt,"You are a highly intelligent file renaming assistant. You must analyze the text content to extract the semantic meaning of the document and propose a human-readable, descriptive name.");
0 commit comments