Skip to content

Commit

Permalink
fix(Search): missing PR details when searching (#163)
Browse files Browse the repository at this point in the history
* fix(Search): missing PR details when searching

* Bot - Fix Formatting

---------

Co-authored-by: homie bot <[email protected]>
  • Loading branch information
mikewuu and homieggbot authored Jul 29, 2024
1 parent 07b633b commit e105b06
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/lib/ai/chat/tools/get-search-pull-requests-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export function getSearchPullRequestsTool(
),
})

const rankedDocuments = reranked.results.filter(
(result) => result.relevanceScore > searchRelevanceThreshold,
)
const rankedDocuments = reranked.results
.filter((result) => result.relevanceScore > searchRelevanceThreshold)
.map((result) => matches[result.index].metadata) // return metadata as results

logger.debug('Ranked and filtered results', {
event: 'get_answer:search_pull_requests:ranked_results',
Expand Down
1 change: 1 addition & 0 deletions src/lib/ai/embed-code-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export async function embedCodeChange(params: EmbedCodeChangeParams) {
metadata: {
...metadata,
text,
code_change: point,
},
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib/ai/embed-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export async function embedDiff(params: EmbedDiffParams) {
metadata: {
...metadata,
text,
code_snippet: snippet,
pull_request_title: title,
pull_request_url: url,
},
}

Expand Down
12 changes: 6 additions & 6 deletions src/lib/github/save-merged-pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ export async function saveMergedPullRequest(
const wasMergedToDefaultBranch =
pullRequest.base.ref === pullRequest.base.repo.default_branch

const embed_metadata = {
const embedMetadata = {
type: 'pr_summary',
title: pullRequest.title,
url: pullRequest.html_url,
pull_request_title: pullRequest.title,
pull_request_url: pullRequest.html_url,
ext_gh_pull_request_id: pullRequest.id,
organization_id: organization.id,
contributor_id: contributor.id,
Expand All @@ -182,7 +182,7 @@ export async function saveMergedPullRequest(
merged_at: parseISO(pullRequest.merged_at),
number: pullRequest.number,
embed_value: summary,
embed_metadata,
embed_metadata: embedMetadata,
source_branch: pullRequest.head.ref,
target_branch: pullRequest.base.ref,
was_merged_to_default_branch: wasMergedToDefaultBranch,
Expand All @@ -199,7 +199,7 @@ export async function saveMergedPullRequest(
merged_at: parseISO(pullRequest.merged_at!),
number: pullRequest.number,
embed_value: summary,
embed_metadata,
embed_metadata: embedMetadata,
source_branch: pullRequest.head.ref,
target_branch: pullRequest.base.ref,
was_merged_to_default_branch: wasMergedToDefaultBranch,
Expand All @@ -217,7 +217,7 @@ export async function saveMergedPullRequest(
title: pullRequest.title,
url: pullRequest.html_url,
summary,
metadata: embed_metadata,
metadata: embedMetadata,
contributor: pullRequest.user.login,
mergedAt: pullRequestRecord.merged_at,
})
Expand Down
8 changes: 4 additions & 4 deletions src/lib/gitlab/save-merged-merge-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ export async function saveMergedMergeRequest(

const wasMergedToDefaultBranch = mergeRequest.target_branch === defaultBranch

const embed_metadata = {
const embedMetadata = {
type: 'pr_summary',
title: mergeRequest.title,
url: mergeRequest.web_url,
pull_request_title: mergeRequest.title,
pull_request_url: mergeRequest.web_url,
ext_gitlab_merge_request_id: mergeRequest.id,
organization_id: organization.id,
contributor_id: contributor.id,
Expand Down Expand Up @@ -161,7 +161,7 @@ export async function saveMergedMergeRequest(
title: pullRequestRecord.title,
url: pullRequestRecord.html_url,
summary,
metadata: embed_metadata,
metadata: embedMetadata,
contributor: mergeRequest.author.username,
mergedAt: pullRequestRecord.merged_at,
})
Expand Down

0 comments on commit e105b06

Please sign in to comment.