Skip to content

feat: add AI-powered cluster naming with fallback to TF-IDF#35

Open
Harsh16gupta wants to merge 1 commit into
masterfrom
feat/ai-cluster-naming
Open

feat: add AI-powered cluster naming with fallback to TF-IDF#35
Harsh16gupta wants to merge 1 commit into
masterfrom
feat/ai-cluster-naming

Conversation

@Harsh16gupta

Copy link
Copy Markdown
Collaborator

This PR adds cluster naming using Joplin's native AI chat API (joplin.ai.chat()).

Changes

  • Added aiNamingService.ts to format prompts, parse JSON responses, and sanitize category names.
  • Integrated AI naming into runPipeline.ts right after TF-IDF tag extraction (runs for both native embeddings and local ONNX worker paths).
  • Extended src/types/joplinAi.d.ts type declarations to include ChatMessage, ChatResult, and chat().
  • Added unit tests in test/pipeline/clustering/aiNamingService.test.ts.

Fallback Behavior

  • If AI is disabled, unconfigured, times out (>45s), or returns an invalid response, the pipeline falls back to existing TF-IDF names.
  • postProcess.ts and clusterNaming.ts remain untouched.

Testing
image

naming after using ai chat api
image

@Harsh16gupta Harsh16gupta self-assigned this Jul 25, 2026
@Harsh16gupta
Harsh16gupta requested a review from HahaBill July 25, 2026 23:19
@Harsh16gupta

Copy link
Copy Markdown
Collaborator Author

Regarding Provider Support:

joplin.ai.chat() routes through whatever provider the user has configured in Joplin's AI settings:

  • Local models via Ollama, LM Studio, or LocalAI
  • OpenAI-compatible APIs like DeepSeek, OpenAI, or Groq
  • Joplin Cloud AI and Anthropic (Claude)

The pr does not hardcode any provider or API key; it uses whichever model the user has active in Joplin Desktop.

I have tested it with deepseek, @HahaBill do you want me to test with other providers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant