diff --git a/src/lib/ai/chat/tools/get-search-pull-requests-tool.ts b/src/lib/ai/chat/tools/get-search-pull-requests-tool.ts index ce726f27..cc1d30cb 100644 --- a/src/lib/ai/chat/tools/get-search-pull-requests-tool.ts +++ b/src/lib/ai/chat/tools/get-search-pull-requests-tool.ts @@ -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', diff --git a/src/lib/ai/embed-code-change.ts b/src/lib/ai/embed-code-change.ts index c34692a7..7c8a3916 100644 --- a/src/lib/ai/embed-code-change.ts +++ b/src/lib/ai/embed-code-change.ts @@ -44,6 +44,7 @@ export async function embedCodeChange(params: EmbedCodeChangeParams) { metadata: { ...metadata, text, + code_change: point, }, } diff --git a/src/lib/ai/embed-diff.ts b/src/lib/ai/embed-diff.ts index 34c29da2..ec184645 100644 --- a/src/lib/ai/embed-diff.ts +++ b/src/lib/ai/embed-diff.ts @@ -52,6 +52,9 @@ export async function embedDiff(params: EmbedDiffParams) { metadata: { ...metadata, text, + code_snippet: snippet, + pull_request_title: title, + pull_request_url: url, }, } diff --git a/src/lib/github/save-merged-pull-request.ts b/src/lib/github/save-merged-pull-request.ts index 31b681e2..bca1d212 100644 --- a/src/lib/github/save-merged-pull-request.ts +++ b/src/lib/github/save-merged-pull-request.ts @@ -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, @@ -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, @@ -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, @@ -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, }) diff --git a/src/lib/gitlab/save-merged-merge-request.ts b/src/lib/gitlab/save-merged-merge-request.ts index f1a7d345..fa38397c 100644 --- a/src/lib/gitlab/save-merged-merge-request.ts +++ b/src/lib/gitlab/save-merged-merge-request.ts @@ -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, @@ -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, })