Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): generate titles for clusters #109

Merged
merged 1 commit into from
Mar 15, 2025
Merged

Conversation

danielroe
Copy link
Owner

resolves #5

Copy link

Deploying unsight with  Cloudflare Pages  Cloudflare Pages

Latest commit: e12c486
Status: ✅  Deploy successful!
Preview URL: https://3840fe27.unsight.pages.dev
Branch Preview URL: https://feat-cluster-titles.unsight.pages.dev

View logs

@danielroe danielroe merged commit 6f7a72b into main Mar 15, 2025
6 checks passed
@danielroe danielroe deleted the feat/cluster-titles branch March 15, 2025 16:57
Copy link
Contributor

@Kai-ros Kai-ros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielroe Was too slow! Sharing anyways in case you care for the feedback. 😆

@@ -136,7 +136,7 @@ function preprocessText(text: string): string {
.trim()
}

function chunkIssue(issue: Issue | RestIssue, exclude?: Set<string>) {
export function chunkIssue(issue: Pick<Issue | RestIssue, 'labels' | 'title' | 'body'>, exclude?: Set<string>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Fairly opposed to string literals as of TS5.8, would suggest instead opting for a mapped type w/as const. The trade-off of less flexibility and a little more TS syntactical complexity here is worthwhile when gaining the stronger type safety and type inference when using an indexed access type. And I'd add that personally I find Pick more readable with just types in it and no strings.

Suggested change
export function chunkIssue(issue: Pick<Issue | RestIssue, 'labels' | 'title' | 'body'>, exclude?: Set<string>) {
export const issueSegments = { labels: 'labels', title: 'title', body: 'body', } as const;
export type IssueSegments = (typeof issueSegments)[keyof typeof issueSegments];
export function chunkIssue( issue: Pick<Issue | RestIssue, IssueSegments>, exclude?: Set<string>, ) { const labels = getLabels(issue).filter((l) => !exclude?.has(l)); return preprocessText( ${issue[issueSegments.title]}\n${labels.join(', ')}\n${ issue[issueSegments.body] }, ); }

@@ -152,6 +152,6 @@ async function generateEmbedding(text: string): Promise<number[]> {
}
}

function getLabels(issue: Issue | RestIssue) {
function getLabels(issue: Pick<Issue | RestIssue, 'labels' | 'title' | 'body'>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: And you get to re-use it down here:

Suggested change
function getLabels(issue: Pick<Issue | RestIssue, 'labels' | 'title' | 'body'>) {
function getLabels(issue: Pick<Issue | RestIssue, IssueSegments >) {

@danielroe
Copy link
Owner Author

good points! feel free to open a pr if you want 🙏

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.

cluster 'title' generated by ai
2 participants