diff --git a/src/handlers/ask-llm.ts b/src/handlers/ask-llm.ts index f0a262c..801f8e7 100644 --- a/src/handlers/ask-llm.ts +++ b/src/handlers/ask-llm.ts @@ -51,21 +51,18 @@ export async function askGpt(context: Context, question: string, formattedChat: try { const [similarComments, similarIssues] = await Promise.all([ comment.findSimilarComments(question, 1 - similarityThreshold, ""), - issue.findSimilarIssues(question, 1 - similarityThreshold, "") + issue.findSimilarIssues(question, 1 - similarityThreshold, ""), ]); const similarText = [ - ...similarComments?.map((comment: CommentSimilaritySearchResult) => comment.comment_plaintext) || [], - ...similarIssues?.map((issue: IssueSimilaritySearchResult) => issue.issue_plaintext) || [] + ...(similarComments?.map((comment: CommentSimilaritySearchResult) => comment.comment_plaintext) || []), + ...(similarIssues?.map((issue: IssueSimilaritySearchResult) => issue.issue_plaintext) || []), ]; - formattedChat = formattedChat.filter(text => text); + formattedChat = formattedChat.filter((text) => text); const rerankedText = similarText.length > 0 ? await reranker.reRankResults(similarText, question) : []; - const [languages, { dependencies, devDependencies }] = await Promise.all([ - fetchRepoLanguageStats(context), - fetchRepoDependencies(context) - ]); + const [languages, { dependencies, devDependencies }] = await Promise.all([fetchRepoLanguageStats(context), fetchRepoDependencies(context)]); const groundTruths = await findGroundTruths(context, "chat-bot", { languages, dependencies, devDependencies }); @@ -76,4 +73,4 @@ export async function askGpt(context: Context, question: string, formattedChat: } catch (error) { throw bubbleUpErrorComment(context, error, false); } -} \ No newline at end of file +} diff --git a/src/helpers/issue-fetching.ts b/src/helpers/issue-fetching.ts index 9f96d7b..6f01340 100644 --- a/src/helpers/issue-fetching.ts +++ b/src/helpers/issue-fetching.ts @@ -41,21 +41,19 @@ export async function fetchLinkedIssues(params: FetchParams) { if (!issue) { return { streamlinedComments: {}, linkedIssues: [], specAndBodies: {}, seen: new Set() }; } - if (!issue.body || !issue.html_url) { - throw logger.error("Issue body or URL not found", { issueUrl: issue.html_url }); - } if (!params.owner || !params.repo) { throw logger.error("Owner or repo not found"); } + const issueKey = createKey(issue.html_url); const [owner, repo, issueNumber] = splitKey(issueKey); - const linkedIssues: LinkedIssues[] = [{ body: issue.body, comments, issueNumber: parseInt(issueNumber), owner, repo, url: issue.html_url }]; + const linkedIssues: LinkedIssues[] = [{ body: issue.body || "", comments, issueNumber: parseInt(issueNumber), owner, repo, url: issue.html_url }]; const specAndBodies: Record = {}; const seen = new Set([issueKey]); comments.push({ - body: issue.body, + body: issue.body || "", user: issue.user, id: issue.id.toString(), org: params.owner,