-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
Deploying unsight with
|
Latest commit: |
e12c486
|
Status: | ✅ Deploy successful! |
Preview URL: | https://3840fe27.unsight.pages.dev |
Branch Preview URL: | https://feat-cluster-titles.unsight.pages.dev |
There was a problem hiding this 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>) { |
There was a problem hiding this comment.
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.
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'>) { |
There was a problem hiding this comment.
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:
function getLabels(issue: Pick<Issue | RestIssue, 'labels' | 'title' | 'body'>) { | |
function getLabels(issue: Pick<Issue | RestIssue, IssueSegments >) { |
good points! feel free to open a pr if you want 🙏 |
resolves #5