Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5208327b5d | ||
|
|
ac76871d60 | ||
|
|
66c86c2625 | ||
|
|
56d0c21b79 | ||
|
|
37e81e773e | ||
|
|
534da11217 | ||
|
|
2212755772 |
@@ -4,11 +4,13 @@ kongruity employs Large Language Model ("LLM") semantic grouping functionality t
|
|||||||
|
|
||||||
(To learn more about this topic, see, e.g., [Kozlowski A., Boutyline A., Semantic Structure in Large Language Model Embeddings Aug. 2025, arXiv:2508.10003v1:04 Aug 2025](https://arxiv.org/html/2508.10003v1)).
|
(To learn more about this topic, see, e.g., [Kozlowski A., Boutyline A., Semantic Structure in Large Language Model Embeddings Aug. 2025, arXiv:2508.10003v1:04 Aug 2025](https://arxiv.org/html/2508.10003v1)).
|
||||||
|
|
||||||
In the world of kongruity, these "to dos" are called "sticky notes." kongruity's React/Vite UI views a board of seemingly chaotic "sticky notes". But with one click, they are transformed into manageable, actionable groups, each with a header that explains the group semantic interrelation.
|
In kongruity world, "to dos", action items, agile tickets... the myriad artifacts of the creative/engineering process, are "sticky notes."
|
||||||
|
|
||||||
The backend is an Express API that serves "sticky note" data and proxies semantic grouping requests to Antrhopic Claude.
|
kongruity's React/Vite UI displays a board of seemingly chaotic "sticky notes". But with one click, they are transformed into manageable, actionable groups, each with a header that explains that group's semantic relation.
|
||||||
|
|
||||||
Developers may feel free to install other LLM SDKs and alter the syntax at backend/services/clustering.service.js to experiment with any LLM model/platform they prefer.
|
The backend is an Express API that serves "sticky note" data and proxies semantic grouping requests to Large Language Models.
|
||||||
|
|
||||||
|
Developers may freeely swap in other LLM SDKs and/or APIs... and alter prompt syntax at backend/services/clustering.service.js to compliement their experimentation with any LLM model/platform they prefer.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ app.use(express.json());
|
|||||||
app.use('/v1/notes', router);
|
app.use('/v1/notes', router);
|
||||||
|
|
||||||
app.use((req, res) => {
|
app.use((req, res) => {
|
||||||
res.status(404).json({ error: `Requested path is invalid or does not exist: ${req.method} ${req.originalUrl}` });
|
res.status(404).json({ error: `Requested path is invalid or does not exist: ${req.method} ${req.originalUrl}` });
|
||||||
});
|
});
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { readFile } from 'fs/promises';
|
|||||||
import { clusterNotes } from '../services/clustering.service.js';
|
import { clusterNotes } from '../services/clustering.service.js';
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
const DATA_PATH = '../data/notes.json'
|
const DATA_PATH = new URL('../data/notes.json', import.meta.url);
|
||||||
|
|
||||||
const loadNotes = async () => {
|
const loadNotes = async () => {
|
||||||
const raw = await readFile(DATA_PATH, 'utf-8');
|
const raw = await readFile(DATA_PATH, 'utf-8');
|
||||||
@@ -15,7 +15,7 @@ router.get('/', async (req, res) => {
|
|||||||
const notes = await loadNotes();
|
const notes = await loadNotes();
|
||||||
res.json(notes);
|
res.json(notes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Error loading notes: ${err}`)
|
console.error(`Error loading notes: ${err}`);
|
||||||
res.status(500).json({ error: 'Failed to load notes' });
|
res.status(500).json({ error: 'Failed to load notes' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -26,8 +26,8 @@ router.post('/cluster', async (req, res) => {
|
|||||||
const clusters = await clusterNotes(notes);
|
const clusters = await clusterNotes(notes);
|
||||||
res.json(clusters);
|
res.json(clusters);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Clustering failed: ${err}` )
|
console.error(`Clustering failed: ${err}`);
|
||||||
res.status(500).json({ error: `Clustering failed: ${err}` });
|
res.status(500).json({ error: 'Clustering failed' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,15 @@ export const clusterNotes = async (notes) => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const raw = response.content[0].text;
|
const textBlock = response?.content?.[0];
|
||||||
return JSON.parse(raw);
|
|
||||||
|
if (!textBlock || textBlock.type !== 'text' || typeof textBlock.text !== 'string') {
|
||||||
|
throw new Error('Unexpected response from LLM API: no text content returned');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(textBlock.text);
|
||||||
|
} catch {
|
||||||
|
throw new Error('LLM API returned non-JSON response');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ describe('clusterNotes service', () => {
|
|||||||
|
|
||||||
it('should call Anthropic messages.create with the correct model', async () => {
|
it('should call Anthropic messages.create with the correct model', async () => {
|
||||||
createMock.mockResolvedValue({
|
createMock.mockResolvedValue({
|
||||||
content: [{ text: JSON.stringify(MOCK_CLUSTERS) }],
|
content: [{ type: 'text', text: JSON.stringify(MOCK_CLUSTERS) }],
|
||||||
});
|
});
|
||||||
|
|
||||||
await clusterNotes(MOCK_NOTES);
|
await clusterNotes(MOCK_NOTES);
|
||||||
@@ -48,7 +48,7 @@ describe('clusterNotes service', () => {
|
|||||||
|
|
||||||
it('should include all note texts in prompt sent to the LLM API', async () => {
|
it('should include all note texts in prompt sent to the LLM API', async () => {
|
||||||
createMock.mockResolvedValue({
|
createMock.mockResolvedValue({
|
||||||
content: [{ text: JSON.stringify(MOCK_CLUSTERS) }],
|
content: [{ type: 'text', text: JSON.stringify(MOCK_CLUSTERS) }],
|
||||||
});
|
});
|
||||||
|
|
||||||
await clusterNotes(MOCK_NOTES);
|
await clusterNotes(MOCK_NOTES);
|
||||||
@@ -62,7 +62,7 @@ describe('clusterNotes service', () => {
|
|||||||
|
|
||||||
it('should parse and return the clustered JSON from the API response', async () => {
|
it('should parse and return the clustered JSON from the API response', async () => {
|
||||||
createMock.mockResolvedValue({
|
createMock.mockResolvedValue({
|
||||||
content: [{ text: JSON.stringify(MOCK_CLUSTERS) }],
|
content: [{ type: 'text', text: JSON.stringify(MOCK_CLUSTERS) }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await clusterNotes(MOCK_NOTES);
|
const result = await clusterNotes(MOCK_NOTES);
|
||||||
@@ -72,10 +72,16 @@ describe('clusterNotes service', () => {
|
|||||||
|
|
||||||
it('should throw error when the API returns non-JSON', async () => {
|
it('should throw error when the API returns non-JSON', async () => {
|
||||||
createMock.mockResolvedValue({
|
createMock.mockResolvedValue({
|
||||||
content: [{ text: 'An unknown error occured when generting structured response.' }],
|
content: [{ type: 'text', text: 'An unknown error occured when generting structured response.' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
await expect(clusterNotes(MOCK_NOTES)).rejects.toThrow();
|
await expect(clusterNotes(MOCK_NOTES)).rejects.toThrow('non-JSON response');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error when the API response has no text content', async () => {
|
||||||
|
createMock.mockResolvedValue({ content: [] });
|
||||||
|
|
||||||
|
await expect(clusterNotes(MOCK_NOTES)).rejects.toThrow('no text content returned');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error when Anthropic API authentication fails', async () => {
|
it('should throw error when Anthropic API authentication fails', async () => {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const Stickies = () => {
|
|||||||
const stickyMap = buildStickyMap();
|
const stickyMap = buildStickyMap();
|
||||||
|
|
||||||
const renderStickies = (items: StickyType[]) =>
|
const renderStickies = (items: StickyType[]) =>
|
||||||
items.map((sticky) => <Sticky key={sticky.id} sticky={sticky} />);
|
items?.map((sticky) => <Sticky key={sticky.id} sticky={sticky} />);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="stickies-container">
|
<div className="stickies-container">
|
||||||
@@ -36,8 +36,8 @@ const Stickies = () => {
|
|||||||
<h3 className="cluster-label">{group.label}</h3>
|
<h3 className="cluster-label">{group.label}</h3>
|
||||||
<div className="stickies-grid">
|
<div className="stickies-grid">
|
||||||
{renderStickies(
|
{renderStickies(
|
||||||
group.noteIds
|
group?.noteIds
|
||||||
.map((id) => stickyMap.get(id))
|
.map((id) => stickyMap?.get(id))
|
||||||
.filter((s): s is StickyType => !!s)
|
.filter((s): s is StickyType => !!s)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import '../styles/home.css'
|
|||||||
const Home = () => {
|
const Home = () => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div>
|
|
||||||
<Navbar />
|
<Navbar />
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Stickies />
|
<Stickies />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.main-head-box {
|
.main-head-box {
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid #6dd6f4;
|
border: 1px solid #6dd6f4;
|
||||||
background-color: rgb(92, 0 91);
|
background-color: rgb(92, 0, 91);
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user