Skip to content

Commit

Permalink
Merge pull request #27 from ubq-testing/development
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Nov 2, 2024
2 parents 8ea7b0f + 35e0429 commit eb5487d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
15 changes: 6 additions & 9 deletions src/handlers/ask-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -76,4 +73,4 @@ export async function askGpt(context: Context, question: string, formattedChat:
} catch (error) {
throw bubbleUpErrorComment(context, error, false);
}
}
}
8 changes: 3 additions & 5 deletions src/helpers/issue-fetching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,19 @@ export async function fetchLinkedIssues(params: FetchParams) {
if (!issue) {
return { streamlinedComments: {}, linkedIssues: [], specAndBodies: {}, seen: new Set<string>() };
}
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<string, string> = {};
const seen = new Set<string>([issueKey]);

comments.push({
body: issue.body,
body: issue.body || "",
user: issue.user,
id: issue.id.toString(),
org: params.owner,
Expand Down

0 comments on commit eb5487d

Please sign in to comment.