@amirdaraee/namewise 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +6 -0
- package/.github/workflows/publish.yml +59 -11
- package/.github/workflows/test.yml +1 -0
- package/RELEASE.md +15 -3
- package/dist/services/claude-service.d.ts.map +1 -1
- package/dist/services/claude-service.js +9 -55
- package/dist/services/claude-service.js.map +1 -1
- package/dist/services/lmstudio-service.d.ts.map +1 -1
- package/dist/services/lmstudio-service.js +9 -19
- package/dist/services/lmstudio-service.js.map +1 -1
- package/dist/services/ollama-service.d.ts.map +1 -1
- package/dist/services/ollama-service.js +9 -19
- package/dist/services/ollama-service.js.map +1 -1
- package/dist/services/openai-service.d.ts.map +1 -1
- package/dist/services/openai-service.js +9 -55
- package/dist/services/openai-service.js.map +1 -1
- package/dist/utils/ai-prompts.d.ts +20 -0
- package/dist/utils/ai-prompts.d.ts.map +1 -0
- package/dist/utils/ai-prompts.js +71 -0
- package/dist/utils/ai-prompts.js.map +1 -0
- package/package.json +1 -1
- package/src/services/claude-service.ts +10 -48
- package/src/services/lmstudio-service.ts +11 -20
- package/src/services/ollama-service.ts +11 -20
- package/src/services/openai-service.ts +10 -48
- package/src/utils/ai-prompts.ts +76 -0
- package/tests/integration/ai-prompting.test.ts +386 -0
- package/tests/integration/person-name-extraction.test.ts +440 -0
- package/tests/unit/services/lmstudio-service.test.ts +4 -4
- package/tests/unit/services/ollama-service.test.ts +4 -4
- package/tests/unit/utils/ai-prompts.test.ts +213 -0
|
@@ -7,9 +7,15 @@ on:
|
|
|
7
7
|
workflow_call: # Allows this workflow to be called by other workflows
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Run Tests Before Build
|
|
12
|
+
uses: ./.github/workflows/test.yml
|
|
13
|
+
|
|
10
14
|
build:
|
|
11
15
|
name: Build Project
|
|
12
16
|
runs-on: ubuntu-latest
|
|
17
|
+
needs: [test]
|
|
18
|
+
if: ${{ needs.test.result == 'success' }}
|
|
13
19
|
|
|
14
20
|
steps:
|
|
15
21
|
- name: Checkout code
|
|
@@ -2,13 +2,25 @@ name: Publish Pipeline
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
workflow_dispatch: # Allows manual triggering
|
|
5
|
+
inputs:
|
|
6
|
+
use_artifact:
|
|
7
|
+
description: 'Use build artifact (provide artifact name or "latest")'
|
|
8
|
+
required: false
|
|
9
|
+
default: ''
|
|
5
10
|
release:
|
|
6
11
|
types: [published]
|
|
7
12
|
|
|
8
13
|
jobs:
|
|
14
|
+
build:
|
|
15
|
+
name: Build for Publishing
|
|
16
|
+
uses: ./.github/workflows/build.yml
|
|
17
|
+
if: ${{ github.event.inputs.use_artifact == '' }}
|
|
18
|
+
|
|
9
19
|
publish:
|
|
10
20
|
name: Publish Package
|
|
11
21
|
runs-on: ubuntu-latest
|
|
22
|
+
needs: [build]
|
|
23
|
+
if: ${{ always() && (needs.build.result == 'success' || github.event.inputs.use_artifact != '') }}
|
|
12
24
|
environment: production # Requires environment approval for production
|
|
13
25
|
|
|
14
26
|
steps:
|
|
@@ -22,14 +34,30 @@ jobs:
|
|
|
22
34
|
registry-url: 'https://registry.npmjs.org'
|
|
23
35
|
cache: 'npm'
|
|
24
36
|
|
|
25
|
-
- name:
|
|
26
|
-
|
|
37
|
+
- name: Download build artifacts (from current run)
|
|
38
|
+
if: ${{ github.event.inputs.use_artifact == '' }}
|
|
39
|
+
uses: actions/download-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: build-artifacts-${{ github.sha }}
|
|
42
|
+
path: ./
|
|
43
|
+
|
|
44
|
+
- name: Download build artifacts (from specific run)
|
|
45
|
+
if: ${{ github.event.inputs.use_artifact != '' && github.event.inputs.use_artifact != 'latest' }}
|
|
46
|
+
uses: actions/download-artifact@v4
|
|
47
|
+
with:
|
|
48
|
+
name: ${{ github.event.inputs.use_artifact }}
|
|
49
|
+
path: ./
|
|
27
50
|
|
|
28
|
-
- name:
|
|
29
|
-
|
|
51
|
+
- name: Download latest build artifacts
|
|
52
|
+
if: ${{ github.event.inputs.use_artifact == 'latest' }}
|
|
53
|
+
run: |
|
|
54
|
+
echo "Downloading latest build artifacts..."
|
|
55
|
+
gh run download --name "build-artifacts-*" --limit 1
|
|
56
|
+
env:
|
|
57
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
30
58
|
|
|
31
|
-
- name:
|
|
32
|
-
run: npm
|
|
59
|
+
- name: Install dependencies (only for package.json)
|
|
60
|
+
run: npm ci --production
|
|
33
61
|
|
|
34
62
|
- name: Publish to NPM
|
|
35
63
|
run: npm publish
|
|
@@ -42,7 +70,8 @@ jobs:
|
|
|
42
70
|
publish-github:
|
|
43
71
|
name: Publish to GitHub Packages
|
|
44
72
|
runs-on: ubuntu-latest
|
|
45
|
-
needs: publish
|
|
73
|
+
needs: [build, publish]
|
|
74
|
+
if: ${{ always() && needs.publish.result == 'success' }}
|
|
46
75
|
permissions:
|
|
47
76
|
contents: read
|
|
48
77
|
packages: write
|
|
@@ -58,11 +87,30 @@ jobs:
|
|
|
58
87
|
registry-url: 'https://npm.pkg.github.com'
|
|
59
88
|
cache: 'npm'
|
|
60
89
|
|
|
61
|
-
- name:
|
|
62
|
-
|
|
90
|
+
- name: Download build artifacts (reuse from publish job)
|
|
91
|
+
if: ${{ github.event.inputs.use_artifact == '' }}
|
|
92
|
+
uses: actions/download-artifact@v4
|
|
93
|
+
with:
|
|
94
|
+
name: build-artifacts-${{ github.sha }}
|
|
95
|
+
path: ./
|
|
96
|
+
|
|
97
|
+
- name: Download build artifacts (from specific run)
|
|
98
|
+
if: ${{ github.event.inputs.use_artifact != '' && github.event.inputs.use_artifact != 'latest' }}
|
|
99
|
+
uses: actions/download-artifact@v4
|
|
100
|
+
with:
|
|
101
|
+
name: ${{ github.event.inputs.use_artifact }}
|
|
102
|
+
path: ./
|
|
103
|
+
|
|
104
|
+
- name: Download latest build artifacts
|
|
105
|
+
if: ${{ github.event.inputs.use_artifact == 'latest' }}
|
|
106
|
+
run: |
|
|
107
|
+
echo "Downloading latest build artifacts..."
|
|
108
|
+
gh run download --name "build-artifacts-*" --limit 1
|
|
109
|
+
env:
|
|
110
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
63
111
|
|
|
64
|
-
- name:
|
|
65
|
-
run: npm
|
|
112
|
+
- name: Install dependencies (only for package.json)
|
|
113
|
+
run: npm ci --production
|
|
66
114
|
|
|
67
115
|
- name: Configure package for GitHub Packages
|
|
68
116
|
run: |
|
package/RELEASE.md
CHANGED
|
@@ -73,18 +73,23 @@ This triggers the `publish.yml` workflow.
|
|
|
73
73
|
Your project has three separate, independently runnable workflows:
|
|
74
74
|
|
|
75
75
|
### 1. Test Pipeline (`test.yml`)
|
|
76
|
-
- **Triggers**: Push to main/develop, PRs, manual dispatch
|
|
76
|
+
- **Triggers**: Push to main/develop, PRs, manual dispatch, called by other workflows
|
|
77
77
|
- **Purpose**: Run tests and linting across Node.js versions
|
|
78
78
|
- **Manual run**: Go to Actions → Test Pipeline → "Run workflow"
|
|
79
79
|
|
|
80
80
|
### 2. Build Pipeline (`build.yml`)
|
|
81
81
|
- **Triggers**: Push to main, manual dispatch, or called by other workflows
|
|
82
|
-
- **Purpose**:
|
|
82
|
+
- **Purpose**: Run tests first, then build the project and create artifacts
|
|
83
|
+
- **Dependencies**: Calls Test Pipeline automatically
|
|
83
84
|
- **Manual run**: Go to Actions → Build Pipeline → "Run workflow"
|
|
84
85
|
|
|
85
86
|
### 3. Publish Pipeline (`publish.yml`)
|
|
86
87
|
- **Triggers**: GitHub releases, manual dispatch
|
|
87
|
-
- **Purpose**: Publish to NPM and GitHub Packages
|
|
88
|
+
- **Purpose**: Publish to NPM and GitHub Packages using build artifacts
|
|
89
|
+
- **Features**:
|
|
90
|
+
- Uses artifacts from build pipeline (no rebuilding)
|
|
91
|
+
- Can use existing artifacts from previous builds
|
|
92
|
+
- Option to specify which artifact to use
|
|
88
93
|
- **Manual run**: Go to Actions → Publish Pipeline → "Run workflow"
|
|
89
94
|
|
|
90
95
|
### 4. Auto Release (`auto-release.yml`)
|
|
@@ -127,6 +132,13 @@ Follow [Semantic Versioning](https://semver.org/):
|
|
|
127
132
|
- Bump the version: `npm version patch`
|
|
128
133
|
- Push: `git push origin main`
|
|
129
134
|
|
|
135
|
+
### Using Existing Build Artifacts
|
|
136
|
+
|
|
137
|
+
You can publish using previously built artifacts:
|
|
138
|
+
|
|
139
|
+
1. **Use latest build**: Go to Actions → Publish Pipeline → Run workflow → Use artifact: `latest`
|
|
140
|
+
2. **Use specific build**: Find the artifact name from a previous build run → Run workflow → Use artifact: `build-artifacts-abc123def`
|
|
141
|
+
|
|
130
142
|
### Manual Publishing
|
|
131
143
|
If workflows fail, you can publish manually:
|
|
132
144
|
```bash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-service.d.ts","sourceRoot":"","sources":["../../src/services/claude-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-service.d.ts","sourceRoot":"","sources":["../../src/services/claude-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAKzD,qBAAa,aAAc,YAAW,UAAU;IAC9C,IAAI,SAAY;IAChB,OAAO,CAAC,MAAM,CAAY;gBAEd,MAAM,EAAE,MAAM;IAMpB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAE,MAAqB,EAAE,QAAQ,GAAE,MAAkB,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAoC1K,OAAO,CAAC,gBAAgB;CAuBzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
-
import { applyNamingConvention
|
|
3
|
-
import {
|
|
2
|
+
import { applyNamingConvention } from '../utils/naming-conventions.js';
|
|
3
|
+
import { buildFileNamePrompt } from '../utils/ai-prompts.js';
|
|
4
4
|
export class ClaudeService {
|
|
5
5
|
name = 'Claude';
|
|
6
6
|
client;
|
|
@@ -12,59 +12,13 @@ export class ClaudeService {
|
|
|
12
12
|
async generateFileName(content, originalName, namingConvention = 'kebab-case', category = 'general', fileInfo) {
|
|
13
13
|
const convention = namingConvention;
|
|
14
14
|
const fileCategory = category;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- File size: ${Math.round(fileInfo.size / 1024)}KB
|
|
23
|
-
- Created: ${fileInfo.createdAt.toLocaleDateString()}
|
|
24
|
-
- Modified: ${fileInfo.modifiedAt.toLocaleDateString()}
|
|
25
|
-
- Parent folder: ${fileInfo.parentFolder}
|
|
26
|
-
- Folder path: ${fileInfo.folderPath.join(' > ')}`;
|
|
27
|
-
if (fileInfo.documentMetadata) {
|
|
28
|
-
const meta = fileInfo.documentMetadata;
|
|
29
|
-
metadataContext += `
|
|
30
|
-
Document Properties:`;
|
|
31
|
-
if (meta.title)
|
|
32
|
-
metadataContext += `\n- Title: ${meta.title}`;
|
|
33
|
-
if (meta.author)
|
|
34
|
-
metadataContext += `\n- Author: ${meta.author}`;
|
|
35
|
-
if (meta.creator)
|
|
36
|
-
metadataContext += `\n- Creator: ${meta.creator}`;
|
|
37
|
-
if (meta.subject)
|
|
38
|
-
metadataContext += `\n- Subject: ${meta.subject}`;
|
|
39
|
-
if (meta.keywords?.length)
|
|
40
|
-
metadataContext += `\n- Keywords: ${meta.keywords.join(', ')}`;
|
|
41
|
-
if (meta.creationDate)
|
|
42
|
-
metadataContext += `\n- Created: ${meta.creationDate.toLocaleDateString()}`;
|
|
43
|
-
if (meta.modificationDate)
|
|
44
|
-
metadataContext += `\n- Modified: ${meta.modificationDate.toLocaleDateString()}`;
|
|
45
|
-
if (meta.pages)
|
|
46
|
-
metadataContext += `\n- Pages: ${meta.pages}`;
|
|
47
|
-
if (meta.wordCount)
|
|
48
|
-
metadataContext += `\n- Word count: ${meta.wordCount}`;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const prompt = `Based on the following document information, generate a descriptive filename that captures the main topic/purpose of the document. The filename should be:
|
|
52
|
-
- Descriptive and meaningful
|
|
53
|
-
- Professional and clean
|
|
54
|
-
- Between 3-8 words
|
|
55
|
-
- ${namingInstructions}
|
|
56
|
-
- ${templateInstructions}
|
|
57
|
-
- Do not include file extension
|
|
58
|
-
- Do not include personal names, dates, or template variables - just the core content description
|
|
59
|
-
- Only use letters, numbers, and appropriate separators for the naming convention
|
|
60
|
-
- Use all available context (metadata, folder context, document properties) to create the most accurate filename
|
|
61
|
-
|
|
62
|
-
${metadataContext}
|
|
63
|
-
|
|
64
|
-
Document content (first 2000 characters):
|
|
65
|
-
${content.substring(0, 2000)}
|
|
66
|
-
|
|
67
|
-
Respond with only the core filename (without personal info or dates) using the specified naming convention, no explanation.`;
|
|
15
|
+
const prompt = buildFileNamePrompt({
|
|
16
|
+
content,
|
|
17
|
+
originalName,
|
|
18
|
+
namingConvention: convention,
|
|
19
|
+
category: fileCategory,
|
|
20
|
+
fileInfo
|
|
21
|
+
});
|
|
68
22
|
try {
|
|
69
23
|
const response = await this.client.messages.create({
|
|
70
24
|
model: 'claude-3-haiku-20240307',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-service.js","sourceRoot":"","sources":["../../src/services/claude-service.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"claude-service.js","sourceRoot":"","sources":["../../src/services/claude-service.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1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K,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,4CAA4C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;QAC1H,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,IAAY,EAAE,UAA4B;QACjE,2DAA2D;QAC3D,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAErD,8BAA8B;QAC9B,IAAI,OAAO,GAAG,qBAAqB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAEhE,yCAAyC;QACzC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,qBAAqB,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAChC,wDAAwD;YACxD,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACpC,4CAA4C;YAC5C,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;gBAChC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC3C,CAAC;iBAAM,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;gBACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lmstudio-service.d.ts","sourceRoot":"","sources":["../../src/services/lmstudio-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"lmstudio-service.d.ts","sourceRoot":"","sources":["../../src/services/lmstudio-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAgCzD,qBAAa,eAAgB,YAAW,UAAU;IAChD,IAAI,SAAc;IAClB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;gBAGpB,OAAO,SAA0B,EACjC,KAAK,SAAgB;IAMjB,gBAAgB,CACpB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,gBAAgB,SAAe,EAC/B,QAAQ,SAAY,EACpB,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,MAAM,CAAC;IAgClB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,gBAAgB;YAUV,WAAW;IAqBnB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAU/B,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAWtC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildFileNamePrompt, AI_SYSTEM_PROMPT } from '../utils/ai-prompts.js';
|
|
1
2
|
export class LMStudioService {
|
|
2
3
|
name = 'LMStudio';
|
|
3
4
|
baseUrl;
|
|
@@ -14,7 +15,7 @@ export class LMStudioService {
|
|
|
14
15
|
messages: [
|
|
15
16
|
{
|
|
16
17
|
role: 'system',
|
|
17
|
-
content:
|
|
18
|
+
content: AI_SYSTEM_PROMPT
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
role: 'user',
|
|
@@ -38,24 +39,13 @@ export class LMStudioService {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
buildPrompt(content, originalName, namingConvention, category, fileInfo) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
prompt += `Author: "${meta.author}". `;
|
|
49
|
-
if (meta.subject)
|
|
50
|
-
prompt += `Subject: "${meta.subject}". `;
|
|
51
|
-
}
|
|
52
|
-
if (fileInfo?.parentFolder && fileInfo.parentFolder !== '.') {
|
|
53
|
-
prompt += `Located in folder: "${fileInfo.parentFolder}". `;
|
|
54
|
-
}
|
|
55
|
-
prompt += `\nOriginal filename: ${originalName}\n`;
|
|
56
|
-
prompt += `\nDocument content (first 2000 characters):\n${content.substring(0, 2000)}`;
|
|
57
|
-
prompt += `\n\nGenerate ONLY a descriptive filename (without extension) using ${namingConvention} format. Do not include any explanation or additional text.`;
|
|
58
|
-
return prompt;
|
|
42
|
+
return buildFileNamePrompt({
|
|
43
|
+
content,
|
|
44
|
+
originalName,
|
|
45
|
+
namingConvention: namingConvention,
|
|
46
|
+
category: category,
|
|
47
|
+
fileInfo
|
|
48
|
+
});
|
|
59
49
|
}
|
|
60
50
|
sanitizeFilename(filename) {
|
|
61
51
|
return filename
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lmstudio-service.js","sourceRoot":"","sources":["../../src/services/lmstudio-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lmstudio-service.js","sourceRoot":"","sources":["../../src/services/lmstudio-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AA+B/E,MAAM,OAAO,eAAe;IAC1B,IAAI,GAAG,UAAU,CAAC;IACV,OAAO,CAAS;IAChB,KAAK,CAAS;IAEtB,YACE,OAAO,GAAG,uBAAuB,EACjC,KAAK,GAAG,aAAa;QAErB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAAe,EACf,YAAoB,EACpB,gBAAgB,GAAG,YAAY,EAC/B,QAAQ,GAAG,SAAS,EACpB,QAAmB;QAEnB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC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;IAClC,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;YAC1D,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,OAAO,EAAE,CAAC;YAE5B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,KAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-service.d.ts","sourceRoot":"","sources":["../../src/services/ollama-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ollama-service.d.ts","sourceRoot":"","sources":["../../src/services/ollama-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAoBzD,qBAAa,aAAc,YAAW,UAAU;IAC9C,IAAI,SAAY;IAChB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;gBAGpB,OAAO,SAA2B,EAClC,KAAK,SAAa;IAMd,gBAAgB,CACpB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,gBAAgB,SAAe,EAC/B,QAAQ,SAAY,EACpB,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,MAAM,CAAC;IA8BlB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,gBAAgB;YAUV,WAAW;IAqBnB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAU/B,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAWtC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildFileNamePrompt, AI_SYSTEM_PROMPT } from '../utils/ai-prompts.js';
|
|
1
2
|
export class OllamaService {
|
|
2
3
|
name = 'Ollama';
|
|
3
4
|
baseUrl;
|
|
@@ -14,7 +15,7 @@ export class OllamaService {
|
|
|
14
15
|
messages: [
|
|
15
16
|
{
|
|
16
17
|
role: 'system',
|
|
17
|
-
content:
|
|
18
|
+
content: AI_SYSTEM_PROMPT
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
role: 'user',
|
|
@@ -36,24 +37,13 @@ export class OllamaService {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
buildPrompt(content, originalName, namingConvention, category, fileInfo) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
prompt += `Author: "${meta.author}". `;
|
|
47
|
-
if (meta.subject)
|
|
48
|
-
prompt += `Subject: "${meta.subject}". `;
|
|
49
|
-
}
|
|
50
|
-
if (fileInfo?.parentFolder && fileInfo.parentFolder !== '.') {
|
|
51
|
-
prompt += `Located in folder: "${fileInfo.parentFolder}". `;
|
|
52
|
-
}
|
|
53
|
-
prompt += `\nOriginal filename: ${originalName}\n`;
|
|
54
|
-
prompt += `\nDocument content (first 2000 characters):\n${content.substring(0, 2000)}`;
|
|
55
|
-
prompt += `\n\nGenerate ONLY a descriptive filename (without extension) using ${namingConvention} format. Do not include any explanation or additional text.`;
|
|
56
|
-
return prompt;
|
|
40
|
+
return buildFileNamePrompt({
|
|
41
|
+
content,
|
|
42
|
+
originalName,
|
|
43
|
+
namingConvention: namingConvention,
|
|
44
|
+
category: category,
|
|
45
|
+
fileInfo
|
|
46
|
+
});
|
|
57
47
|
}
|
|
58
48
|
sanitizeFilename(filename) {
|
|
59
49
|
return filename
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-service.js","sourceRoot":"","sources":["../../src/services/ollama-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ollama-service.js","sourceRoot":"","sources":["../../src/services/ollama-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAmB/E,MAAM,OAAO,aAAa;IACxB,IAAI,GAAG,QAAQ,CAAC;IACR,OAAO,CAAS;IAChB,KAAK,CAAS;IAEtB,YACE,OAAO,GAAG,wBAAwB,EAClC,KAAK,GAAG,UAAU;QAElB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAAe,EACf,YAAoB,EACpB,gBAAgB,GAAG,YAAY,EAC/B,QAAQ,GAAG,SAAS,EACpB,QAAmB;QAEnB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAE7F,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE;gBACnD,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,gBAAgB;qBAC1B;oBACD;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE,MAAM;qBAChB;iBACqB;gBACxB,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,iCAAiC,C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AAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CAAC,CAAC;QACzG,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,IAAsB,CAAC;IAChC,CAAC;IAED,iDAAiD;IACjD,KAAK,CAAC,WAAW;QACf,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;YACzD,OAAO,QAAQ,CAAC,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,kCAAkC;IAClC,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;YACzD,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,OAAO,EAAE,CAAC;YAE5B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-service.d.ts","sourceRoot":"","sources":["../../src/services/openai-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-service.d.ts","sourceRoot":"","sources":["../../src/services/openai-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAKzD,qBAAa,aAAc,YAAW,UAAU;IAC9C,IAAI,SAAY;IAChB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAMpB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAE,MAAqB,EAAE,QAAQ,GAAE,MAAkB,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAmC1K,OAAO,CAAC,gBAAgB;CAuBzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
-
import { applyNamingConvention
|
|
3
|
-
import {
|
|
2
|
+
import { applyNamingConvention } from '../utils/naming-conventions.js';
|
|
3
|
+
import { buildFileNamePrompt } from '../utils/ai-prompts.js';
|
|
4
4
|
export class OpenAIService {
|
|
5
5
|
name = 'OpenAI';
|
|
6
6
|
client;
|
|
@@ -12,59 +12,13 @@ export class OpenAIService {
|
|
|
12
12
|
async generateFileName(content, originalName, namingConvention = 'kebab-case', category = 'general', fileInfo) {
|
|
13
13
|
const convention = namingConvention;
|
|
14
14
|
const fileCategory = category;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- File size: ${Math.round(fileInfo.size / 1024)}KB
|
|
23
|
-
- Created: ${fileInfo.createdAt.toLocaleDateString()}
|
|
24
|
-
- Modified: ${fileInfo.modifiedAt.toLocaleDateString()}
|
|
25
|
-
- Parent folder: ${fileInfo.parentFolder}
|
|
26
|
-
- Folder path: ${fileInfo.folderPath.join(' > ')}`;
|
|
27
|
-
if (fileInfo.documentMetadata) {
|
|
28
|
-
const meta = fileInfo.documentMetadata;
|
|
29
|
-
metadataContext += `
|
|
30
|
-
Document Properties:`;
|
|
31
|
-
if (meta.title)
|
|
32
|
-
metadataContext += `\n- Title: ${meta.title}`;
|
|
33
|
-
if (meta.author)
|
|
34
|
-
metadataContext += `\n- Author: ${meta.author}`;
|
|
35
|
-
if (meta.creator)
|
|
36
|
-
metadataContext += `\n- Creator: ${meta.creator}`;
|
|
37
|
-
if (meta.subject)
|
|
38
|
-
metadataContext += `\n- Subject: ${meta.subject}`;
|
|
39
|
-
if (meta.keywords?.length)
|
|
40
|
-
metadataContext += `\n- Keywords: ${meta.keywords.join(', ')}`;
|
|
41
|
-
if (meta.creationDate)
|
|
42
|
-
metadataContext += `\n- Created: ${meta.creationDate.toLocaleDateString()}`;
|
|
43
|
-
if (meta.modificationDate)
|
|
44
|
-
metadataContext += `\n- Modified: ${meta.modificationDate.toLocaleDateString()}`;
|
|
45
|
-
if (meta.pages)
|
|
46
|
-
metadataContext += `\n- Pages: ${meta.pages}`;
|
|
47
|
-
if (meta.wordCount)
|
|
48
|
-
metadataContext += `\n- Word count: ${meta.wordCount}`;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const prompt = `Based on the following document information, generate a descriptive filename that captures the main topic/purpose of the document. The filename should be:
|
|
52
|
-
- Descriptive and meaningful
|
|
53
|
-
- Professional and clean
|
|
54
|
-
- Between 3-8 words
|
|
55
|
-
- ${namingInstructions}
|
|
56
|
-
- ${templateInstructions}
|
|
57
|
-
- Do not include file extension
|
|
58
|
-
- Do not include personal names, dates, or template variables - just the core content description
|
|
59
|
-
- Only use letters, numbers, and appropriate separators for the naming convention
|
|
60
|
-
- Use all available context (metadata, folder context, document properties) to create the most accurate filename
|
|
61
|
-
|
|
62
|
-
${metadataContext}
|
|
63
|
-
|
|
64
|
-
Document content (first 2000 characters):
|
|
65
|
-
${content.substring(0, 2000)}
|
|
66
|
-
|
|
67
|
-
Respond with only the core filename (without personal info or dates) using the specified naming convention, no explanation.`;
|
|
15
|
+
const prompt = buildFileNamePrompt({
|
|
16
|
+
content,
|
|
17
|
+
originalName,
|
|
18
|
+
namingConvention: convention,
|
|
19
|
+
category: fileCategory,
|
|
20
|
+
fileInfo
|
|
21
|
+
});
|
|
68
22
|
try {
|
|
69
23
|
const response = await this.client.chat.completions.create({
|
|
70
24
|
model: 'gpt-3.5-turbo',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-service.js","sourceRoot":"","sources":["../../src/services/openai-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"openai-service.js","sourceRoot":"","sources":["../../src/services/openai-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAoB,MAAM,gCAAgC,CAAC;AAEzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,OAAO,aAAa;IACxB,IAAI,GAAG,QAAQ,CAAC;IACR,MAAM,CAAS;IAEvB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAe,EAAE,YAAoB,EAAE,mBAA2B,YAAY,EAAE,WAAmB,SAAS,EAAE,QAAmB;QACtJ,MAAM,UAAU,GAAG,gBAAoC,CAAC;QACxD,MAAM,YAAY,GAAG,QAAwB,CAAC;QAE9C,MAAM,MAAM,GAAG,mBAAmB,CAAC;YACjC,OAAO;YACP,YAAY;YACZ,gBAAgB,EAAE,UAAU;YAC5B,QAAQ,EAAE,YAAY;YACtB,QAAQ;SACT,CAAC,CAAC;QAEH,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;gBACzD,KAAK,EAAE,eAAe;gBACtB,QAAQ,EAAE;oBACR;wBACE,IAAI,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,UAAU,KAAK,YAAY,EAAE,CAAC;gBACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FileInfo } from '../types/index.js';
|
|
2
|
+
import { NamingConvention } from './naming-conventions.js';
|
|
3
|
+
import { FileCategory } from './file-templates.js';
|
|
4
|
+
export interface PromptContext {
|
|
5
|
+
content: string;
|
|
6
|
+
originalName: string;
|
|
7
|
+
namingConvention: NamingConvention;
|
|
8
|
+
category: FileCategory;
|
|
9
|
+
fileInfo?: FileInfo;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds a standardized prompt for AI filename generation
|
|
13
|
+
* This prompt is used across all AI providers (Claude, OpenAI, LMStudio, Ollama)
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildFileNamePrompt(context: PromptContext): string;
|
|
16
|
+
/**
|
|
17
|
+
* System prompt for AI models that need a separate system message
|
|
18
|
+
*/
|
|
19
|
+
export declare const AI_SYSTEM_PROMPT = "You are a helpful assistant that generates descriptive filenames based on document content. Always respond with just the filename, no explanation or additional text.";
|
|
20
|
+
//# sourceMappingURL=ai-prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-prompts.d.ts","sourceRoot":"","sources":["../../src/utils/ai-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAyB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAA2B,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAsDlE;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,0KAA0K,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { getNamingInstructions } from './naming-conventions.js';
|
|
2
|
+
import { getTemplateInstructions } from './file-templates.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds a standardized prompt for AI filename generation
|
|
5
|
+
* This prompt is used across all AI providers (Claude, OpenAI, LMStudio, Ollama)
|
|
6
|
+
*/
|
|
7
|
+
export function buildFileNamePrompt(context) {
|
|
8
|
+
const { content, originalName, namingConvention, category, fileInfo } = context;
|
|
9
|
+
const namingInstructions = getNamingInstructions(namingConvention);
|
|
10
|
+
const templateInstructions = getTemplateInstructions(category);
|
|
11
|
+
// Build comprehensive context from all metadata
|
|
12
|
+
let metadataContext = '';
|
|
13
|
+
if (fileInfo) {
|
|
14
|
+
metadataContext += `File Information:
|
|
15
|
+
- Original filename: ${originalName}
|
|
16
|
+
- File size: ${Math.round(fileInfo.size / 1024)}KB
|
|
17
|
+
- Created: ${fileInfo.createdAt.toLocaleDateString()}
|
|
18
|
+
- Modified: ${fileInfo.modifiedAt.toLocaleDateString()}
|
|
19
|
+
- Parent folder: ${fileInfo.parentFolder}
|
|
20
|
+
- Folder path: ${fileInfo.folderPath.join(' > ')}`;
|
|
21
|
+
if (fileInfo.documentMetadata) {
|
|
22
|
+
const meta = fileInfo.documentMetadata;
|
|
23
|
+
metadataContext += `
|
|
24
|
+
Document Properties:`;
|
|
25
|
+
if (meta.title)
|
|
26
|
+
metadataContext += `\n- Title: ${meta.title}`;
|
|
27
|
+
if (meta.author)
|
|
28
|
+
metadataContext += `\n- Author: ${meta.author}`;
|
|
29
|
+
if (meta.creator)
|
|
30
|
+
metadataContext += `\n- Creator: ${meta.creator}`;
|
|
31
|
+
if (meta.subject)
|
|
32
|
+
metadataContext += `\n- Subject: ${meta.subject}`;
|
|
33
|
+
if (meta.keywords?.length)
|
|
34
|
+
metadataContext += `\n- Keywords: ${meta.keywords.join(', ')}`;
|
|
35
|
+
if (meta.creationDate)
|
|
36
|
+
metadataContext += `\n- Created: ${meta.creationDate.toLocaleDateString()}`;
|
|
37
|
+
if (meta.modificationDate)
|
|
38
|
+
metadataContext += `\n- Modified: ${meta.modificationDate.toLocaleDateString()}`;
|
|
39
|
+
if (meta.pages)
|
|
40
|
+
metadataContext += `\n- Pages: ${meta.pages}`;
|
|
41
|
+
if (meta.wordCount)
|
|
42
|
+
metadataContext += `\n- Word count: ${meta.wordCount}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return `Based on the following document information, generate a descriptive filename that captures the main topic/purpose of the document. The filename should be:
|
|
46
|
+
- Descriptive and meaningful
|
|
47
|
+
- Professional and clean
|
|
48
|
+
- Between 3-10 words
|
|
49
|
+
- ${namingInstructions}
|
|
50
|
+
- ${templateInstructions}
|
|
51
|
+
- Do not include file extension
|
|
52
|
+
- If the document is specifically for/about a person (based on content), include their name at the beginning
|
|
53
|
+
- Include dates only if they are essential to the document's identity (e.g., contracts, certificates)
|
|
54
|
+
- Ignore irrelevant folder names that don't describe the document content
|
|
55
|
+
- Only use letters, numbers, and appropriate separators for the naming convention
|
|
56
|
+
- Focus on the document's actual content and purpose, not just metadata
|
|
57
|
+
|
|
58
|
+
${metadataContext}
|
|
59
|
+
|
|
60
|
+
Document content (first 2000 characters):
|
|
61
|
+
${content.substring(0, 2000)}
|
|
62
|
+
|
|
63
|
+
Important: If this document is specifically for or about a particular person mentioned in the content, start the filename with their name. Otherwise, focus on the document's main purpose and content.
|
|
64
|
+
|
|
65
|
+
Respond with only the filename using the specified naming convention, no explanation.`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* System prompt for AI models that need a separate system message
|
|
69
|
+
*/
|
|
70
|
+
export const AI_SYSTEM_PROMPT = 'You are a helpful assistant that generates descriptive filenames based on document content. Always respond with just the filename, no explanation or additional text.';
|
|
71
|
+
//# sourceMappingURL=ai-prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-prompts.js","sourceRoot":"","sources":["../../src/utils/ai-prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAgB,MAAM,qBAAqB,CAAC;AAU5E;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAsB;IACxD,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEhF,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACnE,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAE/D,gDAAgD;IAChD,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,IAAI,QAAQ,EAAE,CAAC;QACb,eAAe,IAAI;uBACA,YAAY;eACpB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;aAClC,QAAQ,CAAC,SAAS,CAAC,kBAAkB,EAAE;cACtC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,EAAE;mBACnC,QAAQ,CAAC,YAAY;iBACvB,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAE/C,IAAI,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,QAAQ,CAAC,gBAAgB,CAAC;YACvC,eAAe,IAAI;qBACJ,CAAC;YAChB,IAAI,IAAI,CAAC,KAAK;gBAAE,eAAe,IAAI,cAAc,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9D,IAAI,IAAI,CAAC,MAAM;gBAAE,eAAe,IA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